2 * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
3 * Copyright (c) 2015-2017 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]);
32 printpath(tcp, tcp->u_arg[1]);
36 if (umove_or_printaddr(tcp, addr, &h)) {
40 printaddr(tcp->u_arg[3]);
44 printflags(name_to_handle_at_flags, tcp->u_arg[4],
49 tprintf("{handle_bytes=%u", h.handle_bytes);
51 set_tcb_priv_ulong(tcp, h.handle_bytes);
55 unsigned int i = get_tcb_priv_ulong(tcp);
57 if ((!syserror(tcp) || EOVERFLOW == tcp->u_error)
58 && !umove(tcp, addr, &h)) {
59 unsigned char f_handle[MAX_HANDLE_SZ];
61 if (i != h.handle_bytes)
62 tprintf(" => %u", h.handle_bytes);
64 tprintf(", handle_type=%d", h.handle_type);
65 if (h.handle_bytes > MAX_HANDLE_SZ)
66 h.handle_bytes = MAX_HANDLE_SZ;
67 if (!umoven(tcp, addr + sizeof(h), h.handle_bytes,
69 tprints(", f_handle=0x");
70 for (i = 0; i < h.handle_bytes; ++i)
71 tprintf("%02x", f_handle[i]);
78 printnum_int(tcp, tcp->u_arg[3], "%d");
82 printflags(name_to_handle_at_flags, tcp->u_arg[4], "AT_???");
87 SYS_FUNC(open_by_handle_at)
90 const kernel_ulong_t addr = tcp->u_arg[1];
93 printfd(tcp, tcp->u_arg[0]);
97 if (!umove_or_printaddr(tcp, addr, &h)) {
98 unsigned char f_handle[MAX_HANDLE_SZ];
100 tprintf("{handle_bytes=%u, handle_type=%d",
101 h.handle_bytes, h.handle_type);
102 if (h.handle_bytes > MAX_HANDLE_SZ)
103 h.handle_bytes = MAX_HANDLE_SZ;
104 if (!umoven(tcp, addr + sizeof(h), h.handle_bytes, &f_handle)) {
107 tprints(", f_handle=0x");
108 for (i = 0; i < h.handle_bytes; ++i)
109 tprintf("%02x", f_handle[i]);
116 tprint_open_modes(tcp->u_arg[2]);