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.

personality.c 959B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
  3. * Copyright (c) 2014-2018 The strace developers.
  4. * All rights reserved.
  5. *
  6. * SPDX-License-Identifier: LGPL-2.1-or-later
  7. */
  8. #include "defs.h"
  9. #include "xlat/personality_flags.h"
  10. #include "xlat/personality_types.h"
  11. SYS_FUNC(personality)
  12. {
  13. unsigned int pers;
  14. if (entering(tcp)) {
  15. pers = tcp->u_arg[0];
  16. if (0xffffffff == pers) {
  17. tprints("0xffffffff");
  18. } else {
  19. printxval(personality_types, pers & PER_MASK, "PER_???");
  20. pers &= ~PER_MASK;
  21. if (pers) {
  22. tprints("|");
  23. printflags(personality_flags, pers, NULL);
  24. }
  25. }
  26. return 0;
  27. }
  28. if (syserror(tcp))
  29. return 0;
  30. pers = tcp->u_rval;
  31. static char outstr[1024];
  32. char *p = outstr + sprintxval(outstr, sizeof(outstr), personality_types,
  33. pers & PER_MASK, "PER_???");
  34. pers &= ~PER_MASK;
  35. if (pers)
  36. strcpy(p, sprintflags("|", personality_flags, pers));
  37. tcp->auxstr = outstr;
  38. return RVAL_HEX | RVAL_STR;
  39. }