Skip to content

Commit 26a7655

Browse files
dhowellsAl Viro
authored andcommitted
affs: Implement show_options
Implement the show_options superblock op for affs 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. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 3ab7947 commit 26a7655

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

fs/affs/super.c

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
#include <linux/slab.h>
2121
#include <linux/writeback.h>
2222
#include <linux/blkdev.h>
23+
#include <linux/seq_file.h>
2324
#include "affs.h"
2425

2526
static int affs_statfs(struct dentry *dentry, struct kstatfs *buf);
27+
static int affs_show_options(struct seq_file *m, struct dentry *root);
2628
static int affs_remount (struct super_block *sb, int *flags, char *data);
2729

2830
static void
@@ -159,7 +161,7 @@ static const struct super_operations affs_sops = {
159161
.sync_fs = affs_sync_fs,
160162
.statfs = affs_statfs,
161163
.remount_fs = affs_remount,
162-
.show_options = generic_show_options,
164+
.show_options = affs_show_options,
163165
};
164166

165167
enum {
@@ -293,6 +295,40 @@ parse_options(char *options, kuid_t *uid, kgid_t *gid, int *mode, int *reserved,
293295
return 1;
294296
}
295297

298+
static int affs_show_options(struct seq_file *m, struct dentry *root)
299+
{
300+
struct super_block *sb = root->d_sb;
301+
struct affs_sb_info *sbi = AFFS_SB(sb);
302+
303+
if (sb->s_blocksize)
304+
seq_printf(m, ",bs=%lu", sb->s_blocksize);
305+
if (affs_test_opt(sbi->s_flags, SF_SETMODE))
306+
seq_printf(m, ",mode=%o", sbi->s_mode);
307+
if (affs_test_opt(sbi->s_flags, SF_MUFS))
308+
seq_puts(m, ",mufs");
309+
if (affs_test_opt(sbi->s_flags, SF_NO_TRUNCATE))
310+
seq_puts(m, ",nofilenametruncate");
311+
if (affs_test_opt(sbi->s_flags, SF_PREFIX))
312+
seq_printf(m, ",prefix=%s", sbi->s_prefix);
313+
if (affs_test_opt(sbi->s_flags, SF_IMMUTABLE))
314+
seq_puts(m, ",protect");
315+
if (sbi->s_reserved != 2)
316+
seq_printf(m, ",reserved=%u", sbi->s_reserved);
317+
if (sbi->s_root_block != (sbi->s_reserved + sbi->s_partition_size - 1) / 2)
318+
seq_printf(m, ",root=%u", sbi->s_root_block);
319+
if (affs_test_opt(sbi->s_flags, SF_SETGID))
320+
seq_printf(m, ",setgid=%u",
321+
from_kgid_munged(&init_user_ns, sbi->s_gid));
322+
if (affs_test_opt(sbi->s_flags, SF_SETUID))
323+
seq_printf(m, ",setuid=%u",
324+
from_kuid_munged(&init_user_ns, sbi->s_uid));
325+
if (affs_test_opt(sbi->s_flags, SF_VERBOSE))
326+
seq_puts(m, ",verbose");
327+
if (sbi->s_volume[0])
328+
seq_printf(m, ",volume=%s", sbi->s_volume);
329+
return 0;
330+
}
331+
296332
/* This function definitely needs to be split up. Some fine day I'll
297333
* hopefully have the guts to do so. Until then: sorry for the mess.
298334
*/
@@ -316,8 +352,6 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
316352
u8 sig[4];
317353
int ret;
318354

319-
save_mount_options(sb, data);
320-
321355
pr_debug("read_super(%s)\n", data ? (const char *)data : "no options");
322356

323357
sb->s_magic = AFFS_SUPER_MAGIC;
@@ -548,8 +582,6 @@ affs_remount(struct super_block *sb, int *flags, char *data)
548582
}
549583

550584
flush_delayed_work(&sbi->sb_work);
551-
if (new_opts)
552-
replace_mount_options(sb, new_opts);
553585

554586
sbi->s_flags = mount_flags;
555587
sbi->s_mode = mode;

0 commit comments

Comments
 (0)