Mirror of strace – the linux syscall tracer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

statx.c 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright (c) 2017-2019 The strace developers.
  3. * All rights reserved.
  4. *
  5. * SPDX-License-Identifier: LGPL-2.1-or-later
  6. */
  7. #include "defs.h"
  8. #include "print_fields.h"
  9. #include "statx.h"
  10. #include <sys/stat.h>
  11. #include "xlat/statx_masks.h"
  12. #include "xlat/statx_attrs.h"
  13. #include "xlat/at_statx_sync_types.h"
  14. SYS_FUNC(statx)
  15. {
  16. if (entering(tcp)) {
  17. print_dirfd(tcp, tcp->u_arg[0]);
  18. tprints(", ");
  19. printpath(tcp, tcp->u_arg[1]);
  20. tprints(", ");
  21. unsigned int flags = tcp->u_arg[2];
  22. printflags(at_statx_sync_types, flags & AT_STATX_SYNC_TYPE,
  23. NULL);
  24. flags &= ~AT_STATX_SYNC_TYPE;
  25. if (flags) {
  26. tprints("|");
  27. printflags(at_flags, flags, NULL);
  28. }
  29. tprints(", ");
  30. printflags(statx_masks, tcp->u_arg[3], "STATX_???");
  31. tprints(", ");
  32. } else {
  33. #define PRINT_FIELD_TIME(field) \
  34. do { \
  35. tprintf(", " #field "={tv_sec=%" PRId64 \
  36. ", tv_nsec=%" PRIu32 "}", \
  37. stx.field.sec, stx.field.nsec); \
  38. tprints_comment(sprinttime_nsec(stx.field.sec, \
  39. zero_extend_signed_to_ull(stx.field.nsec))); \
  40. } while (0)
  41. struct_statx stx;
  42. if (umove_or_printaddr(tcp, tcp->u_arg[4], &stx))
  43. return 0;
  44. tprints("{stx_mask=");
  45. printflags(statx_masks, stx.stx_mask, "STATX_???");
  46. if (!abbrev(tcp))
  47. PRINT_FIELD_U(", ", stx, stx_blksize);
  48. tprints(", stx_attributes=");
  49. printflags(statx_attrs, stx.stx_attributes, "STATX_ATTR_???");
  50. if (!abbrev(tcp)) {
  51. PRINT_FIELD_U(", ", stx, stx_nlink);
  52. printuid(", stx_uid=", stx.stx_uid);
  53. printuid(", stx_gid=", stx.stx_gid);
  54. }
  55. tprints(", stx_mode=");
  56. print_symbolic_mode_t(stx.stx_mode);
  57. if (!abbrev(tcp))
  58. PRINT_FIELD_U(", ", stx, stx_ino);
  59. PRINT_FIELD_U(", ", stx, stx_size);
  60. if (!abbrev(tcp)) {
  61. PRINT_FIELD_U(", ", stx, stx_blocks);
  62. tprints(", stx_attributes_mask=");
  63. printflags(statx_attrs, stx.stx_attributes_mask,
  64. "STATX_ATTR_???");
  65. PRINT_FIELD_TIME(stx_atime);
  66. PRINT_FIELD_TIME(stx_btime);
  67. PRINT_FIELD_TIME(stx_ctime);
  68. PRINT_FIELD_TIME(stx_mtime);
  69. PRINT_FIELD_U(", ", stx, stx_rdev_major);
  70. PRINT_FIELD_U(", ", stx, stx_rdev_minor);
  71. PRINT_FIELD_U(", ", stx, stx_dev_major);
  72. PRINT_FIELD_U(", ", stx, stx_dev_minor);
  73. } else {
  74. tprints(", ...");
  75. }
  76. tprints("}");
  77. }
  78. return 0;
  79. }