]> git.pld-linux.org Git - packages/strace.git/blame - strace-fd.patch
- version up to 4.5.19
[packages/strace.git] / strace-fd.patch
CommitLineData
e4f88ecf
AM
1commit ba2cfac31ccfd0aa4c93524088d1be4fca3e68f6
2Author: ldv <ldv>
3Date: Mon Nov 10 22:53:02 2008 +0000
4
5 2008-10-23 Dmitry V. Levin <ldv@altlinux.org>
6
7 Implement parsers for new linux syscalls.
8 * desc.c (do_dup2, [LINUX] sys_dup3): New functions.
9 (sys_dup2): Use do_dup2.
10 [LINUX] (sys_epoll_create1): New function.
11 [LINUX] (do_eventfd, sys_eventfd2): New functions.
12 [LINUX] (sys_eventfd): Use do_eventfd.
13 * net.c (do_pipe, [LINUX] sys_pipe2): New functions.
14 (sys_pipe): Use do_pipe.
15 * signal.c [LINUX] (do_signalfd, sys_signalfd4): New functions.
16 [LINUX] (sys_signalfd): Use do_signalfd.
17 * linux/syscall.h: Declare new sys_* functions.
18 * linux/syscallent.h: Hook up signalfd4, eventfd2, epoll_create1,
19 dup3, pipe2, inotify_init1.
20 * linux/x86_64/syscallent.h: Hook up paccept, signalfd4, eventfd2,
21 epoll_create1, dup3, pipe2, inotify_init1.
22
23diff --git a/desc.c b/desc.c
24index 8b8a894..222cb2b 100644
25--- a/desc.c
26+++ b/desc.c
27@@ -242,6 +242,8 @@ int getlk;
28 }
29 #endif
30
31+extern const struct xlat open_mode_flags[];
32+
33 /*
34 * low bits of the open(2) flags define access mode,
35 * other bits are real flags.
36@@ -250,7 +252,6 @@ static const char *
37 sprint_open_modes(mode_t flags)
38 {
39 extern const struct xlat open_access_modes[];
40- extern const struct xlat open_mode_flags[];
41 static char outstr[1024];
42 const char *str = xlookup(open_access_modes, flags & 3);
43 const char *sep = "";
44@@ -396,16 +397,33 @@ struct tcb *tcp;
45 return 0;
46 }
47
48-int
49-sys_dup2(tcp)
50-struct tcb *tcp;
51+static int
52+do_dup2(struct tcb *tcp, int flags_arg)
53 {
54 if (entering(tcp)) {
55 tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
56+ if (flags_arg >= 0) {
57+ tprintf(", ");
58+ printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
59+ }
60 }
61 return 0;
62 }
63
64+int
65+sys_dup2(struct tcb *tcp)
66+{
67+ return do_dup2(tcp, -1);
68+}
69+
70+#ifdef LINUX
71+int
72+sys_dup3(struct tcb *tcp)
73+{
74+ return do_dup2(tcp, 2);
75+}
76+#endif
77+
78 #if defined(ALPHA) || defined(FREEBSD) || defined(SUNOS4)
79 int
80 sys_getdtablesize(tcp)
81@@ -605,14 +623,21 @@ static struct xlat epollevents[] = {
82 };
83
84 int
85-sys_epoll_create(tcp)
86-struct tcb *tcp;
87+sys_epoll_create(struct tcb *tcp)
88 {
89 if (entering(tcp))
90 tprintf("%ld", tcp->u_arg[0]);
91 return 0;
92 }
93
94+int
95+sys_epoll_create1(struct tcb *tcp)
96+{
97+ if (entering(tcp))
98+ printflags(open_mode_flags, tcp->u_arg[0], "O_???");
99+ return 0;
100+}
101+
102 #ifdef HAVE_SYS_EPOLL_H
103 static void
104 print_epoll_event(ev)
105@@ -889,12 +914,28 @@ sys_pselect6(struct tcb *tcp)
106 return rc;
107 }
108
109-int
110-sys_eventfd(tcp)
111-struct tcb *tcp;
112+static int
113+do_eventfd(struct tcb *tcp, int flags_arg)
114 {
115- if (entering(tcp))
116+ if (entering(tcp)) {
117 tprintf("%lu", tcp->u_arg[0]);
118+ if (flags_arg >= 0) {
119+ tprintf(", ");
120+ printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
121+ }
122+ }
123 return 0;
124 }
125+
126+int
127+sys_eventfd(struct tcb *tcp)
128+{
129+ return do_eventfd(tcp, -1);
130+}
131+
132+int
133+sys_eventfd2(struct tcb *tcp)
134+{
135+ return do_eventfd(tcp, 1);
136+}
137 #endif
138diff --git a/linux/syscall.h b/linux/syscall.h
139index 96d6d2f..f8e4f20 100644
140--- a/linux/syscall.h
141+++ b/linux/syscall.h
142@@ -105,6 +105,7 @@ int sys_io_setup(), sys_io_submit(), sys_io_cancel(), sys_io_getevents(), sys_io
143 int sys_utimensat(), sys_epoll_pwait(), sys_signalfd(), sys_timerfd(), sys_eventfd();
144 int sys_getcpu();
145 int sys_fallocate(), sys_timerfd_create(), sys_timerfd_settime(), sys_timerfd_gettime();
146+int sys_signalfd4(), sys_eventfd2(), sys_epoll_create1(), sys_dup3(), sys_pipe2();
147
148 /* sys_socketcall subcalls */
149
150diff --git a/linux/syscallent.h b/linux/syscallent.h
151index 59c9a72..53bd9b3 100644
152--- a/linux/syscallent.h
153+++ b/linux/syscallent.h
154@@ -357,12 +357,12 @@
155 { 6, TF, sys_fallocate, "fallocate" }, /* 324 */
156 { 4, TD, sys_timerfd_settime, "timerfd_settime"}, /* 325 */
157 { 2, TD, sys_timerfd_gettime, "timerfd_gettime"}, /* 326 */
158- { 5, 0, printargs, "SYS_327" }, /* 327 */
159- { 5, 0, printargs, "SYS_328" }, /* 328 */
160- { 5, 0, printargs, "SYS_329" }, /* 329 */
161- { 5, 0, printargs, "SYS_330" }, /* 330 */
162- { 5, 0, printargs, "SYS_331" }, /* 331 */
163- { 5, 0, printargs, "SYS_332" }, /* 332 */
164+ { 4, TD|TS, sys_signalfd4, "signalfd4" }, /* 327 */
165+ { 2, TD, sys_eventfd2, "eventfd2" }, /* 328 */
166+ { 1, 0, sys_epoll_create1, "epoll_create1" }, /* 329 */
167+ { 3, TD, sys_dup3, "dup3" }, /* 330 */
168+ { 2, TD, sys_pipe2, "pipe2" }, /* 331 */
169+ { 1, TD, printargs, "inotify_init1" }, /* 332 */
170 { 5, 0, printargs, "SYS_333" }, /* 333 */
171 { 5, 0, printargs, "SYS_334" }, /* 334 */
172 { 5, 0, printargs, "SYS_335" }, /* 335 */
173diff --git a/linux/x86_64/syscallent.h b/linux/x86_64/syscallent.h
174index 0b2150b..4b4eaf0 100644
175--- a/linux/x86_64/syscallent.h
176+++ b/linux/x86_64/syscallent.h
177@@ -286,3 +286,10 @@
178 { 6, TF, sys_fallocate, "fallocate" }, /* 285 */
179 { 4, TD, sys_timerfd_settime, "timerfd_settime"}, /* 286 */
180 { 2, TD, sys_timerfd_gettime, "timerfd_gettime"}, /* 287 */
181+ { 6, TN, printargs, "paccept" }, /* 288 */
182+ { 4, TD|TS, sys_signalfd4, "signalfd4" }, /* 289 */
183+ { 2, TD, sys_eventfd2, "eventfd2" }, /* 290 */
184+ { 1, 0, sys_epoll_create1, "epoll_create1" }, /* 291 */
185+ { 3, TD, sys_dup3, "dup3" }, /* 292 */
186+ { 2, TD, sys_pipe2, "pipe2" }, /* 293 */
187+ { 1, TD, printargs, "inotify_init1" }, /* 294 */
188diff --git a/net.c b/net.c
189index f5426b2..d5426bd 100644
190--- a/net.c
191+++ b/net.c
192@@ -1463,31 +1463,50 @@
193 return sys_accept(tcp);
194 }
195
196-int
197-sys_pipe(tcp)
198-struct tcb *tcp;
199-{
200-
201-#if defined(LINUX) && !defined(SPARC) && !defined(SPARC64) && !defined(SH) && !defined(IA64)
202- int fds[2];
203+extern const struct xlat open_mode_flags[];
204
205+ static int
206+do_pipe(struct tcb *tcp, int flags_arg)
207+{
208 if (exiting(tcp)) {
209 if (syserror(tcp)) {
210 tprintf("%#lx", tcp->u_arg[0]);
211- return 0;
212- }
213- if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0)
214- tprintf("[...]");
215- else
216- tprintf("[%u, %u]", fds[0], fds[1]);
217- }
218+ } else {
219+#if defined(LINUX) && !defined(SPARC) && !defined(SPARC64) && !defined(SH) && !defined(IA64)
220+ int fds[2];
221+
222+ if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0)
223+ tprintf("[...]");
224+ else
225+ tprintf("[%u, %u]", fds[0], fds[1]);
226 #elif defined(SPARC) || defined(SPARC64) || defined(SH) || defined(SVR4) || defined(FREEBSD) || defined(IA64)
227- if (exiting(tcp))
228- tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
229+ tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
230+#else
231+ tprintf("%#lx", tcp->u_arg[0]);
232 #endif
233+ }
234+ if (flags_arg >= 0) {
235+ tprintf(", ");
236+ printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
237+ }
238+ }
239 return 0;
240 }
241
242+ int
243+sys_pipe(struct tcb *tcp)
244+{
245+ return do_pipe(tcp, -1);
246+}
247+
248+#ifdef LINUX
249+ int
250+sys_pipe2(struct tcb *tcp)
251+{
252+ return do_pipe(tcp, 1);
253+}
254+#endif
255+
256 int
257 sys_socketpair(tcp)
258 struct tcb *tcp;
259diff --git a/signal.c b/signal.c
260index 12bbac3..0366bb5 100644
261--- a/signal.c
262+++ b/signal.c
263@@ -2011,15 +2011,32 @@ struct tcb *tcp;
264 return 0;
265 }
266
267-int
268-sys_signalfd(tcp)
269-struct tcb *tcp;
270+extern const struct xlat open_mode_flags[];
271+
272+static int
273+do_signalfd(struct tcb *tcp, int flags_arg)
274 {
275 if (entering(tcp)) {
276 tprintf("%ld, ", tcp->u_arg[0]);
277 print_sigset(tcp, tcp->u_arg[1], 1);
278 tprintf("%lu", tcp->u_arg[2]);
279+ if (flags_arg >= 0) {
280+ tprintf(", ");
281+ printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
282+ }
283 }
284 return 0;
285 }
286+
287+int
288+sys_signalfd(struct tcb *tcp)
289+{
290+ return do_signalfd(tcp, -1);
291+}
292+
293+int
294+sys_signalfd4(struct tcb *tcp)
295+{
296+ return do_signalfd(tcp, 3);
297+}
298 #endif /* LINUX */
1f142459
AM
299commit feeceab4c8bfde6542d78048854c3bdc7ea9c99b
300Author: ldv <ldv>
301Date: Mon Nov 10 17:21:23 2008 +0000
302
303 2008-10-22 Dmitry V. Levin <ldv@altlinux.org>
304
305 Handle socket type flags introduced in linux 2.6.27.
306 * net.c (socktypes): Add SOCK_DCCP.
307 (sock_type_flags): New xlat structure.
308 (tprint_sock_type): New function.
309 (sys_socket, sys_socketpair): Use it to parse socket type and
310 socket type flags.
311
312diff --git a/net.c b/net.c
313index c302b1f..f5426b2 100644
314--- a/net.c
315+++ b/net.c
316@@ -27,7 +27,7 @@
317 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
318 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
319 *
320- * $Id$
321+ * $Id$
322 */
323
324 #include "defs.h"
325@@ -320,17 +320,32 @@ static const struct xlat socktypes[] = {
326 #ifdef SOCK_RAW
327 { SOCK_RAW, "SOCK_RAW" },
328 #endif
329+#ifdef SOCK_RDM
330+ { SOCK_RDM, "SOCK_RDM" },
331+#endif
332 #ifdef SOCK_SEQPACKET
333 { SOCK_SEQPACKET,"SOCK_SEQPACKET"},
334 #endif
335-#ifdef SOCK_RDM
336- { SOCK_RDM, "SOCK_RDM" },
337+#ifdef SOCK_DCCP
338+ { SOCK_DCCP, "SOCK_DCCP" },
339 #endif
340 #ifdef SOCK_PACKET
341 { SOCK_PACKET, "SOCK_PACKET" },
342 #endif
343 { 0, NULL },
344 };
345+const struct xlat sock_type_flags[] = {
346+#ifdef SOCK_CLOEXEC
347+ { SOCK_CLOEXEC, "SOCK_CLOEXEC" },
348+#endif
349+#ifdef SOCK_NONBLOCK
350+ { SOCK_NONBLOCK,"SOCK_NONBLOCK" },
351+#endif
352+ { 0, NULL },
353+};
354+#ifndef SOCK_TYPE_MASK
355+# define SOCK_TYPE_MASK 0xf
356+#endif
357 static const struct xlat socketlayers[] = {
358 #if defined(SOL_IP)
359 { SOL_IP, "SOL_IP" },
360@@ -1182,14 +1197,33 @@ long addr;
361
362 #endif /* HAVE_SENDMSG */
363
364+/*
365+ * low bits of the socket type define real socket type,
366+ * other bits are socket type flags.
367+ */
368+static void
369+tprint_sock_type(struct tcb *tcp, int flags)
370+{
371+ const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK);
372+
373+ if (str)
374+ {
375+ tprintf("%s", str);
376+ flags &= ~SOCK_TYPE_MASK;
377+ if (!flags)
378+ return;
379+ tprintf("|");
380+ }
381+ printflags(sock_type_flags, flags, "SOCK_???");
382+}
383+
384 int
385-sys_socket(tcp)
386-struct tcb *tcp;
387+sys_socket(struct tcb *tcp)
388 {
389 if (entering(tcp)) {
390 printxval(domains, tcp->u_arg[0], "PF_???");
391 tprintf(", ");
392- printxval(socktypes, tcp->u_arg[1], "SOCK_???");
393+ tprint_sock_type(tcp, tcp->u_arg[1]);
394 tprintf(", ");
395 switch (tcp->u_arg[0]) {
396 case PF_INET:
397@@ -1489,8 +1523,7 @@ struct tcb *tcp;
398 }
399
400 int
401-sys_socketpair(tcp)
402-struct tcb *tcp;
403+sys_socketpair(struct tcb *tcp)
404 {
405 #ifdef LINUX
406 int fds[2];
407@@ -1499,7 +1532,7 @@ struct tcb *tcp;
408 if (entering(tcp)) {
409 printxval(domains, tcp->u_arg[0], "PF_???");
410 tprintf(", ");
411- printxval(socktypes, tcp->u_arg[1], "SOCK_???");
412+ tprint_sock_type(tcp, tcp->u_arg[1]);
413 tprintf(", ");
414 switch (tcp->u_arg[0]) {
415 case PF_INET:
This page took 0.176605 seconds and 4 git commands to generate.