2 * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
3 * Copyright (c) 2015-2019 The strace developers.
6 * SPDX-License-Identifier: LGPL-2.1-or-later
11 #include "xlat/name_to_handle_at_flags.h"
14 # define MAX_HANDLE_SZ 128
18 unsigned int handle_bytes;
22 SYS_FUNC(name_to_handle_at)
25 const kernel_ulong_t addr = tcp->u_arg[2];
29 print_dirfd(tcp, tcp->u_arg[0]);
33 printpath(tcp, tcp->u_arg[1]);
37 if (umove_or_printaddr(tcp, addr, &h)) {
41 printaddr(tcp->u_arg[3]);
45 printflags(name_to_handle_at_flags, tcp->u_arg[4],
50 tprintf("{handle_bytes=%u", h.handle_bytes);
52 set_tcb_priv_ulong(tcp, h.handle_bytes);
56 unsigned int i = get_tcb_priv_ulong(tcp);
58 if ((!syserror(tcp) || EOVERFLOW == tcp->u_error)
59 && !umove(tcp, addr, &h)) {
60 unsigned char f_handle[MAX_HANDLE_SZ];
62 if (i != h.handle_bytes)
63 tprintf(" => %u", h.handle_bytes);
65 tprintf(", handle_type=%d", h.handle_type);
66 if (h.handle_bytes > MAX_HANDLE_SZ)
67 h.handle_bytes = MAX_HANDLE_SZ;
68 if (!umoven(tcp, addr + sizeof(h), h.handle_bytes,
70 tprints(", f_handle=0x");
71 for (i = 0; i < h.handle_bytes; ++i)
72 tprintf("%02x", f_handle[i]);
79 printnum_int(tcp, tcp->u_arg[3], "%d");
83 printflags(name_to_handle_at_flags, tcp->u_arg[4], "AT_???");
88 SYS_FUNC(open_by_handle_at)
91 const kernel_ulong_t addr = tcp->u_arg[1];
94 printfd(tcp, tcp->u_arg[0]);
98 if (!umove_or_printaddr(tcp, addr, &h)) {
99 unsigned char f_handle[MAX_HANDLE_SZ];
101 tprintf("{handle_bytes=%u, handle_type=%d",
102 h.handle_bytes, h.handle_type);
103 if (h.handle_bytes > MAX_HANDLE_SZ)
104 h.handle_bytes = MAX_HANDLE_SZ;
105 if (!umoven(tcp, addr + sizeof(h), h.handle_bytes, &f_handle)) {
108 tprints(", f_handle=0x");
109 for (i = 0; i < h.handle_bytes; ++i)
110 tprintf("%02x", f_handle[i]);
117 tprint_open_modes(tcp->u_arg[2]);