Decode paths associated with file descriptors returned by syscalls
authorZubin Mithra <zubin.mithra@gmail.com>
Wed, 4 Jun 2014 03:00:41 +0000 (08:30 +0530)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 4 Jun 2014 16:28:04 +0000 (16:28 +0000)
* defs.h (RVAL_FD): New macro.
(RVAL_MASK, RVAL_STR, RVAL_NONE): Update.
* desc.c (sys_dup, sys_delete_module): New functions.
(do_dup2, decode_open, sys_creat): Change return value to RVAL_FD.
* linux/dummy.h (sys_delete_module, sys_dup): Remove.
* linux/syscall.h (sys_delete_module, sys_dup): New prototypes.
* syscall.c (trace_syscall_exiting): Handle RVAL_FD.

Signed-off-by: Zubin Mithra <zubin.mithra@gmail.com>
defs.h
desc.c
file.c
linux/dummy.h
linux/syscall.h
syscall.c

diff --git a/defs.h b/defs.h
index c862de5a726b6c457aa5b7a1d1b0bd426b0edff3..1a3b48376360c268d2ae050cb5083823a7966529 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -533,10 +533,11 @@ extern const struct xlat whence_codes[];
 # endif
 # define RVAL_LUDECIMAL        007     /* long unsigned decimal format */
 #endif
-#define RVAL_MASK      007     /* mask for these values */
+#define RVAL_FD                010     /* file descriptor */
+#define RVAL_MASK      017     /* mask for these values */
 
-#define RVAL_STR       010     /* Print `auxstr' field after return val */
-#define RVAL_NONE      020     /* Print nothing */
+#define RVAL_STR       020     /* Print `auxstr' field after return val */
+#define RVAL_NONE      040     /* Print nothing */
 
 #define TRACE_FILE     001     /* Trace file-related syscalls. */
 #define TRACE_IPC      002     /* Trace IPC-related syscalls. */
diff --git a/desc.c b/desc.c
index 0c9a81755acbd90c00370f0e0df48fabcb284b32..5b8869bcf92e426bfd85b2410cf58ff449f2291b 100644 (file)
--- a/desc.c
+++ b/desc.c
@@ -265,6 +265,15 @@ sys_close(struct tcb *tcp)
        return 0;
 }
 
+int
+sys_dup(struct tcb *tcp)
+{
+       if (entering(tcp)) {
+               printfd(tcp, tcp->u_arg[0]);
+       }
+       return RVAL_FD;
+}
+
 static int
 do_dup2(struct tcb *tcp, int flags_arg)
 {
@@ -277,7 +286,7 @@ do_dup2(struct tcb *tcp, int flags_arg)
                        printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
                }
        }
-       return 0;
+       return RVAL_FD;
 }
 
 int
diff --git a/file.c b/file.c
index c32224271012bc0f705a15157431640252eb1313..f817182826a422abbaff121dce857a1d42a9393b 100644 (file)
--- a/file.c
+++ b/file.c
@@ -303,7 +303,7 @@ decode_open(struct tcb *tcp, int offset)
                        tprintf(", %#lo", tcp->u_arg[offset + 2]);
                }
        }
-       return 0;
+       return RVAL_FD;
 }
 
 int
@@ -312,6 +312,12 @@ sys_open(struct tcb *tcp)
        return decode_open(tcp, 0);
 }
 
+int sys_delete_module(struct tcb *tcp)
+{
+       decode_open(tcp, 0);
+       return RVAL_DECIMAL;
+}
+
 int
 sys_openat(struct tcb *tcp)
 {
@@ -348,7 +354,7 @@ sys_creat(struct tcb *tcp)
                printpath(tcp, tcp->u_arg[0]);
                tprintf(", %#lo", tcp->u_arg[1]);
        }
-       return 0;
+       return RVAL_FD;
 }
 
 #include "xlat/access_flags.h"
index 4f3e92029f6ac3b903791ff5e21f1eeaa030346d..6068666733a1024d9cefe9d12da8b8bc949fbde1 100644 (file)
@@ -57,8 +57,6 @@
 #define        sys_acct                sys_chdir
 #define        sys_chroot              sys_chdir
 #define        sys_clock_getres        sys_clock_gettime
-#define        sys_delete_module       sys_open
-#define        sys_dup                 sys_close
 #define        sys_fchdir              sys_close
 #define        sys_fdatasync           sys_close
 #define        sys_fsync               sys_close
index 1943297689de8d9d0dfbe9b0f4ab4c188f95a16d..38aa4bd7e8eb893abc1e1c76f0a123da6808a860 100644 (file)
@@ -52,6 +52,8 @@ int sys_close();
 int sys_connect();
 int sys_creat();
 int sys_create_module();
+int sys_delete_module();
+int sys_dup();
 int sys_dup2();
 int sys_dup3();
 int sys_epoll_create();
index c95eb6c888e7c44d841da8ab1bc047fcb42f2645..b0ad47e13caf837e60715d406d007f7572a78dd8 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -2688,6 +2688,14 @@ trace_syscall_exiting(struct tcb *tcp)
                        case RVAL_DECIMAL:
                                tprintf("= %ld", tcp->u_rval);
                                break;
+                       case RVAL_FD:
+                               if (show_fd_path) {
+                                       tprints("= ");
+                                       printfd(tcp, tcp->u_rval);
+                               }
+                               else
+                                       tprintf("= %ld", tcp->u_rval);
+                               break;
 #if defined(LINUX_MIPSN32) || defined(X32)
                        /*
                        case RVAL_LHEX: