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.

print_struct_stat.c 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 1999-2003 Ulrich Drepper <drepper@redhat.com>
  3. * Copyright (c) 2004 David S. Miller <davem@nuts.davemloft.net>
  4. * Copyright (c) 2003-2005 Roland McGrath <roland@redhat.com>
  5. * Copyright (c) 2007 Jan Kratochvil <jan.kratochvil@redhat.com>
  6. * Copyright (c) 2009 Denys Vlasenko <dvlasenk@redhat.com>
  7. * Copyright (c) 2009-2010 Andreas Schwab <schwab@linux-m68k.org>
  8. * Copyright (c) 2012 H.J. Lu <hongjiu.lu@intel.com>
  9. * Copyright (c) 2005-2016 Dmitry V. Levin <ldv@altlinux.org>
  10. * Copyright (c) 2016-2018 The strace developers.
  11. * All rights reserved.
  12. *
  13. * SPDX-License-Identifier: LGPL-2.1-or-later
  14. */
  15. #include "defs.h"
  16. #include <sys/stat.h>
  17. #include "stat.h"
  18. void
  19. print_struct_stat(struct tcb *tcp, const struct strace_stat *const st)
  20. {
  21. tprints("{");
  22. if (!abbrev(tcp)) {
  23. tprints("st_dev=");
  24. print_dev_t(st->dev);
  25. tprintf(", st_ino=%llu, st_mode=", st->ino);
  26. print_symbolic_mode_t(st->mode);
  27. tprintf(", st_nlink=%llu, st_uid=%llu, st_gid=%llu",
  28. st->nlink, st->uid, st->gid);
  29. tprintf(", st_blksize=%llu", st->blksize);
  30. tprintf(", st_blocks=%llu", st->blocks);
  31. } else {
  32. tprints("st_mode=");
  33. print_symbolic_mode_t(st->mode);
  34. }
  35. switch (st->mode & S_IFMT) {
  36. case S_IFCHR: case S_IFBLK:
  37. tprints(", st_rdev=");
  38. print_dev_t(st->rdev);
  39. break;
  40. default:
  41. tprintf(", st_size=%llu", st->size);
  42. break;
  43. }
  44. if (!abbrev(tcp)) {
  45. #define PRINT_ST_TIME(field) \
  46. do { \
  47. tprintf(", st_" #field "=%lld", (long long) st->field); \
  48. tprints_comment(sprinttime_nsec(st->field, \
  49. zero_extend_signed_to_ull(st->field ## _nsec)));\
  50. if (st->has_nsec) \
  51. tprintf(", st_" #field "_nsec=%llu", \
  52. zero_extend_signed_to_ull( \
  53. st->field ## _nsec)); \
  54. } while (0)
  55. PRINT_ST_TIME(atime);
  56. PRINT_ST_TIME(mtime);
  57. PRINT_ST_TIME(ctime);
  58. } else {
  59. tprints(", ...");
  60. }
  61. tprints("}");
  62. }