]> granicus.if.org Git - strace/commitdiff
file.c: move readlink and readlinkat parsers to a separate file
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 6 Dec 2014 03:53:16 +0000 (03:53 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 11 Dec 2014 21:39:35 +0000 (21:39 +0000)
* readlink.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c (decode_readlink, sys_readlink, sys_readlinkat): Move
to readlink.c.

Makefile.am
file.c
readlink.c [new file with mode: 0644]

index 324be2b68872ad32edebc5ecd85173efb9d82dbc..c8a6871bf00b0e6da473799faaa4024d2ce6a868 100644 (file)
@@ -53,6 +53,7 @@ strace_SOURCES =      \
        process.c       \
        ptp.c           \
        quota.c         \
+       readlink.c      \
        reboot.c        \
        renameat.c      \
        resource.c      \
diff --git a/file.c b/file.c
index 9fa2ee1cdef032f9bae0f487ce60e3374cfaeb11..2c4691bea11c1fb8942047544c22a8a681d000f5 100644 (file)
--- a/file.c
+++ b/file.c
@@ -1319,40 +1319,3 @@ sys_symlinkat(struct tcb *tcp)
        }
        return 0;
 }
-
-static int
-decode_readlink(struct tcb *tcp, int offset)
-{
-       if (entering(tcp)) {
-               printpath(tcp, tcp->u_arg[offset]);
-               tprints(", ");
-       } else {
-               if (syserror(tcp))
-                       tprintf("%#lx", tcp->u_arg[offset + 1]);
-               else
-                       /* Used to use printpathn(), but readlink
-                        * neither includes NUL in the returned count,
-                        * nor actually writes it into memory.
-                        * printpathn() would decide on printing
-                        * "..." continuation based on garbage
-                        * past return buffer's end.
-                        */
-                       printstr(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
-               tprintf(", %lu", tcp->u_arg[offset + 2]);
-       }
-       return 0;
-}
-
-int
-sys_readlink(struct tcb *tcp)
-{
-       return decode_readlink(tcp, 0);
-}
-
-int
-sys_readlinkat(struct tcb *tcp)
-{
-       if (entering(tcp))
-               print_dirfd(tcp, tcp->u_arg[0]);
-       return decode_readlink(tcp, 1);
-}
diff --git a/readlink.c b/readlink.c
new file mode 100644 (file)
index 0000000..efa8e9f
--- /dev/null
@@ -0,0 +1,38 @@
+#include "defs.h"
+
+static int
+decode_readlink(struct tcb *tcp, int offset)
+{
+       if (entering(tcp)) {
+               printpath(tcp, tcp->u_arg[offset]);
+               tprints(", ");
+       } else {
+               if (syserror(tcp))
+                       tprintf("%#lx", tcp->u_arg[offset + 1]);
+               else
+                       /* Used to use printpathn(), but readlink
+                        * neither includes NUL in the returned count,
+                        * nor actually writes it into memory.
+                        * printpathn() would decide on printing
+                        * "..." continuation based on garbage
+                        * past return buffer's end.
+                        */
+                       printstr(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
+               tprintf(", %lu", tcp->u_arg[offset + 2]);
+       }
+       return 0;
+}
+
+int
+sys_readlink(struct tcb *tcp)
+{
+       return decode_readlink(tcp, 0);
+}
+
+int
+sys_readlinkat(struct tcb *tcp)
+{
+       if (entering(tcp))
+               print_dirfd(tcp, tcp->u_arg[0]);
+       return decode_readlink(tcp, 1);
+}