From: Dmitry V. Levin Date: Mon, 25 Apr 2016 10:15:14 +0000 (+0000) Subject: statfs: print f_flags field only when ST_VALID flag is set X-Git-Tag: v4.12~289 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f3ac12990dd4e88f5842972caec5958523f95069;p=strace statfs: print f_flags field only when ST_VALID flag is set * statfs.c (print_statfs_flags): New function. (printstatfs, printstatfs64, printcompat_statfs64): Use it. * xlat/statfs_flags.in (ST_VALID): Move to the head of the list. * tests/statfs.expected: Update. --- diff --git a/statfs.c b/statfs.c index 706e0990..73892b6c 100644 --- a/statfs.c +++ b/statfs.c @@ -51,6 +51,15 @@ sprintfstype(const unsigned int magic) return buf; } +static void +print_statfs_flags(const char *const prefix, const unsigned int flags) +{ + if (flags & ST_VALID) { + tprints(prefix); + printflags(statfs_flags, flags, "ST_???"); + } +} + static void printstatfs(struct tcb *tcp, const long addr) { @@ -73,8 +82,7 @@ printstatfs(struct tcb *tcp, const long addr) tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize); #endif #ifdef _STATFS_F_FLAGS - tprints(", f_flags="); - printflags(statfs_flags, statbuf.f_flags, "ST_???"); + print_statfs_flags(", f_flags=", statbuf.f_flags); #endif tprints("}"); } @@ -124,8 +132,7 @@ printstatfs64(struct tcb *tcp, long addr) tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize); #endif #ifdef _STATFS_F_FLAGS - tprints(", f_flags="); - printflags(statfs_flags, statbuf.f_flags, "ST_???"); + print_statfs_flags(", f_flags=", statbuf.f_flags); #endif tprints("}"); } @@ -172,8 +179,7 @@ printcompat_statfs64(struct tcb *tcp, const long addr) statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]); tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen); tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize); - tprints(", f_flags="); - printflags(statfs_flags, statbuf.f_flags, "ST_???"); + print_statfs_flags(", f_flags=", statbuf.f_flags); tprints("}"); } diff --git a/tests/statfs.expected b/tests/statfs.expected index 9decc1ab..0fa45109 100644 --- a/tests/statfs.expected +++ b/tests/statfs.expected @@ -1 +1 @@ -statfs(64)?\("/proc/self/status"(, [1-9][0-9]*)?, \{f_type=PROC_SUPER_MAGIC, f_bsize=[1-9][0-9]*, f_blocks=[0-9]+, f_bfree=[0-9]+, f_bavail=[0-9]+, f_files=[0-9]+, f_ffree=[0-9]+, f_fsid=\{[0-9]+, [0-9]+\}, f_namelen=[1-9][0-9]*(, f_frsize=[0-9]+)?(, f_flags=(0|ST_[A-Z]+(\|ST_[A-Z]+)*))?\}\) += 0 +statfs(64)?\("/proc/self/status"(, [1-9][0-9]*)?, \{f_type=PROC_SUPER_MAGIC, f_bsize=[1-9][0-9]*, f_blocks=[0-9]+, f_bfree=[0-9]+, f_bavail=[0-9]+, f_files=[0-9]+, f_ffree=[0-9]+, f_fsid=\{[0-9]+, [0-9]+\}, f_namelen=[1-9][0-9]*(, f_frsize=[0-9]+)?(, f_flags=ST_VALID(\|ST_[A-Z]+)*)?\}\) += 0 diff --git a/xlat/statfs_flags.in b/xlat/statfs_flags.in index 2b427c3d..f791a60e 100644 --- a/xlat/statfs_flags.in +++ b/xlat/statfs_flags.in @@ -1,9 +1,9 @@ +ST_VALID 0x0020 ST_RDONLY 0x0001 ST_NOSUID 0x0002 ST_NODEV 0x0004 ST_NOEXEC 0x0008 ST_SYNCHRONOUS 0x0010 -ST_VALID 0x0020 ST_MANDLOCK 0x0040 ST_NOATIME 0x0400 ST_NODIRATIME 0x0800