Skip to content

Commit d86efb0

Browse files
dhowellsAl Viro
authored andcommitted
omfs: Implement show_options
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]>
1 parent 4a25220 commit d86efb0

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

fs/omfs/inode.c

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/buffer_head.h>
1414
#include <linux/vmalloc.h>
1515
#include <linux/writeback.h>
16+
#include <linux/seq_file.h>
1617
#include <linux/crc-itu-t.h>
1718
#include "omfs.h"
1819

@@ -290,12 +291,40 @@ static int omfs_statfs(struct dentry *dentry, struct kstatfs *buf)
290291
return 0;
291292
}
292293

294+
/*
295+
* Display the mount options in /proc/mounts.
296+
*/
297+
static int omfs_show_options(struct seq_file *m, struct dentry *root)
298+
{
299+
struct omfs_sb_info *sbi = OMFS_SB(root->d_sb);
300+
umode_t cur_umask = current_umask();
301+
302+
if (!uid_eq(sbi->s_uid, current_uid()))
303+
seq_printf(m, ",uid=%u",
304+
from_kuid_munged(&init_user_ns, sbi->s_uid));
305+
if (!gid_eq(sbi->s_gid, current_gid()))
306+
seq_printf(m, ",gid=%u",
307+
from_kgid_munged(&init_user_ns, sbi->s_gid));
308+
309+
if (sbi->s_dmask == sbi->s_fmask) {
310+
if (sbi->s_fmask != cur_umask)
311+
seq_printf(m, ",umask=%o", sbi->s_fmask);
312+
} else {
313+
if (sbi->s_dmask != cur_umask)
314+
seq_printf(m, ",dmask=%o", sbi->s_dmask);
315+
if (sbi->s_fmask != cur_umask)
316+
seq_printf(m, ",fmask=%o", sbi->s_fmask);
317+
}
318+
319+
return 0;
320+
}
321+
293322
static const struct super_operations omfs_sops = {
294323
.write_inode = omfs_write_inode,
295324
.evict_inode = omfs_evict_inode,
296325
.put_super = omfs_put_super,
297326
.statfs = omfs_statfs,
298-
.show_options = generic_show_options,
327+
.show_options = omfs_show_options,
299328
};
300329

301330
/*
@@ -434,8 +463,6 @@ static int omfs_fill_super(struct super_block *sb, void *data, int silent)
434463
struct inode *root;
435464
int ret = -EINVAL;
436465

437-
save_mount_options(sb, (char *) data);
438-
439466
sbi = kzalloc(sizeof(struct omfs_sb_info), GFP_KERNEL);
440467
if (!sbi)
441468
return -ENOMEM;

0 commit comments

Comments
 (0)