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