169b07ee3SNishad Kamdar /* SPDX-License-Identifier: GPL-2.0 */ 29fd4dcecSNicolai Stange /* 39fd4dcecSNicolai Stange * internal.h - declarations internal to debugfs 49fd4dcecSNicolai Stange * 59fd4dcecSNicolai Stange * Copyright (C) 2016 Nicolai Stange <nicstange@gmail.com> 69fd4dcecSNicolai Stange */ 79fd4dcecSNicolai Stange 89fd4dcecSNicolai Stange #ifndef _DEBUGFS_INTERNAL_H_ 99fd4dcecSNicolai Stange #define _DEBUGFS_INTERNAL_H_ 109fd4dcecSNicolai Stange 119fd4dcecSNicolai Stange struct file_operations; 129fd4dcecSNicolai Stange 139fd4dcecSNicolai Stange /* declared over in file.c */ 149fd4dcecSNicolai Stange extern const struct file_operations debugfs_noop_file_operations; 159fd4dcecSNicolai Stange extern const struct file_operations debugfs_open_proxy_file_operations; 1649d200deSNicolai Stange extern const struct file_operations debugfs_full_proxy_file_operations; 179fd4dcecSNicolai Stange 187c8d4698SNicolai Stange struct debugfs_fsdata { 197c8d4698SNicolai Stange const struct file_operations *real_fops; 20*c455b17aSJohannes Berg union { 21*c455b17aSJohannes Berg /* automount_fn is used when real_fops is NULL */ 22*c455b17aSJohannes Berg debugfs_automount_t automount; 23*c455b17aSJohannes Berg struct { 24e9117a5aSNicolai Stange refcount_t active_users; 25e9117a5aSNicolai Stange struct completion active_users_drained; 267c8d4698SNicolai Stange }; 27*c455b17aSJohannes Berg }; 28*c455b17aSJohannes Berg }; 297c8d4698SNicolai Stange 307d39bc50SNicolai Stange /* 317d39bc50SNicolai Stange * A dentry's ->d_fsdata either points to the real fops or to a 327d39bc50SNicolai Stange * dynamically allocated debugfs_fsdata instance. 337d39bc50SNicolai Stange * In order to distinguish between these two cases, a real fops 347d39bc50SNicolai Stange * pointer gets its lowest bit set. 357d39bc50SNicolai Stange */ 367d39bc50SNicolai Stange #define DEBUGFS_FSDATA_IS_REAL_FOPS_BIT BIT(0) 377d39bc50SNicolai Stange 38a24c6f7bSPeter Enderborg /* Access BITS */ 39a24c6f7bSPeter Enderborg #define DEBUGFS_ALLOW_API BIT(0) 40a24c6f7bSPeter Enderborg #define DEBUGFS_ALLOW_MOUNT BIT(1) 41a24c6f7bSPeter Enderborg 42a24c6f7bSPeter Enderborg #ifdef CONFIG_DEBUG_FS_ALLOW_ALL 43a24c6f7bSPeter Enderborg #define DEFAULT_DEBUGFS_ALLOW_BITS (DEBUGFS_ALLOW_MOUNT | DEBUGFS_ALLOW_API) 44a24c6f7bSPeter Enderborg #endif 45a24c6f7bSPeter Enderborg #ifdef CONFIG_DEBUG_FS_DISALLOW_MOUNT 46a24c6f7bSPeter Enderborg #define DEFAULT_DEBUGFS_ALLOW_BITS (DEBUGFS_ALLOW_API) 47a24c6f7bSPeter Enderborg #endif 48a24c6f7bSPeter Enderborg #ifdef CONFIG_DEBUG_FS_ALLOW_NONE 49a24c6f7bSPeter Enderborg #define DEFAULT_DEBUGFS_ALLOW_BITS (0) 50a24c6f7bSPeter Enderborg #endif 51a24c6f7bSPeter Enderborg 529fd4dcecSNicolai Stange #endif /* _DEBUGFS_INTERNAL_H_ */ 53