Skip to content

Commit

Permalink
omfs: Implement show_options
Browse files Browse the repository at this point in the history
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 <[email protected]>
cc: Bob Copeland <[email protected]>
cc: [email protected]
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
dhowells authored and Al Viro committed Jul 6, 2017
1 parent 4a25220 commit d86efb0
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions fs/omfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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,
};

/*
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d86efb0

Please sign in to comment.