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.

nsfs.c 877B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Support for decoding of NS_* ioctl commands.
  3. *
  4. * Copyright (c) 2017 Nikolay Marchuk <marchuk.nikolay.a@gmail.com>
  5. * Copyright (c) 2017-2018 The strace developers.
  6. * All rights reserved.
  7. *
  8. * SPDX-License-Identifier: LGPL-2.1-or-later
  9. */
  10. #include "defs.h"
  11. #include "nsfs.h"
  12. int
  13. nsfs_ioctl(struct tcb *tcp, unsigned int code, kernel_ulong_t arg)
  14. {
  15. unsigned int uid;
  16. switch (code) {
  17. case NS_GET_USERNS:
  18. case NS_GET_PARENT:
  19. return RVAL_IOCTL_DECODED | RVAL_FD;
  20. case NS_GET_NSTYPE:
  21. if (entering(tcp))
  22. return 0;
  23. if (!syserror(tcp))
  24. tcp->auxstr = xlookup(setns_types, tcp->u_rval);
  25. return RVAL_IOCTL_DECODED | RVAL_STR;
  26. case NS_GET_OWNER_UID:
  27. if (entering(tcp))
  28. return 0;
  29. tprints(", ");
  30. if (!umove_or_printaddr(tcp, arg, &uid)) {
  31. printuid("[", uid);
  32. tprints("]");
  33. }
  34. return RVAL_IOCTL_DECODED;
  35. default:
  36. return RVAL_DECODED;
  37. }
  38. }