Blame SOURCES/0042-fs-ntfs3-Show-uid-gid-always-in-show_options.patch

Kmods SIG 63c143
From 15b2ae776044ac52cddda8a3e6c9fecd15226b8c Mon Sep 17 00:00:00 2001
Kmods SIG 63c143
From: Kari Argillander <kari.argillander@gmail.com>
Kmods SIG 63c143
Date: Tue, 7 Sep 2021 18:35:57 +0300
Kmods SIG 63c143
Subject: [Backport 15b2ae776044] src: Show uid/gid always in
Kmods SIG 63c143
 show_options()
Kmods SIG 63c143
Kmods SIG 63c143
Show options should show option according documentation when some value
Kmods SIG 63c143
is not default or when ever coder wants. Uid/gid are problematic because
Kmods SIG 63c143
it is hard to know which are defaults. In file system there is many
Kmods SIG 63c143
different implementation for this problem.
Kmods SIG 63c143
Kmods SIG 63c143
Some file systems show uid/gid when they are different than root, some
Kmods SIG 63c143
when user has set them and some show them always. There is also problem
Kmods SIG 63c143
that what if root uid/gid change. This code just choose to show them
Kmods SIG 63c143
always. This way we do not need to think this any more.
Kmods SIG 63c143
Kmods SIG 63c143
Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
Kmods SIG 63c143
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Kmods SIG 63c143
---
Kmods SIG 63c143
 src/ntfs_fs.h | 23 ++++++++++-------------
Kmods SIG 63c143
 src/super.c   | 12 ++++--------
Kmods SIG 63c143
 2 files changed, 14 insertions(+), 21 deletions(-)
Kmods SIG 63c143
Kmods SIG 63c143
diff --git a/src/ntfs_fs.h b/src/ntfs_fs.h
Kmods SIG 63c143
index 15bab48bc1ad13a9bc93d365ce92c8978635ec2b..372cda697dd4c587a82ed6381a1dd512b700d5c1 100644
Kmods SIG 63c143
--- a/src/ntfs_fs.h
Kmods SIG 63c143
+++ b/src/ntfs_fs.h
Kmods SIG 63c143
@@ -60,19 +60,16 @@ struct ntfs_mount_options {
Kmods SIG 63c143
 	u16 fs_fmask_inv;
Kmods SIG 63c143
 	u16 fs_dmask_inv;
Kmods SIG 63c143
 
Kmods SIG 63c143
-	unsigned uid : 1, /* uid was set. */
Kmods SIG 63c143
-		gid : 1, /* gid was set. */
Kmods SIG 63c143
-		fmask : 1, /* fmask was set. */
Kmods SIG 63c143
-		dmask : 1, /* dmask was set. */
Kmods SIG 63c143
-		sys_immutable : 1, /* Immutable system files. */
Kmods SIG 63c143
-		discard : 1, /* Issue discard requests on deletions. */
Kmods SIG 63c143
-		sparse : 1, /* Create sparse files. */
Kmods SIG 63c143
-		showmeta : 1, /* Show meta files. */
Kmods SIG 63c143
-		nohidden : 1, /* Do not show hidden files. */
Kmods SIG 63c143
-		force : 1, /* Rw mount dirty volume. */
Kmods SIG 63c143
-		noacsrules : 1, /*Exclude acs rules. */
Kmods SIG 63c143
-		prealloc : 1 /* Preallocate space when file is growing. */
Kmods SIG 63c143
-		;
Kmods SIG 63c143
+	unsigned fmask : 1; /* fmask was set. */
Kmods SIG 63c143
+	unsigned dmask : 1; /*dmask was set. */
Kmods SIG 63c143
+	unsigned sys_immutable : 1; /* Immutable system files. */
Kmods SIG 63c143
+	unsigned discard : 1; /* Issue discard requests on deletions. */
Kmods SIG 63c143
+	unsigned sparse : 1; /* Create sparse files. */
Kmods SIG 63c143
+	unsigned showmeta : 1; /* Show meta files. */
Kmods SIG 63c143
+	unsigned nohidden : 1; /* Do not show hidden files. */
Kmods SIG 63c143
+	unsigned force : 1; /* RW mount dirty volume. */
Kmods SIG 63c143
+	unsigned noacsrules : 1; /* Exclude acs rules. */
Kmods SIG 63c143
+	unsigned prealloc : 1; /* Preallocate space when file is growing. */
Kmods SIG 63c143
 };
Kmods SIG 63c143
 
Kmods SIG 63c143
 /* Special value to unpack and deallocate. */
Kmods SIG 63c143
diff --git a/src/super.c b/src/super.c
Kmods SIG 63c143
index 0690e7e4f00de4e6c89cacebdb4862bbb8f00bc6..3cba0b5e7ac72c444a55de38b791faa87732049f 100644
Kmods SIG 63c143
--- a/src/super.c
Kmods SIG 63c143
+++ b/src/super.c
Kmods SIG 63c143
@@ -294,13 +294,11 @@ static int ntfs_fs_parse_param(struct fs_context *fc,
Kmods SIG 63c143
 		opts->fs_uid = make_kuid(current_user_ns(), result.uint_32);
Kmods SIG 63c143
 		if (!uid_valid(opts->fs_uid))
Kmods SIG 63c143
 			return invalf(fc, "ntfs3: Invalid value for uid.");
Kmods SIG 63c143
-		opts->uid = 1;
Kmods SIG 63c143
 		break;
Kmods SIG 63c143
 	case Opt_gid:
Kmods SIG 63c143
 		opts->fs_gid = make_kgid(current_user_ns(), result.uint_32);
Kmods SIG 63c143
 		if (!gid_valid(opts->fs_gid))
Kmods SIG 63c143
 			return invalf(fc, "ntfs3: Invalid value for gid.");
Kmods SIG 63c143
-		opts->gid = 1;
Kmods SIG 63c143
 		break;
Kmods SIG 63c143
 	case Opt_umask:
Kmods SIG 63c143
 		if (result.uint_32 & ~07777)
Kmods SIG 63c143
@@ -521,12 +519,10 @@ static int ntfs_show_options(struct seq_file *m, struct dentry *root)
Kmods SIG 63c143
 	struct ntfs_mount_options *opts = sbi->options;
Kmods SIG 63c143
 	struct user_namespace *user_ns = seq_user_ns(m);
Kmods SIG 63c143
 
Kmods SIG 63c143
-	if (opts->uid)
Kmods SIG 63c143
-		seq_printf(m, ",uid=%u",
Kmods SIG 63c143
-			   from_kuid_munged(user_ns, opts->fs_uid));
Kmods SIG 63c143
-	if (opts->gid)
Kmods SIG 63c143
-		seq_printf(m, ",gid=%u",
Kmods SIG 63c143
-			   from_kgid_munged(user_ns, opts->fs_gid));
Kmods SIG 63c143
+	seq_printf(m, ",uid=%u",
Kmods SIG 63c143
+		  from_kuid_munged(user_ns, opts->fs_uid));
Kmods SIG 63c143
+	seq_printf(m, ",gid=%u",
Kmods SIG 63c143
+		  from_kgid_munged(user_ns, opts->fs_gid));
Kmods SIG 63c143
 	if (opts->fmask)
Kmods SIG 63c143
 		seq_printf(m, ",fmask=%04o", ~opts->fs_fmask_inv);
Kmods SIG 63c143
 	if (opts->dmask)
Kmods SIG 63c143
-- 
Kmods SIG 63c143
2.31.1
Kmods SIG 63c143