summaryrefslogtreecommitdiff
path: root/fs/tracefs/internal.h
blob: 1886f1826cd83a305f427d4d548529b7ed8bd28e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _TRACEFS_INTERNAL_H
#define _TRACEFS_INTERNAL_H

enum {
	TRACEFS_EVENT_INODE		= BIT(1),
	TRACEFS_EVENT_TOP_INODE		= BIT(2),
	TRACEFS_GID_PERM_SET		= BIT(3),
	TRACEFS_UID_PERM_SET		= BIT(4),
	TRACEFS_INSTANCE_INODE		= BIT(5),
};

struct tracefs_inode {
	struct inode            vfs_inode;
	/* The below gets initialized with memset_after(ti, 0, vfs_inode) */
	unsigned long           flags;
	void                    *private;
};

/*
 * struct eventfs_attr - cache the mode and ownership of a eventfs entry
 * @mode:	saved mode plus flags of what is saved
 * @uid:	saved uid if changed
 * @gid:	saved gid if changed
 */
struct eventfs_attr {
	int				mode;
	kuid_t				uid;
	kgid_t				gid;
};

/*
 * struct eventfs_inode - hold the properties of the eventfs directories.
 * @list:	link list into the parent directory
 * @entries:	the array of entries representing the files in the directory
 * @name:	the name of the directory to create
 * @children:	link list into the child eventfs_inode
 * @events_dir: the dentry of the events directory
 * @entry_attrs: Saved mode and ownership of the @d_children
 * @attr:	Saved mode and ownership of eventfs_inode itself
 * @data:	The private data to pass to the callbacks
 * @is_freed:	Flag set if the eventfs is on its way to be freed
 *                Note if is_freed is set, then dentry is corrupted.
 * @nr_entries: The number of items in @entries
 */
struct eventfs_inode {
	struct kref			kref;
	struct list_head		list;
	const struct eventfs_entry	*entries;
	const char			*name;
	struct list_head		children;
	struct dentry			*events_dir;
	struct eventfs_attr		*entry_attrs;
	struct eventfs_attr		attr;
	void				*data;
	unsigned int			is_freed:1;
	unsigned int			is_events:1;
	unsigned int			nr_entries:30;
	unsigned int			ino;
	/*
	 * Union - used for deletion
	 * @llist:	for calling dput() if needed after RCU
	 * @rcu:	eventfs_inode to delete in RCU
	 */
	union {
		struct llist_node	llist;
		struct rcu_head		rcu;
	};
};

static inline struct tracefs_inode *get_tracefs(const struct inode *inode)
{
	return container_of(inode, struct tracefs_inode, vfs_inode);
}

struct dentry *tracefs_start_creating(const char *name, struct dentry *parent);
struct dentry *tracefs_end_creating(struct dentry *dentry);
struct dentry *tracefs_failed_creating(struct dentry *dentry);
struct inode *tracefs_get_inode(struct super_block *sb);

void eventfs_d_release(struct dentry *dentry);

#endif /* _TRACEFS_INTERNAL_H */