android_fs.h 1.8 KB

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