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