[PATCH] findmnt: add option to list all statvfs f_flags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It might be useful for security auditing purposes list all possible
mount flags/options including default set which are normally not listed.

Given that we already call statvfs to retrieve i.e. filesystem size,
add an extra column to list all possible f_flags, default or not.

Signed-off-by: Roberto Bergantinos Corpas <rbergant@xxxxxxxxxx>
---
 misc-utils/findmnt.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c
index 43b4dc7d6..da9f42020 100644
--- a/misc-utils/findmnt.c
+++ b/misc-utils/findmnt.c
@@ -56,6 +56,7 @@ enum {
 	COL_FSTYPE,
 	COL_OPTIONS,
 	COL_VFS_OPTIONS,
+	COL_MNT_OPTIONS,
 	COL_FS_OPTIONS,
 	COL_LABEL,
 	COL_UUID,
@@ -101,6 +102,7 @@ static struct colinfo infos[] = {
 	[COL_FSTYPE]       = { "FSTYPE",       0.10, SCOLS_FL_TRUNC, N_("filesystem type") },
 	[COL_OPTIONS]      = { "OPTIONS",      0.10, SCOLS_FL_TRUNC, N_("all mount options") },
 	[COL_VFS_OPTIONS]  = { "VFS-OPTIONS",  0.20, SCOLS_FL_TRUNC, N_("VFS specific mount options") },
+	[COL_MNT_OPTIONS]  = { "MNT-OPTIONS",  0.20, SCOLS_FL_TRUNC, N_("All statvfs f_flags from mount") },
 	[COL_FS_OPTIONS]   = { "FS-OPTIONS",   0.10, SCOLS_FL_TRUNC, N_("FS specific mount options") },
 	[COL_LABEL]        = { "LABEL",        0.10, 0, N_("filesystem label") },
 	[COL_UUID]         = { "UUID",           36, 0, N_("filesystem UUID") },
@@ -490,6 +492,26 @@ static char *get_vfs_attr(struct libmnt_fs *fs, int sizetype)
 				(double)(buf.f_blocks - buf.f_bfree) /
 				buf.f_blocks * 100);
 		return sizestr;
+	case COL_MNT_OPTIONS:
+		if (mnt_fs_get_vfs_options(fs)) {
+			sizestr = xstrdup(mnt_fs_get_vfs_options(fs));
+			if (!(buf.f_flag & MS_NOEXEC))
+				mnt_optstr_append_option(&sizestr, "exec", NULL);
+			if (!(buf.f_flag & MS_NOSUID))
+				mnt_optstr_append_option(&sizestr, "suid", NULL);
+			if (!(buf.f_flag & MS_NODEV))
+				mnt_optstr_append_option(&sizestr, "dev", NULL);
+			if (!(buf.f_flag & MS_SYNCHRONOUS))
+				mnt_optstr_append_option(&sizestr, "async", NULL);
+			if (!(buf.f_flag & MS_MANDLOCK))
+				mnt_optstr_append_option(&sizestr, "nomand", NULL);
+			if (!(buf.f_flag & MS_NOATIME))
+				mnt_optstr_append_option(&sizestr, "atime", NULL);
+			if (!(buf.f_flag & MS_NODIRATIME))
+				mnt_optstr_append_option(&sizestr, "diratime", NULL);
+			return sizestr;
+		} else
+			return NULL;
 	}
 
 	if (!vfs_attr)
@@ -585,6 +607,7 @@ static char *get_data(struct libmnt_fs *fs, int num)
 	case COL_AVAIL:
 	case COL_USED:
 	case COL_USEPERC:
+	case COL_MNT_OPTIONS:
 		str = get_vfs_attr(fs, col_id);
 		break;
 	case COL_FSROOT:
-- 
2.21.0




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux