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