• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM android_fs
3 
4 #if !defined(_TRACE_ANDROID_FS_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_ANDROID_FS_H
6 
7 #include <linux/fs.h>
8 #include <linux/tracepoint.h>
9 #include <trace/events/android_fs_template.h>
10 
11 DEFINE_EVENT(android_fs_data_start_template, android_fs_dataread_start,
12 	TP_PROTO(struct inode *inode, loff_t offset, int bytes,
13 		 pid_t pid, char *pathname, char *command),
14 	TP_ARGS(inode, offset, bytes, pid, pathname, command));
15 
16 DEFINE_EVENT(android_fs_data_end_template, android_fs_dataread_end,
17 	TP_PROTO(struct inode *inode, loff_t offset, int bytes),
18 	TP_ARGS(inode, offset, bytes));
19 
20 DEFINE_EVENT(android_fs_data_start_template, android_fs_datawrite_start,
21 	TP_PROTO(struct inode *inode, loff_t offset, int bytes,
22 		 pid_t pid, char *pathname, char *command),
23 	TP_ARGS(inode, offset, bytes, pid, pathname, command));
24 
25 DEFINE_EVENT(android_fs_data_end_template, android_fs_datawrite_end,
26 	TP_PROTO(struct inode *inode, loff_t offset, int bytes),
27 	     TP_ARGS(inode, offset, bytes));
28 
29 #endif /* _TRACE_ANDROID_FS_H */
30 
31 /* This part must be outside protection */
32 #include <trace/define_trace.h>
33 
34 #ifndef ANDROID_FSTRACE_GET_PATHNAME
35 #define ANDROID_FSTRACE_GET_PATHNAME
36 
37 /* Sizes an on-stack array, so careful if sizing this up ! */
38 #define MAX_TRACE_PATHBUF_LEN	256
39 
40 static inline char *
android_fstrace_get_pathname(char * buf,int buflen,struct inode * inode)41 android_fstrace_get_pathname(char *buf, int buflen, struct inode *inode)
42 {
43 	char *path;
44 	struct dentry *d;
45 
46 	/*
47 	 * d_obtain_alias() will either iput() if it locates an existing
48 	 * dentry or transfer the reference to the new dentry created.
49 	 * So get an extra reference here.
50 	 */
51 	ihold(inode);
52 	d = d_obtain_alias(inode);
53 	if (likely(!IS_ERR(d))) {
54 		path = dentry_path_raw(d, buf, buflen);
55 		if (unlikely(IS_ERR(path))) {
56 			strcpy(buf, "ERROR");
57 			path = buf;
58 		}
59 		dput(d);
60 	} else {
61 		strcpy(buf, "ERROR");
62 		path = buf;
63 	}
64 	return path;
65 }
66 #endif
67