diff options
author | David Howells <dhowells@redhat.com> | 2017-07-05 11:25:37 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-07-11 06:08:58 -0400 |
commit | c4fac9100456995c10b65c13be84554258ed7fc8 (patch) | |
tree | ea395c955dfac2337eff1a4608caea5f3a26701b /fs/9p | |
parent | 86a1da6d30ad727c2a9cc5d6a51bff6d830036b5 (diff) |
9p: Implement show_options
Implement the show_options superblock op for 9p 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>
cc: Eric Van Hensbergen <ericvh@gmail.com>
cc: Ron Minnich <rminnich@sandia.gov>
cc: Latchesar Ionkov <lucho@ionkov.net>
cc: v9fs-developer@lists.sourceforge.net
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/9p')
-rw-r--r-- | fs/9p/v9fs.c | 61 | ||||
-rw-r--r-- | fs/9p/v9fs.h | 3 | ||||
-rw-r--r-- | fs/9p/vfs_super.c | 6 |
3 files changed, 66 insertions, 4 deletions
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index c202930086ed..8fb89ddc6cc7 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/parser.h> | 33 | #include <linux/parser.h> |
34 | #include <linux/idr.h> | 34 | #include <linux/idr.h> |
35 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
36 | #include <linux/seq_file.h> | ||
36 | #include <net/9p/9p.h> | 37 | #include <net/9p/9p.h> |
37 | #include <net/9p/client.h> | 38 | #include <net/9p/client.h> |
38 | #include <net/9p/transport.h> | 39 | #include <net/9p/transport.h> |
@@ -82,6 +83,13 @@ static const match_table_t tokens = { | |||
82 | {Opt_err, NULL} | 83 | {Opt_err, NULL} |
83 | }; | 84 | }; |
84 | 85 | ||
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 | |||
85 | /* Interpret mount options for cache mode */ | 93 | /* Interpret mount options for cache mode */ |
86 | static int get_cache_mode(char *s) | 94 | static int get_cache_mode(char *s) |
87 | { | 95 | { |
@@ -104,6 +112,58 @@ static int get_cache_mode(char *s) | |||
104 | return version; | 112 | return version; |
105 | } | 113 | } |
106 | 114 | ||
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 | |||
107 | /** | 167 | /** |
108 | * v9fs_parse_options - parse mount options into session structure | 168 | * v9fs_parse_options - parse mount options into session structure |
109 | * @v9ses: existing v9fs session information | 169 | * @v9ses: existing v9fs session information |
@@ -230,6 +290,7 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) | |||
230 | break; | 290 | break; |
231 | case Opt_cachetag: | 291 | case Opt_cachetag: |
232 | #ifdef CONFIG_9P_FSCACHE | 292 | #ifdef CONFIG_9P_FSCACHE |
293 | kfree(v9ses->cachetag); | ||
233 | v9ses->cachetag = match_strdup(&args[0]); | 294 | v9ses->cachetag = match_strdup(&args[0]); |
234 | #endif | 295 | #endif |
235 | break; | 296 | break; |
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h index 76eaf49abd3a..982e017acadb 100644 --- a/fs/9p/v9fs.h +++ b/fs/9p/v9fs.h | |||
@@ -67,6 +67,7 @@ enum p9_cache_modes { | |||
67 | CACHE_MMAP, | 67 | CACHE_MMAP, |
68 | CACHE_LOOSE, | 68 | CACHE_LOOSE, |
69 | CACHE_FSCACHE, | 69 | CACHE_FSCACHE, |
70 | nr__p9_cache_modes | ||
70 | }; | 71 | }; |
71 | 72 | ||
72 | /** | 73 | /** |
@@ -137,6 +138,8 @@ static inline struct v9fs_inode *V9FS_I(const struct inode *inode) | |||
137 | return container_of(inode, struct v9fs_inode, vfs_inode); | 138 | return container_of(inode, struct v9fs_inode, vfs_inode); |
138 | } | 139 | } |
139 | 140 | ||
141 | extern int v9fs_show_options(struct seq_file *m, struct dentry *root); | ||
142 | |||
140 | struct p9_fid *v9fs_session_init(struct v9fs_session_info *, const char *, | 143 | struct p9_fid *v9fs_session_init(struct v9fs_session_info *, const char *, |
141 | char *); | 144 | char *); |
142 | extern void v9fs_session_close(struct v9fs_session_info *v9ses); | 145 | extern void v9fs_session_close(struct v9fs_session_info *v9ses); |
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index a0965fb587a5..8b75463cb211 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <linux/string.h> | 33 | #include <linux/string.h> |
34 | #include <linux/inet.h> | 34 | #include <linux/inet.h> |
35 | #include <linux/pagemap.h> | 35 | #include <linux/pagemap.h> |
36 | #include <linux/seq_file.h> | ||
37 | #include <linux/mount.h> | 36 | #include <linux/mount.h> |
38 | #include <linux/idr.h> | 37 | #include <linux/idr.h> |
39 | #include <linux/sched.h> | 38 | #include <linux/sched.h> |
@@ -104,7 +103,6 @@ v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses, | |||
104 | sb->s_flags |= MS_POSIXACL; | 103 | sb->s_flags |= MS_POSIXACL; |
105 | #endif | 104 | #endif |
106 | 105 | ||
107 | save_mount_options(sb, data); | ||
108 | return 0; | 106 | return 0; |
109 | } | 107 | } |
110 | 108 | ||
@@ -349,7 +347,7 @@ static const struct super_operations v9fs_super_ops = { | |||
349 | .destroy_inode = v9fs_destroy_inode, | 347 | .destroy_inode = v9fs_destroy_inode, |
350 | .statfs = simple_statfs, | 348 | .statfs = simple_statfs, |
351 | .evict_inode = v9fs_evict_inode, | 349 | .evict_inode = v9fs_evict_inode, |
352 | .show_options = generic_show_options, | 350 | .show_options = v9fs_show_options, |
353 | .umount_begin = v9fs_umount_begin, | 351 | .umount_begin = v9fs_umount_begin, |
354 | .write_inode = v9fs_write_inode, | 352 | .write_inode = v9fs_write_inode, |
355 | }; | 353 | }; |
@@ -360,7 +358,7 @@ static const struct super_operations v9fs_super_ops_dotl = { | |||
360 | .statfs = v9fs_statfs, | 358 | .statfs = v9fs_statfs, |
361 | .drop_inode = v9fs_drop_inode, | 359 | .drop_inode = v9fs_drop_inode, |
362 | .evict_inode = v9fs_evict_inode, | 360 | .evict_inode = v9fs_evict_inode, |
363 | .show_options = generic_show_options, | 361 | .show_options = v9fs_show_options, |
364 | .umount_begin = v9fs_umount_begin, | 362 | .umount_begin = v9fs_umount_begin, |
365 | .write_inode = v9fs_write_inode_dotl, | 363 | .write_inode = v9fs_write_inode_dotl, |
366 | }; | 364 | }; |