Linux 6.14-rc1
[linux-stable.git] / fs / debugfs / internal.h
blob93483fe844257c4bcae05641d4eb6b6855a77217
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * internal.h - declarations internal to debugfs
5 * Copyright (C) 2016 Nicolai Stange <nicstange@gmail.com>
6 */
8 #ifndef _DEBUGFS_INTERNAL_H_
9 #define _DEBUGFS_INTERNAL_H_
10 #include <linux/list.h>
12 struct file_operations;
14 struct debugfs_inode_info {
15 struct inode vfs_inode;
16 union {
17 const void *raw;
18 const struct file_operations *real_fops;
19 const struct debugfs_short_fops *short_fops;
20 debugfs_automount_t automount;
22 const void *aux;
25 static inline struct debugfs_inode_info *DEBUGFS_I(struct inode *inode)
27 return container_of(inode, struct debugfs_inode_info, vfs_inode);
30 /* declared over in file.c */
31 extern const struct file_operations debugfs_noop_file_operations;
32 extern const struct file_operations debugfs_open_proxy_file_operations;
33 extern const struct file_operations debugfs_full_proxy_file_operations;
34 extern const struct file_operations debugfs_full_short_proxy_file_operations;
36 struct debugfs_fsdata {
37 const struct file_operations *real_fops;
38 const struct debugfs_short_fops *short_fops;
39 struct {
40 refcount_t active_users;
41 struct completion active_users_drained;
43 /* protect cancellations */
44 struct mutex cancellations_mtx;
45 struct list_head cancellations;
46 unsigned int methods;
50 enum {
51 HAS_READ = 1,
52 HAS_WRITE = 2,
53 HAS_LSEEK = 4,
54 HAS_POLL = 8,
55 HAS_IOCTL = 16
58 #define DEBUGFS_ALLOW_API BIT(0)
59 #define DEBUGFS_ALLOW_MOUNT BIT(1)
61 #ifdef CONFIG_DEBUG_FS_ALLOW_ALL
62 #define DEFAULT_DEBUGFS_ALLOW_BITS (DEBUGFS_ALLOW_MOUNT | DEBUGFS_ALLOW_API)
63 #endif
64 #ifdef CONFIG_DEBUG_FS_DISALLOW_MOUNT
65 #define DEFAULT_DEBUGFS_ALLOW_BITS (DEBUGFS_ALLOW_API)
66 #endif
67 #ifdef CONFIG_DEBUG_FS_ALLOW_NONE
68 #define DEFAULT_DEBUGFS_ALLOW_BITS (0)
69 #endif
71 #endif /* _DEBUGFS_INTERNAL_H_ */