statx.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * trace/beauty/statx.c
  3. *
  4. * Copyright (C) 2017, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
  5. *
  6. * Released under the GPL v2. (and only v2, not any later version)
  7. */
  8. #include "trace/beauty/beauty.h"
  9. #include <linux/kernel.h>
  10. #include <sys/types.h>
  11. #include <uapi/linux/fcntl.h>
  12. #include <uapi/linux/stat.h>
  13. size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_arg *arg)
  14. {
  15. int printed = 0, flags = arg->val;
  16. if (flags == 0)
  17. return scnprintf(bf, size, "SYNC_AS_STAT");
  18. #define P_FLAG(n) \
  19. if (flags & AT_##n) { \
  20. printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
  21. flags &= ~AT_##n; \
  22. }
  23. P_FLAG(SYMLINK_NOFOLLOW);
  24. P_FLAG(REMOVEDIR);
  25. P_FLAG(SYMLINK_FOLLOW);
  26. P_FLAG(NO_AUTOMOUNT);
  27. P_FLAG(EMPTY_PATH);
  28. P_FLAG(STATX_FORCE_SYNC);
  29. P_FLAG(STATX_DONT_SYNC);
  30. #undef P_FLAG
  31. if (flags)
  32. printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
  33. return printed;
  34. }
  35. size_t syscall_arg__scnprintf_statx_mask(char *bf, size_t size, struct syscall_arg *arg)
  36. {
  37. int printed = 0, flags = arg->val;
  38. #define P_FLAG(n) \
  39. if (flags & STATX_##n) { \
  40. printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
  41. flags &= ~STATX_##n; \
  42. }
  43. P_FLAG(TYPE);
  44. P_FLAG(MODE);
  45. P_FLAG(NLINK);
  46. P_FLAG(UID);
  47. P_FLAG(GID);
  48. P_FLAG(ATIME);
  49. P_FLAG(MTIME);
  50. P_FLAG(CTIME);
  51. P_FLAG(INO);
  52. P_FLAG(SIZE);
  53. P_FLAG(BLOCKS);
  54. P_FLAG(BTIME);
  55. #undef P_FLAG
  56. if (flags)
  57. printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
  58. return printed;
  59. }