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.

oldstat.c 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  3. * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  4. * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
  5. * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
  6. * Copyright (c) 2005-2015 Dmitry V. Levin <ldv@altlinux.org>
  7. * Copyright (c) 2015-2018 The strace developers.
  8. * All rights reserved.
  9. *
  10. * SPDX-License-Identifier: LGPL-2.1-or-later
  11. */
  12. #include "defs.h"
  13. #include "asm_stat.h"
  14. #include "stat.h"
  15. #ifdef HAVE_STRUCT___OLD_KERNEL_STAT
  16. static void
  17. print_old_kernel_stat(struct tcb *const tcp, const kernel_ulong_t addr)
  18. {
  19. struct __old_kernel_stat buf;
  20. if (umove_or_printaddr(tcp, addr, &buf))
  21. return;
  22. struct strace_stat st = {
  23. .dev = zero_extend_signed_to_ull(buf.st_dev),
  24. .ino = zero_extend_signed_to_ull(buf.st_ino),
  25. .rdev = zero_extend_signed_to_ull(buf.st_rdev),
  26. .size = zero_extend_signed_to_ull(buf.st_size),
  27. .mode = zero_extend_signed_to_ull(buf.st_mode),
  28. .nlink = zero_extend_signed_to_ull(buf.st_nlink),
  29. .uid = zero_extend_signed_to_ull(buf.st_uid),
  30. .gid = zero_extend_signed_to_ull(buf.st_gid),
  31. .atime = sign_extend_unsigned_to_ll(buf.st_atime),
  32. .ctime = sign_extend_unsigned_to_ll(buf.st_ctime),
  33. .mtime = sign_extend_unsigned_to_ll(buf.st_mtime)
  34. };
  35. print_struct_stat(tcp, &st);
  36. }
  37. SYS_FUNC(oldstat)
  38. {
  39. if (entering(tcp)) {
  40. printpath(tcp, tcp->u_arg[0]);
  41. tprints(", ");
  42. } else {
  43. print_old_kernel_stat(tcp, tcp->u_arg[1]);
  44. }
  45. return 0;
  46. }
  47. SYS_FUNC(oldfstat)
  48. {
  49. if (entering(tcp)) {
  50. printfd(tcp, tcp->u_arg[0]);
  51. tprints(", ");
  52. } else {
  53. print_old_kernel_stat(tcp, tcp->u_arg[1]);
  54. }
  55. return 0;
  56. }
  57. #endif /* HAVE_STRUCT___OLD_KERNEL_STAT */