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_statfs.c 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright (c) 2014-2018 Dmitry V. Levin <ldv@altlinux.org>
  3. * All rights reserved.
  4. *
  5. * SPDX-License-Identifier: LGPL-2.1-or-later
  6. */
  7. #include "defs.h"
  8. #include "statfs.h"
  9. #include "xlat/fsmagic.h"
  10. #include "xlat/statfs_flags.h"
  11. static void
  12. print_statfs_type(const char *const prefix, const unsigned long long magic)
  13. {
  14. tprints(prefix);
  15. printxval_search(fsmagic, magic, NULL);
  16. }
  17. #if defined HAVE_STRUCT_STATFS_F_FLAGS || defined HAVE_STRUCT_STATFS64_F_FLAGS
  18. static void
  19. print_statfs_flags(const char *const prefix, const unsigned long long flags)
  20. {
  21. if (flags & ST_VALID) {
  22. tprints(prefix);
  23. printflags64(statfs_flags, flags, "ST_???");
  24. }
  25. }
  26. #endif /* HAVE_STRUCT_STATFS_F_FLAGS || HAVE_STRUCT_STATFS64_F_FLAGS */
  27. static void
  28. print_statfs_number(const char *const prefix, const unsigned long long number)
  29. {
  30. tprints(prefix);
  31. tprintf("%llu", number);
  32. }
  33. void
  34. print_struct_statfs(struct tcb *const tcp, const kernel_ulong_t addr)
  35. {
  36. #ifdef HAVE_STRUCT_STATFS
  37. struct strace_statfs b;
  38. if (!fetch_struct_statfs(tcp, addr, &b))
  39. return;
  40. print_statfs_type("{f_type=", b.f_type);
  41. print_statfs_number(", f_bsize=", b.f_bsize);
  42. print_statfs_number(", f_blocks=", b.f_blocks);
  43. print_statfs_number(", f_bfree=", b.f_bfree);
  44. print_statfs_number(", f_bavail=", b.f_bavail);
  45. print_statfs_number(", f_files=", b.f_files);
  46. print_statfs_number(", f_ffree=", b.f_ffree);
  47. # if defined HAVE_STRUCT_STATFS_F_FSID_VAL \
  48. || defined HAVE_STRUCT_STATFS_F_FSID___VAL
  49. print_statfs_number(", f_fsid={val=[", b.f_fsid[0]);
  50. print_statfs_number(", ", b.f_fsid[1]);
  51. tprints("]}");
  52. # endif
  53. print_statfs_number(", f_namelen=", b.f_namelen);
  54. # ifdef HAVE_STRUCT_STATFS_F_FRSIZE
  55. print_statfs_number(", f_frsize=", b.f_frsize);
  56. # endif
  57. # ifdef HAVE_STRUCT_STATFS_F_FLAGS
  58. print_statfs_flags(", f_flags=", b.f_flags);
  59. # endif
  60. tprints("}");
  61. #else
  62. printaddr(addr);
  63. #endif
  64. }
  65. void
  66. print_struct_statfs64(struct tcb *const tcp, const kernel_ulong_t addr,
  67. const kernel_ulong_t size)
  68. {
  69. #ifdef HAVE_STRUCT_STATFS64
  70. struct strace_statfs b;
  71. if (!fetch_struct_statfs64(tcp, addr, size, &b))
  72. return;
  73. print_statfs_type("{f_type=", b.f_type);
  74. print_statfs_number(", f_bsize=", b.f_bsize);
  75. print_statfs_number(", f_blocks=", b.f_blocks);
  76. print_statfs_number(", f_bfree=", b.f_bfree);
  77. print_statfs_number(", f_bavail=", b.f_bavail);
  78. print_statfs_number(", f_files=", b.f_files);
  79. print_statfs_number(", f_ffree=", b.f_ffree);
  80. # if defined HAVE_STRUCT_STATFS64_F_FSID_VAL \
  81. || defined HAVE_STRUCT_STATFS64_F_FSID___VAL
  82. print_statfs_number(", f_fsid={val=[", b.f_fsid[0]);
  83. print_statfs_number(", ", b.f_fsid[1]);
  84. tprints("]}");
  85. # endif
  86. print_statfs_number(", f_namelen=", b.f_namelen);
  87. # ifdef HAVE_STRUCT_STATFS64_F_FRSIZE
  88. print_statfs_number(", f_frsize=", b.f_frsize);
  89. # endif
  90. # ifdef HAVE_STRUCT_STATFS64_F_FLAGS
  91. print_statfs_flags(", f_flags=", b.f_flags);
  92. # endif
  93. tprints("}");
  94. #else
  95. printaddr(addr);
  96. #endif
  97. }