1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _TRACEFS_INTERNAL_H 3 #define _TRACEFS_INTERNAL_H 4 5 enum { 6 TRACEFS_EVENT_INODE = BIT(1), 7 TRACEFS_EVENT_TOP_INODE = BIT(2), 8 TRACEFS_GID_PERM_SET = BIT(3), 9 TRACEFS_UID_PERM_SET = BIT(4), 10 TRACEFS_INSTANCE_INODE = BIT(5), 11 }; 12 13 struct tracefs_inode { 14 unsigned long flags; 15 void *private; 16 struct inode vfs_inode; 17 }; 18 19 /* 20 * struct eventfs_attr - cache the mode and ownership of a eventfs entry 21 * @mode: saved mode plus flags of what is saved 22 * @uid: saved uid if changed 23 * @gid: saved gid if changed 24 */ 25 struct eventfs_attr { 26 int mode; 27 kuid_t uid; 28 kgid_t gid; 29 }; 30 31 /* 32 * struct eventfs_inode - hold the properties of the eventfs directories. 33 * @list: link list into the parent directory 34 * @entries: the array of entries representing the files in the directory 35 * @name: the name of the directory to create 36 * @children: link list into the child eventfs_inode 37 * @dentry: the dentry of the directory 38 * @d_parent: pointer to the parent's dentry 39 * @d_children: The array of dentries to represent the files when created 40 * @entry_attrs: Saved mode and ownership of the @d_children 41 * @attr: Saved mode and ownership of eventfs_inode itself 42 * @data: The private data to pass to the callbacks 43 * @is_freed: Flag set if the eventfs is on its way to be freed 44 * Note if is_freed is set, then dentry is corrupted. 45 * @nr_entries: The number of items in @entries 46 */ 47 struct eventfs_inode { 48 struct list_head list; 49 const struct eventfs_entry *entries; 50 const char *name; 51 struct list_head children; 52 struct dentry *dentry; /* Check is_freed to access */ 53 struct dentry *d_parent; 54 struct dentry **d_children; 55 struct eventfs_attr *entry_attrs; 56 struct eventfs_attr attr; 57 void *data; 58 unsigned int is_freed:1; 59 unsigned int is_events:1; 60 unsigned int nr_entries:30; 61 unsigned int ino; 62 /* 63 * Union - used for deletion 64 * @llist: for calling dput() if needed after RCU 65 * @rcu: eventfs_inode to delete in RCU 66 */ 67 union { 68 struct llist_node llist; 69 struct rcu_head rcu; 70 }; 71 }; 72 73 static inline struct tracefs_inode *get_tracefs(const struct inode *inode) 74 { 75 return container_of(inode, struct tracefs_inode, vfs_inode); 76 } 77 78 struct dentry *tracefs_start_creating(const char *name, struct dentry *parent); 79 struct dentry *tracefs_end_creating(struct dentry *dentry); 80 struct dentry *tracefs_failed_creating(struct dentry *dentry); 81 struct inode *tracefs_get_inode(struct super_block *sb); 82 struct dentry *eventfs_start_creating(const char *name, struct dentry *parent); 83 struct dentry *eventfs_failed_creating(struct dentry *dentry); 84 struct dentry *eventfs_end_creating(struct dentry *dentry); 85 void eventfs_update_gid(struct dentry *dentry, kgid_t gid); 86 void eventfs_set_ei_status_free(struct tracefs_inode *ti, struct dentry *dentry); 87 88 #endif /* _TRACEFS_INTERNAL_H */ 89