Skip to content

Commit 604ecf4

Browse files
dhowellsAl Viro
authored andcommitted
ramfs: Implement show_options
Implement the show_options superblock op for ramfs 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 <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 349d743 commit 604ecf4

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

fs/ramfs/inode.c

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@
3838
#include <linux/uaccess.h>
3939
#include "internal.h"
4040

41+
struct ramfs_mount_opts {
42+
umode_t mode;
43+
};
44+
45+
struct ramfs_fs_info {
46+
struct ramfs_mount_opts mount_opts;
47+
};
48+
4149
#define RAMFS_DEFAULT_MODE 0755
4250

4351
static const struct super_operations ramfs_ops;
@@ -149,14 +157,22 @@ static const struct inode_operations ramfs_dir_inode_operations = {
149157
.rename = simple_rename,
150158
};
151159

160+
/*
161+
* Display the mount options in /proc/mounts.
162+
*/
163+
static int ramfs_show_options(struct seq_file *m, struct dentry *root)
164+
{
165+
struct ramfs_fs_info *fsi = root->d_sb->s_fs_info;
166+
167+
if (fsi->mount_opts.mode != RAMFS_DEFAULT_MODE)
168+
seq_printf(m, ",mode=%o", fsi->mount_opts.mode);
169+
return 0;
170+
}
171+
152172
static const struct super_operations ramfs_ops = {
153173
.statfs = simple_statfs,
154174
.drop_inode = generic_delete_inode,
155-
.show_options = generic_show_options,
156-
};
157-
158-
struct ramfs_mount_opts {
159-
umode_t mode;
175+
.show_options = ramfs_show_options,
160176
};
161177

162178
enum {
@@ -169,10 +185,6 @@ static const match_table_t tokens = {
169185
{Opt_err, NULL}
170186
};
171187

172-
struct ramfs_fs_info {
173-
struct ramfs_mount_opts mount_opts;
174-
};
175-
176188
static int ramfs_parse_options(char *data, struct ramfs_mount_opts *opts)
177189
{
178190
substring_t args[MAX_OPT_ARGS];
@@ -211,8 +223,6 @@ int ramfs_fill_super(struct super_block *sb, void *data, int silent)
211223
struct inode *inode;
212224
int err;
213225

214-
save_mount_options(sb, data);
215-
216226
fsi = kzalloc(sizeof(struct ramfs_fs_info), GFP_KERNEL);
217227
sb->s_fs_info = fsi;
218228
if (!fsi)

0 commit comments

Comments
 (0)