Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
| 14 | #ifdef CONFIG_PROFILING |
| 15 | |
Bob Nelson | 1474855 | 2007-07-20 21:39:53 +0200 | [diff] [blame] | 16 | #include <linux/dcache.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/types.h> |
| 18 | |
| 19 | struct dcookie_user; |
Alexey Dobriyan | 37721e1 | 2011-01-10 08:17:10 +0200 | [diff] [blame] | 20 | struct path; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * dcookie_register - register a user of dcookies |
| 24 | * |
| 25 | * Register as a dcookie user. Returns %NULL on failure. |
| 26 | */ |
| 27 | struct 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 | */ |
| 35 | void 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 Viro | 71215a7 | 2016-11-20 19:30:18 -0500 | [diff] [blame] | 48 | int get_dcookie(const struct path *path, unsigned long *cookie); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | #else |
| 51 | |
Adrian Bunk | 0072b13 | 2005-08-01 21:11:39 -0700 | [diff] [blame] | 52 | static inline struct dcookie_user * dcookie_register(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | { |
| 54 | return NULL; |
| 55 | } |
| 56 | |
Adrian Bunk | 0072b13 | 2005-08-01 21:11:39 -0700 | [diff] [blame] | 57 | static inline void dcookie_unregister(struct dcookie_user * user) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | { |
| 59 | return; |
| 60 | } |
Jan Blunck | 448678a | 2008-02-14 19:38:36 -0800 | [diff] [blame] | 61 | |
Al Viro | 71215a7 | 2016-11-20 19:30:18 -0500 | [diff] [blame] | 62 | static inline int get_dcookie(const struct path *path, unsigned long *cookie) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | { |
| 64 | return -ENOSYS; |
Jan Blunck | 448678a | 2008-02-14 19:38:36 -0800 | [diff] [blame] | 65 | } |
| 66 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | #endif /* CONFIG_PROFILING */ |
Jan Blunck | 448678a | 2008-02-14 19:38:36 -0800 | [diff] [blame] | 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | #endif /* DCOOKIES_H */ |