blob: ddfdac20cad03ca774c87be11b0dd4350eb0a0c1 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * dcookies.h
4 *
5 * Persistent cookie-path mappings
6 *
7 * Copyright 2002 John Levon <levon@movementarian.org>
8 */
9
10#ifndef DCOOKIES_H
11#define DCOOKIES_H
12
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
14#ifdef CONFIG_PROFILING
15
Bob Nelson14748552007-07-20 21:39:53 +020016#include <linux/dcache.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/types.h>
18
19struct dcookie_user;
Alexey Dobriyan37721e12011-01-10 08:17:10 +020020struct path;
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
22/**
23 * dcookie_register - register a user of dcookies
24 *
25 * Register as a dcookie user. Returns %NULL on failure.
26 */
27struct dcookie_user * dcookie_register(void);
28
29/**
30 * dcookie_unregister - unregister a user of dcookies
31 *
32 * Unregister as a dcookie user. This may invalidate
33 * any dcookie values returned from get_dcookie().
34 */
35void dcookie_unregister(struct dcookie_user * user);
36
37/**
38 * get_dcookie - acquire a dcookie
39 *
40 * Convert the given dentry/vfsmount pair into
41 * a cookie value.
42 *
43 * Returns -EINVAL if no living task has registered as a
44 * dcookie user.
45 *
46 * Returns 0 on success, with *cookie filled in
47 */
Al Viro71215a72016-11-20 19:30:18 -050048int get_dcookie(const struct path *path, unsigned long *cookie);
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50#else
51
Adrian Bunk0072b132005-08-01 21:11:39 -070052static inline struct dcookie_user * dcookie_register(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070053{
54 return NULL;
55}
56
Adrian Bunk0072b132005-08-01 21:11:39 -070057static inline void dcookie_unregister(struct dcookie_user * user)
Linus Torvalds1da177e2005-04-16 15:20:36 -070058{
59 return;
60}
Jan Blunck448678a2008-02-14 19:38:36 -080061
Al Viro71215a72016-11-20 19:30:18 -050062static inline int get_dcookie(const struct path *path, unsigned long *cookie)
Linus Torvalds1da177e2005-04-16 15:20:36 -070063{
64 return -ENOSYS;
Jan Blunck448678a2008-02-14 19:38:36 -080065}
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067#endif /* CONFIG_PROFILING */
Jan Blunck448678a2008-02-14 19:38:36 -080068
Linus Torvalds1da177e2005-04-16 15:20:36 -070069#endif /* DCOOKIES_H */