xref: /linux-6.15/include/linux/tracefs.h (revision 5790b1fb)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  *  tracefs.h - a pseudo file system for activating tracing
4  *
5  * Based on debugfs by: 2004 Greg Kroah-Hartman <[email protected]>
6  *
7  *  Copyright (C) 2014 Red Hat Inc, author: Steven Rostedt <[email protected]>
8  *
9  * tracefs is the file system that is used by the tracing infrastructure.
10  */
11 
12 #ifndef _TRACEFS_H_
13 #define _TRACEFS_H_
14 
15 #include <linux/fs.h>
16 #include <linux/seq_file.h>
17 
18 #include <linux/types.h>
19 
20 struct file_operations;
21 
22 #ifdef CONFIG_TRACING
23 
24 struct eventfs_file;
25 
26 typedef int (*eventfs_callback)(const char *name, umode_t *mode, void **data,
27 				const struct file_operations **fops);
28 
29 struct eventfs_entry {
30 	const char			*name;
31 	eventfs_callback		callback;
32 };
33 
34 struct eventfs_inode;
35 
36 struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry *parent,
37 						const struct eventfs_entry *entries,
38 						int size, void *data);
39 
40 struct eventfs_inode *eventfs_create_dir(const char *name, struct eventfs_inode *parent,
41 					 const struct eventfs_entry *entries,
42 					 int size, void *data);
43 
44 void eventfs_remove_dir(struct eventfs_inode *ei);
45 
46 struct dentry *tracefs_create_file(const char *name, umode_t mode,
47 				   struct dentry *parent, void *data,
48 				   const struct file_operations *fops);
49 
50 struct dentry *tracefs_create_dir(const char *name, struct dentry *parent);
51 
52 void tracefs_remove(struct dentry *dentry);
53 
54 struct dentry *tracefs_create_instance_dir(const char *name, struct dentry *parent,
55 					   int (*mkdir)(const char *name),
56 					   int (*rmdir)(const char *name));
57 
58 bool tracefs_initialized(void);
59 
60 #endif /* CONFIG_TRACING */
61 
62 #endif
63