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 #include <linux/lockdep.h> 11 #include <linux/list.h> 12 13 struct file_operations; 14 15 /* declared over in file.c */ 16 extern const struct file_operations debugfs_noop_file_operations; 17 extern const struct file_operations debugfs_open_proxy_file_operations; 18 extern const struct file_operations debugfs_full_proxy_file_operations; 19 20 struct debugfs_fsdata { 21 const struct file_operations *real_fops; 22 union { 23 /* automount_fn is used when real_fops is NULL */ 24 debugfs_automount_t automount; 25 struct { 26 refcount_t active_users; 27 struct completion active_users_drained; 28 #ifdef CONFIG_LOCKDEP 29 struct lockdep_map lockdep_map; 30 struct lock_class_key key; 31 char *lock_name; 32 #endif 33 34 /* protect cancellations */ 35 struct mutex cancellations_mtx; 36 struct list_head cancellations; 37 }; 38 }; 39 }; 40 41 /* 42 * A dentry's ->d_fsdata either points to the real fops or to a 43 * dynamically allocated debugfs_fsdata instance. 44 * In order to distinguish between these two cases, a real fops 45 * pointer gets its lowest bit set. 46 */ 47 #define DEBUGFS_FSDATA_IS_REAL_FOPS_BIT BIT(0) 48 49 /* Access BITS */ 50 #define DEBUGFS_ALLOW_API BIT(0) 51 #define DEBUGFS_ALLOW_MOUNT BIT(1) 52 53 #ifdef CONFIG_DEBUG_FS_ALLOW_ALL 54 #define DEFAULT_DEBUGFS_ALLOW_BITS (DEBUGFS_ALLOW_MOUNT | DEBUGFS_ALLOW_API) 55 #endif 56 #ifdef CONFIG_DEBUG_FS_DISALLOW_MOUNT 57 #define DEFAULT_DEBUGFS_ALLOW_BITS (DEBUGFS_ALLOW_API) 58 #endif 59 #ifdef CONFIG_DEBUG_FS_ALLOW_NONE 60 #define DEFAULT_DEBUGFS_ALLOW_BITS (0) 61 #endif 62 63 #endif /* _DEBUGFS_INTERNAL_H_ */ 64