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