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