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.

memfd_create.c 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
  3. * Copyright (c) 2015-2018 The strace developers.
  4. * All rights reserved.
  5. *
  6. * SPDX-License-Identifier: LGPL-2.1-or-later
  7. */
  8. #include "defs.h"
  9. #ifdef HAVE_LINUX_MEMFD_H
  10. # include <linux/memfd.h>
  11. #endif
  12. #include "xlat/memfd_create_flags.h"
  13. #ifndef MFD_HUGE_SHIFT
  14. # define MFD_HUGE_SHIFT 26
  15. #endif
  16. #ifndef MFD_HUGE_MASK
  17. # define MFD_HUGE_MASK 0x3f
  18. #endif
  19. SYS_FUNC(memfd_create)
  20. {
  21. printpathn(tcp, tcp->u_arg[0], 255 - (sizeof("memfd:") - 1));
  22. tprints(", ");
  23. unsigned int flags = tcp->u_arg[1];
  24. if (!flags || xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV)
  25. tprintf("%#x", flags);
  26. if (!flags || xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW)
  27. return RVAL_DECODED | RVAL_FD;
  28. if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE)
  29. tprints(" /* ");
  30. const unsigned int mask = MFD_HUGE_MASK << MFD_HUGE_SHIFT;
  31. const unsigned int hugetlb_value = flags & mask;
  32. flags &= ~mask;
  33. if (flags || !hugetlb_value)
  34. printflags_ex(flags, "MFD_???", XLAT_STYLE_ABBREV,
  35. memfd_create_flags, NULL);
  36. if (hugetlb_value)
  37. tprintf("%s%u<<MFD_HUGE_SHIFT",
  38. flags ? "|" : "",
  39. hugetlb_value >> MFD_HUGE_SHIFT);
  40. if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE)
  41. tprints(" */");
  42. return RVAL_DECODED | RVAL_FD;
  43. }