Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1681590 > unrolled thread

[PATCH 03/14] omfs: Implement show_options

Started byDavid Howells <dhowells@redhat.com>
First post2017-07-05 17:30 +0200
Last post2017-07-07 20:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 03/14] omfs: Implement show_options David Howells <dhowells@redhat.com> - 2017-07-05 17:30 +0200
    Re: [PATCH 03/14] omfs: Implement show_options Bob Copeland <me@bobcopeland.com> - 2017-07-07 20:30 +0200

#1681590 — [PATCH 03/14] omfs: Implement show_options

FromDavid Howells <dhowells@redhat.com>
Date2017-07-05 17:30 +0200
Subject[PATCH 03/14] omfs: Implement show_options
Message-ID<tZUpA-83i-25@gated-at.bofh.it>
Implement the show_options superblock op for omfs as part of a bid to get
rid of s_options and generic_show_options() to make it easier to implement
a context-based mount where the mount options can be passed individually
over a file descriptor.

Note that the uid and gid should possibly be displayed relative to the
viewer's user namespace.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Bob Copeland <me@bobcopeland.com>
cc: linux-karma-devel@lists.sourceforge.net
---

 fs/omfs/inode.c |   33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
index 8c9034ee7383..ee14af9e26f2 100644
--- a/fs/omfs/inode.c
+++ b/fs/omfs/inode.c
@@ -13,6 +13,7 @@
 #include <linux/buffer_head.h>
 #include <linux/vmalloc.h>
 #include <linux/writeback.h>
+#include <linux/seq_file.h>
 #include <linux/crc-itu-t.h>
 #include "omfs.h"
 
@@ -290,12 +291,40 @@ static int omfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 	return 0;
 }
 
+/*
+ * Display the mount options in /proc/mounts.
+ */
+static int omfs_show_options(struct seq_file *m, struct dentry *root)
+{
+	struct omfs_sb_info *sbi = OMFS_SB(root->d_sb);
+	umode_t cur_umask = current_umask();
+
+	if (!uid_eq(sbi->s_uid, current_uid()))
+		seq_printf(m, ",uid=%u",
+			   from_kuid_munged(&init_user_ns, sbi->s_uid));
+	if (!gid_eq(sbi->s_gid, current_gid()))
+		seq_printf(m, ",gid=%u",
+			   from_kgid_munged(&init_user_ns, sbi->s_gid));
+
+	if (sbi->s_dmask == sbi->s_fmask) {
+		if (sbi->s_fmask != cur_umask)
+			seq_printf(m, ",umask=%o", sbi->s_fmask);
+	} else {
+		if (sbi->s_dmask != cur_umask)
+			seq_printf(m, ",dmask=%o", sbi->s_dmask);
+		if (sbi->s_fmask != cur_umask)
+			seq_printf(m, ",fmask=%o", sbi->s_fmask);
+	}
+
+	return 0;
+}
+
 static const struct super_operations omfs_sops = {
 	.write_inode	= omfs_write_inode,
 	.evict_inode	= omfs_evict_inode,
 	.put_super	= omfs_put_super,
 	.statfs		= omfs_statfs,
-	.show_options	= generic_show_options,
+	.show_options	= omfs_show_options,
 };
 
 /*
@@ -434,8 +463,6 @@ static int omfs_fill_super(struct super_block *sb, void *data, int silent)
 	struct inode *root;
 	int ret = -EINVAL;
 
-	save_mount_options(sb, (char *) data);
-
 	sbi = kzalloc(sizeof(struct omfs_sb_info), GFP_KERNEL);
 	if (!sbi)
 		return -ENOMEM;

[toc] | [next] | [standalone]


#1683360

FromBob Copeland <me@bobcopeland.com>
Date2017-07-07 20:30 +0200
Message-ID<u0GaR-7Kj-15@gated-at.bofh.it>
In reply to#1681590
On Wed, Jul 05, 2017 at 04:24:27PM +0100, David Howells wrote:
> Implement the show_options superblock op for omfs as part of a bid to get
> rid of s_options and generic_show_options() to make it easier to implement
> a context-based mount where the mount options can be passed individually
> over a file descriptor.
> 
> Note that the uid and gid should possibly be displayed relative to the
> viewer's user namespace.
> 
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Bob Copeland <me@bobcopeland.com>

Acked-by: Bob Copeland <me@bobcopeland.com>

-- 
Bob Copeland %% https://bobcopeland.com/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web