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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (c) 2017-2018 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. printpath(tcp, tcp->u_arg[1]);
  19. tprints(", ");
  20. unsigned int flags = tcp->u_arg[2];
  21. printflags(at_statx_sync_types, flags & AT_STATX_SYNC_TYPE,
  22. NULL);
  23. flags &= ~AT_STATX_SYNC_TYPE;
  24. if (flags) {
  25. tprints("|");
  26. printflags(at_flags, flags, NULL);
  27. }
  28. tprints(", ");
  29. printflags(statx_masks, tcp->u_arg[3], "STATX_???");
  30. tprints(", ");
  31. } else {
  32. #define PRINT_FIELD_TIME(field) \
  33. do { \
  34. tprintf(", " #field "={tv_sec=%" PRId64 \
  35. ", tv_nsec=%" PRIu32 "}", \
  36. stx.field.sec, stx.field.nsec); \
  37. tprints_comment(sprinttime_nsec(stx.field.sec, \
  38. zero_extend_signed_to_ull(stx.field.nsec))); \
  39. } while (0)
  40. struct_statx stx;
  41. if (umove_or_printaddr(tcp, tcp->u_arg[4], &stx))
  42. return 0;
  43. tprints("{stx_mask=");
  44. printflags(statx_masks, stx.stx_mask, "STATX_???");
  45. if (!abbrev(tcp))
  46. PRINT_FIELD_U(", ", stx, stx_blksize);
  47. tprints(", stx_attributes=");
  48. printflags(statx_attrs, stx.stx_attributes, "STATX_ATTR_???");
  49. if (!abbrev(tcp)) {
  50. PRINT_FIELD_U(", ", stx, stx_nlink);
  51. printuid(", stx_uid=", stx.stx_uid);
  52. printuid(", stx_gid=", stx.stx_gid);
  53. }
  54. tprints(", stx_mode=");
  55. print_symbolic_mode_t(stx.stx_mode);
  56. if (!abbrev(tcp))
  57. PRINT_FIELD_U(", ", stx, stx_ino);
  58. PRINT_FIELD_U(", ", stx, stx_size);
  59. if (!abbrev(tcp)) {
  60. PRINT_FIELD_U(", ", stx, stx_blocks);
  61. tprints(", stx_attributes_mask=");
  62. printflags(statx_attrs, stx.stx_attributes_mask,
  63. "STATX_ATTR_???");
  64. PRINT_FIELD_TIME(stx_atime);
  65. PRINT_FIELD_TIME(stx_btime);
  66. PRINT_FIELD_TIME(stx_ctime);
  67. PRINT_FIELD_TIME(stx_mtime);
  68. PRINT_FIELD_U(", ", stx, stx_rdev_major);
  69. PRINT_FIELD_U(", ", stx, stx_rdev_minor);
  70. PRINT_FIELD_U(", ", stx, stx_dev_major);
  71. PRINT_FIELD_U(", ", stx, stx_dev_minor);
  72. } else {
  73. tprints(", ...");
  74. }
  75. tprints("}");
  76. }
  77. return 0;
  78. }