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.

stat.c 1008B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2005-2015 Dmitry V. Levin <ldv@altlinux.org>
  3. * Copyright (c) 2015-2019 The strace developers.
  4. * All rights reserved.
  5. *
  6. * SPDX-License-Identifier: LGPL-2.1-or-later
  7. */
  8. #include "defs.h"
  9. #include "stat.h"
  10. static void
  11. decode_struct_stat(struct tcb *const tcp, const kernel_ulong_t addr)
  12. {
  13. struct strace_stat st;
  14. if (fetch_struct_stat(tcp, addr, &st))
  15. print_struct_stat(tcp, &st);
  16. }
  17. SYS_FUNC(stat)
  18. {
  19. if (entering(tcp)) {
  20. printpath(tcp, tcp->u_arg[0]);
  21. tprints(", ");
  22. } else {
  23. decode_struct_stat(tcp, tcp->u_arg[1]);
  24. }
  25. return 0;
  26. }
  27. SYS_FUNC(fstat)
  28. {
  29. if (entering(tcp)) {
  30. printfd(tcp, tcp->u_arg[0]);
  31. tprints(", ");
  32. } else {
  33. decode_struct_stat(tcp, tcp->u_arg[1]);
  34. }
  35. return 0;
  36. }
  37. SYS_FUNC(newfstatat)
  38. {
  39. if (entering(tcp)) {
  40. print_dirfd(tcp, tcp->u_arg[0]);
  41. tprints(", ");
  42. printpath(tcp, tcp->u_arg[1]);
  43. tprints(", ");
  44. } else {
  45. decode_struct_stat(tcp, tcp->u_arg[2]);
  46. tprints(", ");
  47. printflags(at_flags, tcp->u_arg[3], "AT_???");
  48. }
  49. return 0;
  50. }