internal.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _TRACEFS_INTERNAL_H
  3. #define _TRACEFS_INTERNAL_H
  4. enum {
  5. TRACEFS_EVENT_INODE = BIT(1),
  6. TRACEFS_GID_PERM_SET = BIT(2),
  7. TRACEFS_UID_PERM_SET = BIT(3),
  8. TRACEFS_INSTANCE_INODE = BIT(4),
  9. };
  10. struct tracefs_inode {
  11. struct inode vfs_inode;
  12. /* The below gets initialized with memset_after(ti, 0, vfs_inode) */
  13. struct list_head list;
  14. unsigned long flags;
  15. void *private;
  16. };
  17. /*
  18. * struct eventfs_attr - cache the mode and ownership of a eventfs entry
  19. * @mode: saved mode plus flags of what is saved
  20. * @uid: saved uid if changed
  21. * @gid: saved gid if changed
  22. */
  23. struct eventfs_attr {
  24. int mode;
  25. kuid_t uid;
  26. kgid_t gid;
  27. };
  28. /*
  29. * struct eventfs_inode - hold the properties of the eventfs directories.
  30. * @list: link list into the parent directory
  31. * @rcu: Union with @list for freeing
  32. * @children: link list into the child eventfs_inode
  33. * @entries: the array of entries representing the files in the directory
  34. * @name: the name of the directory to create
  35. * @entry_attrs: Saved mode and ownership of the @d_children
  36. * @data: The private data to pass to the callbacks
  37. * @attr: Saved mode and ownership of eventfs_inode itself
  38. * @is_freed: Flag set if the eventfs is on its way to be freed
  39. * Note if is_freed is set, then dentry is corrupted.
  40. * @is_events: Flag set for only the top level "events" directory
  41. * @nr_entries: The number of items in @entries
  42. * @ino: The saved inode number
  43. */
  44. struct eventfs_inode {
  45. union {
  46. struct list_head list;
  47. struct rcu_head rcu;
  48. };
  49. struct list_head children;
  50. const struct eventfs_entry *entries;
  51. const char *name;
  52. struct eventfs_attr *entry_attrs;
  53. void *data;
  54. struct eventfs_attr attr;
  55. struct kref kref;
  56. unsigned int is_freed:1;
  57. unsigned int is_events:1;
  58. unsigned int nr_entries:30;
  59. unsigned int ino;
  60. };
  61. static inline struct tracefs_inode *get_tracefs(const struct inode *inode)
  62. {
  63. return container_of(inode, struct tracefs_inode, vfs_inode);
  64. }
  65. struct dentry *tracefs_start_creating(const char *name, struct dentry *parent);
  66. struct dentry *tracefs_end_creating(struct dentry *dentry);
  67. struct dentry *tracefs_failed_creating(struct dentry *dentry);
  68. struct inode *tracefs_get_inode(struct super_block *sb);
  69. void eventfs_remount(struct tracefs_inode *ti, bool update_uid, bool update_gid);
  70. void eventfs_d_release(struct dentry *dentry);
  71. #endif /* _TRACEFS_INTERNAL_H */