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.

mknod.c 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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-1996 Rick Sladkey <jrs@world.std.com>
  5. * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
  6. * Copyright (c) 2006 Ulrich Drepper <drepper@redhat.com>
  7. * Copyright (c) 2006 Bernhard Kaindl <bk@suse.de>
  8. * Copyright (c) 2006-2015 Dmitry V. Levin <ldv@altlinux.org>
  9. * Copyright (c) 2014-2018 The strace developers.
  10. * All rights reserved.
  11. *
  12. * SPDX-License-Identifier: LGPL-2.1-or-later
  13. */
  14. #include "defs.h"
  15. #include <fcntl.h>
  16. #include <sys/stat.h>
  17. static void
  18. decode_mknod(struct tcb *tcp, int offset)
  19. {
  20. unsigned short mode = tcp->u_arg[offset + 1];
  21. unsigned int dev;
  22. printpath(tcp, tcp->u_arg[offset]);
  23. tprints(", ");
  24. print_symbolic_mode_t(mode);
  25. switch (mode & S_IFMT) {
  26. case S_IFCHR:
  27. case S_IFBLK:
  28. dev = tcp->u_arg[offset + 2];
  29. tprints(", ");
  30. print_dev_t(dev);
  31. break;
  32. }
  33. }
  34. SYS_FUNC(mknod)
  35. {
  36. decode_mknod(tcp, 0);
  37. return RVAL_DECODED;
  38. }
  39. SYS_FUNC(mknodat)
  40. {
  41. print_dirfd(tcp, tcp->u_arg[0]);
  42. decode_mknod(tcp, 1);
  43. return RVAL_DECODED;
  44. }