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