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_ 10*8c88a474SJohannes Berg #include <linux/list.h> 119fd4dcecSNicolai Stange 129fd4dcecSNicolai Stange struct file_operations; 139fd4dcecSNicolai Stange 149fd4dcecSNicolai Stange /* declared over in file.c */ 159fd4dcecSNicolai Stange extern const struct file_operations debugfs_noop_file_operations; 169fd4dcecSNicolai Stange extern const struct file_operations debugfs_open_proxy_file_operations; 1749d200deSNicolai Stange extern const struct file_operations debugfs_full_proxy_file_operations; 189fd4dcecSNicolai Stange 197c8d4698SNicolai Stange struct debugfs_fsdata { 207c8d4698SNicolai Stange const struct file_operations *real_fops; 210ed04a18SJohannes Berg union { 220ed04a18SJohannes Berg /* automount_fn is used when real_fops is NULL */ 230ed04a18SJohannes Berg debugfs_automount_t automount; 240ed04a18SJohannes Berg struct { 25e9117a5aSNicolai Stange refcount_t active_users; 26e9117a5aSNicolai Stange struct completion active_users_drained; 27*8c88a474SJohannes Berg 28*8c88a474SJohannes Berg /* protect cancellations */ 29*8c88a474SJohannes Berg struct mutex cancellations_mtx; 30*8c88a474SJohannes Berg struct list_head cancellations; 317c8d4698SNicolai Stange }; 320ed04a18SJohannes Berg }; 330ed04a18SJohannes Berg }; 347c8d4698SNicolai Stange 357d39bc50SNicolai Stange /* 367d39bc50SNicolai Stange * A dentry's ->d_fsdata either points to the real fops or to a 377d39bc50SNicolai Stange * dynamically allocated debugfs_fsdata instance. 387d39bc50SNicolai Stange * In order to distinguish between these two cases, a real fops 397d39bc50SNicolai Stange * pointer gets its lowest bit set. 407d39bc50SNicolai Stange */ 417d39bc50SNicolai Stange #define DEBUGFS_FSDATA_IS_REAL_FOPS_BIT BIT(0) 427d39bc50SNicolai Stange 43a24c6f7bSPeter Enderborg /* Access BITS */ 44a24c6f7bSPeter Enderborg #define DEBUGFS_ALLOW_API BIT(0) 45a24c6f7bSPeter Enderborg #define DEBUGFS_ALLOW_MOUNT BIT(1) 46a24c6f7bSPeter Enderborg 47a24c6f7bSPeter Enderborg #ifdef CONFIG_DEBUG_FS_ALLOW_ALL 48a24c6f7bSPeter Enderborg #define DEFAULT_DEBUGFS_ALLOW_BITS (DEBUGFS_ALLOW_MOUNT | DEBUGFS_ALLOW_API) 49a24c6f7bSPeter Enderborg #endif 50a24c6f7bSPeter Enderborg #ifdef CONFIG_DEBUG_FS_DISALLOW_MOUNT 51a24c6f7bSPeter Enderborg #define DEFAULT_DEBUGFS_ALLOW_BITS (DEBUGFS_ALLOW_API) 52a24c6f7bSPeter Enderborg #endif 53a24c6f7bSPeter Enderborg #ifdef CONFIG_DEBUG_FS_ALLOW_NONE 54a24c6f7bSPeter Enderborg #define DEFAULT_DEBUGFS_ALLOW_BITS (0) 55a24c6f7bSPeter Enderborg #endif 56a24c6f7bSPeter Enderborg 579fd4dcecSNicolai Stange #endif /* _DEBUGFS_INTERNAL_H_ */ 58