]> granicus.if.org Git - strace/commitdiff
swapon: decode swap flags
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 9 Mar 2012 21:02:19 +0000 (21:02 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 9 Mar 2012 21:02:19 +0000 (21:02 +0000)
* file.c: Include <sys/swap.h>.
(swap_flags): New xlat structure.
(sys_swapon): New function.
* linux/dummy.h (sys_swapon): Remove.
* linux/syscall.h (sys_swapon): New declaration.

file.c
linux/dummy.h
linux/syscall.h

diff --git a/file.c b/file.c
index be1b1a73688eb644ffdf02de225d7b9a52ac36db..c04d581ad6759332a1e6fe7218f2e112db451ac0 100644 (file)
--- a/file.c
+++ b/file.c
@@ -33,6 +33,7 @@
 #include "defs.h"
 
 #include <dirent.h>
+#include <sys/swap.h>
 
 struct kernel_dirent {
        unsigned long   d_ino;
@@ -2694,3 +2695,24 @@ sys_fallocate(struct tcb *tcp)
        }
        return 0;
 }
+
+static const struct xlat swap_flags[] = {
+       { SWAP_FLAG_PREFER,     "SWAP_FLAG_PREFER"      },
+       { SWAP_FLAG_DISCARD,    "SWAP_FLAG_DISCARD"     },
+       { 0,                    NULL                    }
+};
+
+int
+sys_swapon(struct tcb *tcp)
+{
+       if (entering(tcp)) {
+               int flags = tcp->u_arg[1];
+               printpath(tcp, tcp->u_arg[0]);
+               tprints(", ");
+               printflags(swap_flags, flags & ~SWAP_FLAG_PRIO_MASK,
+                       "SWAP_FLAG_???");
+               if (flags & SWAP_FLAG_PREFER)
+                       tprintf("|%d", flags & SWAP_FLAG_PRIO_MASK);
+       }
+       return 0;
+}
index 1605bb40bb0da0f50741a7114b5e89f99399fd5f..493da2aef583fd78917c787a558bad32766f2759 100644 (file)
@@ -91,7 +91,6 @@
 #define        sys_rmdir               sys_chdir
 #define        sys_sched_get_priority_max      sys_sched_get_priority_min
 #define        sys_swapoff             sys_chdir
-#define        sys_swapon              sys_chdir
 #define        sys_symlink             sys_link
 #define        sys_syncfs              sys_close
 #define        sys_umount              sys_chdir
index 45f00a3bad245d8ffeca31632461228a823aefbb..4eb7368b1ce0f8a9a8a7736a05e88131e079f017 100644 (file)
@@ -259,6 +259,7 @@ int sys_stat64();
 int sys_statfs();
 int sys_statfs64();
 int sys_stime();
+int sys_swapon();
 int sys_symlinkat();
 int sys_sysctl();
 int sys_sysinfo();