80 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2#ifndef _TRACEFS_INTERNAL_H3#define _TRACEFS_INTERNAL_H4 5enum {6 TRACEFS_EVENT_INODE = BIT(1),7 TRACEFS_GID_PERM_SET = BIT(2),8 TRACEFS_UID_PERM_SET = BIT(3),9 TRACEFS_INSTANCE_INODE = BIT(4),10};11 12struct tracefs_inode {13 struct inode vfs_inode;14 /* The below gets initialized with memset_after(ti, 0, vfs_inode) */15 struct list_head list;16 unsigned long flags;17 void *private;18};19 20/*21 * struct eventfs_attr - cache the mode and ownership of a eventfs entry22 * @mode: saved mode plus flags of what is saved23 * @uid: saved uid if changed24 * @gid: saved gid if changed25 */26struct eventfs_attr {27 int mode;28 kuid_t uid;29 kgid_t gid;30};31 32/*33 * struct eventfs_inode - hold the properties of the eventfs directories.34 * @list: link list into the parent directory35 * @rcu: Union with @list for freeing36 * @children: link list into the child eventfs_inode37 * @entries: the array of entries representing the files in the directory38 * @name: the name of the directory to create39 * @entry_attrs: Saved mode and ownership of the @d_children40 * @data: The private data to pass to the callbacks41 * @attr: Saved mode and ownership of eventfs_inode itself42 * @is_freed: Flag set if the eventfs is on its way to be freed43 * Note if is_freed is set, then dentry is corrupted.44 * @is_events: Flag set for only the top level "events" directory45 * @nr_entries: The number of items in @entries46 * @ino: The saved inode number47 */48struct eventfs_inode {49 union {50 struct list_head list;51 struct rcu_head rcu;52 };53 struct list_head children;54 const struct eventfs_entry *entries;55 const char *name;56 struct eventfs_attr *entry_attrs;57 void *data;58 struct eventfs_attr attr;59 struct kref kref;60 unsigned int is_freed:1;61 unsigned int is_events:1;62 unsigned int nr_entries:30;63 unsigned int ino;64};65 66static inline struct tracefs_inode *get_tracefs(const struct inode *inode)67{68 return container_of(inode, struct tracefs_inode, vfs_inode);69}70 71struct dentry *tracefs_start_creating(const char *name, struct dentry *parent);72struct dentry *tracefs_end_creating(struct dentry *dentry);73struct dentry *tracefs_failed_creating(struct dentry *dentry);74struct inode *tracefs_get_inode(struct super_block *sb);75 76void eventfs_remount(struct tracefs_inode *ti, bool update_uid, bool update_gid);77void eventfs_d_release(struct dentry *dentry);78 79#endif /* _TRACEFS_INTERNAL_H */80