xref: /openbmc/linux/fs/debugfs/internal.h (revision c455b17a)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  *  internal.h - declarations internal to debugfs
4  *
5  *  Copyright (C) 2016 Nicolai Stange <nicstange@gmail.com>
6  */
7 
8 #ifndef _DEBUGFS_INTERNAL_H_
9 #define _DEBUGFS_INTERNAL_H_
10 
11 struct file_operations;
12 
13 /* declared over in file.c */
14 extern const struct file_operations debugfs_noop_file_operations;
15 extern const struct file_operations debugfs_open_proxy_file_operations;
16 extern const struct file_operations debugfs_full_proxy_file_operations;
17 
18 struct debugfs_fsdata {
19 	const struct file_operations *real_fops;
20 	union {
21 		/* automount_fn is used when real_fops is NULL */
22 		debugfs_automount_t automount;
23 		struct {
24 			refcount_t active_users;
25 			struct completion active_users_drained;
26 		};
27 	};
28 };
29 
30 /*
31  * A dentry's ->d_fsdata either points to the real fops or to a
32  * dynamically allocated debugfs_fsdata instance.
33  * In order to distinguish between these two cases, a real fops
34  * pointer gets its lowest bit set.
35  */
36 #define DEBUGFS_FSDATA_IS_REAL_FOPS_BIT BIT(0)
37 
38 /* Access BITS */
39 #define DEBUGFS_ALLOW_API	BIT(0)
40 #define DEBUGFS_ALLOW_MOUNT	BIT(1)
41 
42 #ifdef CONFIG_DEBUG_FS_ALLOW_ALL
43 #define DEFAULT_DEBUGFS_ALLOW_BITS (DEBUGFS_ALLOW_MOUNT | DEBUGFS_ALLOW_API)
44 #endif
45 #ifdef CONFIG_DEBUG_FS_DISALLOW_MOUNT
46 #define DEFAULT_DEBUGFS_ALLOW_BITS (DEBUGFS_ALLOW_API)
47 #endif
48 #ifdef CONFIG_DEBUG_FS_ALLOW_NONE
49 #define DEFAULT_DEBUGFS_ALLOW_BITS (0)
50 #endif
51 
52 #endif /* _DEBUGFS_INTERNAL_H_ */
53