internal.h 1.5 KB

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