Skip to content

Commit 78dcf73

Browse files
committed
Merge branch 'work.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull ->s_options removal from Al Viro: "Preparations for fsmount/fsopen stuff (coming next cycle). Everything gets moved to explicit ->show_options(), killing ->s_options off + some cosmetic bits around fs/namespace.c and friends. Basically, the stuff needed to work with fsmount series with minimum of conflicts with other work. It's not strictly required for this merge window, but it would reduce the PITA during the coming cycle, so it would be nice to have those bits and pieces out of the way" * 'work.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: isofs: Fix isofs_show_options() VFS: Kill off s_options and helpers orangefs: Implement show_options 9p: Implement show_options isofs: Implement show_options afs: Implement show_options affs: Implement show_options befs: Implement show_options spufs: Implement show_options bpf: Implement show_options ramfs: Implement show_options pstore: Implement show_options omfs: Implement show_options hugetlbfs: Implement show_options VFS: Don't use save/replace_mount_options if not using generic_show_options VFS: Provide empty name qstr VFS: Make get_filesystem() return the affected filesystem VFS: Clean up whitespace in fs/namespace.c and fs/super.c Provide a function to create a NUL-terminated string from unterminated data
2 parents 93ff818 + fdb254d commit 78dcf73

File tree

41 files changed

+531
-163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+531
-163
lines changed

Documentation/filesystems/vfs.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,12 +1225,6 @@ The underlying reason for the above rules is to make sure, that a
12251225
mount can be accurately replicated (e.g. umounting and mounting again)
12261226
based on the information found in /proc/mounts.
12271227

1228-
A simple method of saving options at mount/remount time and showing
1229-
them is provided with the save_mount_options() and
1230-
generic_show_options() helper functions. Please note, that using
1231-
these may have drawbacks. For more info see header comments for these
1232-
functions in fs/namespace.c.
1233-
12341228
Resources
12351229
=========
12361230

arch/powerpc/platforms/cell/spufs/inode.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,24 @@ static const match_table_t spufs_tokens = {
605605
{ Opt_err, NULL },
606606
};
607607

608+
static int spufs_show_options(struct seq_file *m, struct dentry *root)
609+
{
610+
struct spufs_sb_info *sbi = spufs_get_sb_info(root->d_sb);
611+
struct inode *inode = root->d_inode;
612+
613+
if (!uid_eq(inode->i_uid, GLOBAL_ROOT_UID))
614+
seq_printf(m, ",uid=%u",
615+
from_kuid_munged(&init_user_ns, inode->i_uid));
616+
if (!gid_eq(inode->i_gid, GLOBAL_ROOT_GID))
617+
seq_printf(m, ",gid=%u",
618+
from_kgid_munged(&init_user_ns, inode->i_gid));
619+
if ((inode->i_mode & S_IALLUGO) != 0775)
620+
seq_printf(m, ",mode=%o", inode->i_mode);
621+
if (sbi->debug)
622+
seq_puts(m, ",debug");
623+
return 0;
624+
}
625+
608626
static int
609627
spufs_parse_options(struct super_block *sb, char *options, struct inode *root)
610628
{
@@ -724,11 +742,9 @@ spufs_fill_super(struct super_block *sb, void *data, int silent)
724742
.destroy_inode = spufs_destroy_inode,
725743
.statfs = simple_statfs,
726744
.evict_inode = spufs_evict_inode,
727-
.show_options = generic_show_options,
745+
.show_options = spufs_show_options,
728746
};
729747

730-
save_mount_options(sb, data);
731-
732748
info = kzalloc(sizeof(*info), GFP_KERNEL);
733749
if (!info)
734750
return -ENOMEM;

fs/9p/v9fs.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <linux/parser.h>
3434
#include <linux/idr.h>
3535
#include <linux/slab.h>
36+
#include <linux/seq_file.h>
3637
#include <net/9p/9p.h>
3738
#include <net/9p/client.h>
3839
#include <net/9p/transport.h>
@@ -82,6 +83,13 @@ static const match_table_t tokens = {
8283
{Opt_err, NULL}
8384
};
8485

86+
static const char *const v9fs_cache_modes[nr__p9_cache_modes] = {
87+
[CACHE_NONE] = "none",
88+
[CACHE_MMAP] = "mmap",
89+
[CACHE_LOOSE] = "loose",
90+
[CACHE_FSCACHE] = "fscache",
91+
};
92+
8593
/* Interpret mount options for cache mode */
8694
static int get_cache_mode(char *s)
8795
{
@@ -104,6 +112,58 @@ static int get_cache_mode(char *s)
104112
return version;
105113
}
106114

115+
/*
116+
* Display the mount options in /proc/mounts.
117+
*/
118+
int v9fs_show_options(struct seq_file *m, struct dentry *root)
119+
{
120+
struct v9fs_session_info *v9ses = root->d_sb->s_fs_info;
121+
122+
if (v9ses->debug)
123+
seq_printf(m, ",debug=%x", v9ses->debug);
124+
if (!uid_eq(v9ses->dfltuid, V9FS_DEFUID))
125+
seq_printf(m, ",dfltuid=%u",
126+
from_kuid_munged(&init_user_ns, v9ses->dfltuid));
127+
if (!gid_eq(v9ses->dfltgid, V9FS_DEFGID))
128+
seq_printf(m, ",dfltgid=%u",
129+
from_kgid_munged(&init_user_ns, v9ses->dfltgid));
130+
if (v9ses->afid != ~0)
131+
seq_printf(m, ",afid=%u", v9ses->afid);
132+
if (strcmp(v9ses->uname, V9FS_DEFUSER) != 0)
133+
seq_printf(m, ",uname=%s", v9ses->uname);
134+
if (strcmp(v9ses->aname, V9FS_DEFANAME) != 0)
135+
seq_printf(m, ",aname=%s", v9ses->aname);
136+
if (v9ses->nodev)
137+
seq_puts(m, ",nodevmap");
138+
if (v9ses->cache)
139+
seq_printf(m, ",%s", v9fs_cache_modes[v9ses->cache]);
140+
#ifdef CONFIG_9P_FSCACHE
141+
if (v9ses->cachetag && v9ses->cache == CACHE_FSCACHE)
142+
seq_printf(m, ",cachetag=%s", v9ses->cachetag);
143+
#endif
144+
145+
switch (v9ses->flags & V9FS_ACCESS_MASK) {
146+
case V9FS_ACCESS_USER:
147+
seq_puts(m, ",access=user");
148+
break;
149+
case V9FS_ACCESS_ANY:
150+
seq_puts(m, ",access=any");
151+
break;
152+
case V9FS_ACCESS_CLIENT:
153+
seq_puts(m, ",access=client");
154+
break;
155+
case V9FS_ACCESS_SINGLE:
156+
seq_printf(m, ",access=%u",
157+
from_kuid_munged(&init_user_ns, v9ses->uid));
158+
break;
159+
}
160+
161+
if (v9ses->flags & V9FS_POSIX_ACL)
162+
seq_puts(m, ",posixacl");
163+
164+
return p9_show_client_options(m, v9ses->clnt);
165+
}
166+
107167
/**
108168
* v9fs_parse_options - parse mount options into session structure
109169
* @v9ses: existing v9fs session information
@@ -230,6 +290,7 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
230290
break;
231291
case Opt_cachetag:
232292
#ifdef CONFIG_9P_FSCACHE
293+
kfree(v9ses->cachetag);
233294
v9ses->cachetag = match_strdup(&args[0]);
234295
#endif
235296
break;

fs/9p/v9fs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ enum p9_cache_modes {
6767
CACHE_MMAP,
6868
CACHE_LOOSE,
6969
CACHE_FSCACHE,
70+
nr__p9_cache_modes
7071
};
7172

7273
/**
@@ -137,6 +138,8 @@ static inline struct v9fs_inode *V9FS_I(const struct inode *inode)
137138
return container_of(inode, struct v9fs_inode, vfs_inode);
138139
}
139140

141+
extern int v9fs_show_options(struct seq_file *m, struct dentry *root);
142+
140143
struct p9_fid *v9fs_session_init(struct v9fs_session_info *, const char *,
141144
char *);
142145
extern void v9fs_session_close(struct v9fs_session_info *v9ses);

fs/9p/vfs_super.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include <linux/string.h>
3434
#include <linux/inet.h>
3535
#include <linux/pagemap.h>
36-
#include <linux/seq_file.h>
3736
#include <linux/mount.h>
3837
#include <linux/idr.h>
3938
#include <linux/sched.h>
@@ -104,7 +103,6 @@ v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses,
104103
sb->s_flags |= MS_POSIXACL;
105104
#endif
106105

107-
save_mount_options(sb, data);
108106
return 0;
109107
}
110108

@@ -349,7 +347,7 @@ static const struct super_operations v9fs_super_ops = {
349347
.destroy_inode = v9fs_destroy_inode,
350348
.statfs = simple_statfs,
351349
.evict_inode = v9fs_evict_inode,
352-
.show_options = generic_show_options,
350+
.show_options = v9fs_show_options,
353351
.umount_begin = v9fs_umount_begin,
354352
.write_inode = v9fs_write_inode,
355353
};
@@ -360,7 +358,7 @@ static const struct super_operations v9fs_super_ops_dotl = {
360358
.statfs = v9fs_statfs,
361359
.drop_inode = v9fs_drop_inode,
362360
.evict_inode = v9fs_evict_inode,
363-
.show_options = generic_show_options,
361+
.show_options = v9fs_show_options,
364362
.umount_begin = v9fs_umount_begin,
365363
.write_inode = v9fs_write_inode_dotl,
366364
};

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;

fs/afs/super.c

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ static void afs_kill_super(struct super_block *sb);
3737
static struct inode *afs_alloc_inode(struct super_block *sb);
3838
static void afs_destroy_inode(struct inode *inode);
3939
static int afs_statfs(struct dentry *dentry, struct kstatfs *buf);
40+
static int afs_show_devname(struct seq_file *m, struct dentry *root);
41+
static int afs_show_options(struct seq_file *m, struct dentry *root);
4042

4143
struct file_system_type afs_fs_type = {
4244
.owner = THIS_MODULE,
@@ -53,7 +55,8 @@ static const struct super_operations afs_super_ops = {
5355
.drop_inode = afs_drop_inode,
5456
.destroy_inode = afs_destroy_inode,
5557
.evict_inode = afs_evict_inode,
56-
.show_options = generic_show_options,
58+
.show_devname = afs_show_devname,
59+
.show_options = afs_show_options,
5760
};
5861

5962
static struct kmem_cache *afs_inode_cachep;
@@ -135,6 +138,45 @@ void __exit afs_fs_exit(void)
135138
_leave("");
136139
}
137140

141+
/*
142+
* Display the mount device name in /proc/mounts.
143+
*/
144+
static int afs_show_devname(struct seq_file *m, struct dentry *root)
145+
{
146+
struct afs_super_info *as = root->d_sb->s_fs_info;
147+
struct afs_volume *volume = as->volume;
148+
struct afs_cell *cell = volume->cell;
149+
const char *suf = "";
150+
char pref = '%';
151+
152+
switch (volume->type) {
153+
case AFSVL_RWVOL:
154+
break;
155+
case AFSVL_ROVOL:
156+
pref = '#';
157+
if (volume->type_force)
158+
suf = ".readonly";
159+
break;
160+
case AFSVL_BACKVOL:
161+
pref = '#';
162+
suf = ".backup";
163+
break;
164+
}
165+
166+
seq_printf(m, "%c%s:%s%s", pref, cell->name, volume->vlocation->vldb.name, suf);
167+
return 0;
168+
}
169+
170+
/*
171+
* Display the mount options in /proc/mounts.
172+
*/
173+
static int afs_show_options(struct seq_file *m, struct dentry *root)
174+
{
175+
if (test_bit(AFS_VNODE_AUTOCELL, &AFS_FS_I(d_inode(root))->flags))
176+
seq_puts(m, "autocell");
177+
return 0;
178+
}
179+
138180
/*
139181
* parse the mount options
140182
* - this function has been shamelessly adapted from the ext3 fs which
@@ -427,7 +469,6 @@ static struct dentry *afs_mount(struct file_system_type *fs_type,
427469
deactivate_locked_super(sb);
428470
goto error;
429471
}
430-
save_mount_options(sb, new_opts);
431472
sb->s_flags |= MS_ACTIVE;
432473
} else {
433474
_debug("reuse");

0 commit comments

Comments
 (0)