From: Dmitry V. Levin Date: Fri, 9 Mar 2012 21:02:19 +0000 (+0000) Subject: swapon: decode swap flags X-Git-Tag: v4.7~134 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=882936565463ff895e6d50efc5c7c80521e7add8;p=strace swapon: decode swap flags * file.c: Include . (swap_flags): New xlat structure. (sys_swapon): New function. * linux/dummy.h (sys_swapon): Remove. * linux/syscall.h (sys_swapon): New declaration. --- diff --git a/file.c b/file.c index be1b1a73..c04d581a 100644 --- a/file.c +++ b/file.c @@ -33,6 +33,7 @@ #include "defs.h" #include +#include 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; +} diff --git a/linux/dummy.h b/linux/dummy.h index 1605bb40..493da2ae 100644 --- a/linux/dummy.h +++ b/linux/dummy.h @@ -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 diff --git a/linux/syscall.h b/linux/syscall.h index 45f00a3b..4eb7368b 100644 --- a/linux/syscall.h +++ b/linux/syscall.h @@ -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();