2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include "xlat/f_owner_types.h"
35 #include "xlat/f_seals.h"
36 #include "xlat/fcntlcmds.h"
37 #include "xlat/fcntl64cmds.h"
38 #include "xlat/fdflags.h"
39 #include "xlat/lockfcmds.h"
40 #include "xlat/notifyflags.h"
43 print_struct_flock64(const struct_kernel_flock64 *fl, const int getlk)
46 printxval(lockfcmds, (unsigned short) fl->l_type, "F_???");
47 tprints(", l_whence=");
48 printxval(whence_codes, (unsigned short) fl->l_whence, "SEEK_???");
49 tprintf(", l_start=%lld, l_len=%lld",
50 (long long) fl->l_start, (long long) fl->l_len);
52 tprintf(", l_pid=%lu", (unsigned long) fl->l_pid);
57 printflock64(struct tcb *tcp, const long addr, const int getlk)
59 struct_kernel_flock64 fl;
61 if (fetch_struct_flock64(tcp, addr, &fl))
62 print_struct_flock64(&fl, getlk);
66 printflock(struct tcb *tcp, const long addr, const int getlk)
68 struct_kernel_flock64 fl;
70 if (fetch_struct_flock(tcp, addr, &fl))
71 print_struct_flock64(&fl, getlk);
75 print_f_owner_ex(struct tcb *tcp, const long addr)
77 struct { int type, pid; } owner;
79 if (umove_or_printaddr(tcp, addr, &owner))
83 printxval(f_owner_types, owner.type, "F_OWNER_???");
84 tprintf(", pid=%d}", owner.pid);
88 print_fcntl(struct tcb *tcp)
90 const unsigned int cmd = tcp->u_arg[1];
95 printflags(fdflags, tcp->u_arg[2], "FD_???");
99 tprintf(", %ld", tcp->u_arg[2]);
102 case F_DUPFD_CLOEXEC:
103 tprintf(", %ld", tcp->u_arg[2]);
104 return RVAL_DECODED | RVAL_FD;
107 tprint_open_modes(tcp->u_arg[2]);
112 printflock(tcp, tcp->u_arg[2], 0);
117 printflock64(tcp, tcp->u_arg[2], 0);
121 print_f_owner_ex(tcp, tcp->u_arg[2]);
125 printflags_long(notifyflags, tcp->u_arg[2], "DN_???");
129 printxval_long(lockfcmds, tcp->u_arg[2], "F_???");
133 printflags_long(f_seals, tcp->u_arg[2], "F_SEAL_???");
137 tprints(signame(tcp->u_arg[2]));
143 if (entering(tcp) || syserror(tcp) || tcp->u_rval == 0)
145 tcp->auxstr = sprintflags("flags ", fdflags,
146 (unsigned long) tcp->u_rval);
147 return RVAL_HEX | RVAL_STR;
149 if (entering(tcp) || syserror(tcp))
151 tcp->auxstr = sprint_open_modes(tcp->u_rval);
152 return RVAL_HEX | RVAL_STR;
157 printflock(tcp, tcp->u_arg[2], 1);
163 printflock64(tcp, tcp->u_arg[2], 1);
169 print_f_owner_ex(tcp, tcp->u_arg[2]);
172 if (entering(tcp) || syserror(tcp))
174 tcp->auxstr = xlookup(lockfcmds, (unsigned long) tcp->u_rval);
175 return RVAL_HEX | RVAL_STR;
177 if (entering(tcp) || syserror(tcp) || tcp->u_rval == 0)
179 tcp->auxstr = sprintflags("seals ", f_seals,
180 (unsigned long) tcp->u_rval);
181 return RVAL_HEX | RVAL_STR;
183 if (entering(tcp) || syserror(tcp) || tcp->u_rval == 0)
185 tcp->auxstr = signame(tcp->u_rval);
188 tprintf(", %#lx", tcp->u_arg[2]);
197 printfd(tcp, tcp->u_arg[0]);
199 const unsigned int cmd = tcp->u_arg[1];
200 const char *str = xlookup(fcntlcmds, cmd);
205 * fcntl syscall does not recognize these
206 * constants, but we would like to show them
207 * for better debugging experience.
209 printxval(fcntl64cmds, cmd, "F_???");
212 return print_fcntl(tcp);
217 const unsigned int cmd = tcp->u_arg[1];
219 printfd(tcp, tcp->u_arg[0]);
221 const char *str = xlookup(fcntl64cmds, cmd);
225 printxval(fcntlcmds, cmd, "F_???");
232 printflock64(tcp, tcp->u_arg[2], 0);
237 printflock64(tcp, tcp->u_arg[2], 1);
241 return print_fcntl(tcp);