Skip to content

Commit 4eb98b7

Browse files
committed
Merge tag 'vfs-6.13.mount.api' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull vfs mount api conversions from Christian Brauner: "Convert adfs, affs, befs, hfs, hfsplus, jfs, and hpfs to the new mount api" * tag 'vfs-6.13.mount.api' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: efs: fix the efs new mount api implementation ubifs: Convert ubifs to use the new mount API hpfs: convert hpfs to use the new mount api jfs: convert jfs to use the new mount api hfsplus: convert hfsplus to use the new mount api hfs: convert hfs to use the new mount api befs: convert befs to use the new mount api affs: convert affs to use the new mount api adfs: convert adfs to use the new mount api
2 parents 6ac81fd + 51ceeb1 commit 4eb98b7

File tree

12 files changed

+1346
-1432
lines changed

12 files changed

+1346
-1432
lines changed

fs/adfs/super.c

Lines changed: 95 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
*/
77
#include <linux/module.h>
88
#include <linux/init.h>
9-
#include <linux/parser.h>
9+
#include <linux/fs_parser.h>
10+
#include <linux/fs_context.h>
1011
#include <linux/mount.h>
1112
#include <linux/seq_file.h>
1213
#include <linux/slab.h>
@@ -115,87 +116,61 @@ static int adfs_show_options(struct seq_file *seq, struct dentry *root)
115116
return 0;
116117
}
117118

118-
enum {Opt_uid, Opt_gid, Opt_ownmask, Opt_othmask, Opt_ftsuffix, Opt_err};
119+
enum {Opt_uid, Opt_gid, Opt_ownmask, Opt_othmask, Opt_ftsuffix};
119120

120-
static const match_table_t tokens = {
121-
{Opt_uid, "uid=%u"},
122-
{Opt_gid, "gid=%u"},
123-
{Opt_ownmask, "ownmask=%o"},
124-
{Opt_othmask, "othmask=%o"},
125-
{Opt_ftsuffix, "ftsuffix=%u"},
126-
{Opt_err, NULL}
121+
static const struct fs_parameter_spec adfs_param_spec[] = {
122+
fsparam_uid ("uid", Opt_uid),
123+
fsparam_gid ("gid", Opt_gid),
124+
fsparam_u32oct ("ownmask", Opt_ownmask),
125+
fsparam_u32oct ("othmask", Opt_othmask),
126+
fsparam_u32 ("ftsuffix", Opt_ftsuffix),
127+
{}
127128
};
128129

129-
static int parse_options(struct super_block *sb, struct adfs_sb_info *asb,
130-
char *options)
130+
static int adfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
131131
{
132-
char *p;
133-
int option;
134-
135-
if (!options)
136-
return 0;
137-
138-
while ((p = strsep(&options, ",")) != NULL) {
139-
substring_t args[MAX_OPT_ARGS];
140-
int token;
141-
if (!*p)
142-
continue;
143-
144-
token = match_token(p, tokens, args);
145-
switch (token) {
146-
case Opt_uid:
147-
if (match_int(args, &option))
148-
return -EINVAL;
149-
asb->s_uid = make_kuid(current_user_ns(), option);
150-
if (!uid_valid(asb->s_uid))
151-
return -EINVAL;
152-
break;
153-
case Opt_gid:
154-
if (match_int(args, &option))
155-
return -EINVAL;
156-
asb->s_gid = make_kgid(current_user_ns(), option);
157-
if (!gid_valid(asb->s_gid))
158-
return -EINVAL;
159-
break;
160-
case Opt_ownmask:
161-
if (match_octal(args, &option))
162-
return -EINVAL;
163-
asb->s_owner_mask = option;
164-
break;
165-
case Opt_othmask:
166-
if (match_octal(args, &option))
167-
return -EINVAL;
168-
asb->s_other_mask = option;
169-
break;
170-
case Opt_ftsuffix:
171-
if (match_int(args, &option))
172-
return -EINVAL;
173-
asb->s_ftsuffix = option;
174-
break;
175-
default:
176-
adfs_msg(sb, KERN_ERR,
177-
"unrecognised mount option \"%s\" or missing value",
178-
p);
179-
return -EINVAL;
180-
}
132+
struct adfs_sb_info *asb = fc->s_fs_info;
133+
struct fs_parse_result result;
134+
int opt;
135+
136+
opt = fs_parse(fc, adfs_param_spec, param, &result);
137+
if (opt < 0)
138+
return opt;
139+
140+
switch (opt) {
141+
case Opt_uid:
142+
asb->s_uid = result.uid;
143+
break;
144+
case Opt_gid:
145+
asb->s_gid = result.gid;
146+
break;
147+
case Opt_ownmask:
148+
asb->s_owner_mask = result.uint_32;
149+
break;
150+
case Opt_othmask:
151+
asb->s_other_mask = result.uint_32;
152+
break;
153+
case Opt_ftsuffix:
154+
asb->s_ftsuffix = result.uint_32;
155+
break;
156+
default:
157+
return -EINVAL;
181158
}
182159
return 0;
183160
}
184161

185-
static int adfs_remount(struct super_block *sb, int *flags, char *data)
162+
static int adfs_reconfigure(struct fs_context *fc)
186163
{
187-
struct adfs_sb_info temp_asb;
188-
int ret;
164+
struct adfs_sb_info *new_asb = fc->s_fs_info;
165+
struct adfs_sb_info *asb = ADFS_SB(fc->root->d_sb);
189166

190-
sync_filesystem(sb);
191-
*flags |= ADFS_SB_FLAGS;
167+
sync_filesystem(fc->root->d_sb);
168+
fc->sb_flags |= ADFS_SB_FLAGS;
192169

193-
temp_asb = *ADFS_SB(sb);
194-
ret = parse_options(sb, &temp_asb, data);
195-
if (ret == 0)
196-
*ADFS_SB(sb) = temp_asb;
170+
/* Structure copy newly parsed options */
171+
*asb = *new_asb;
197172

198-
return ret;
173+
return 0;
199174
}
200175

201176
static int adfs_statfs(struct dentry *dentry, struct kstatfs *buf)
@@ -273,7 +248,6 @@ static const struct super_operations adfs_sops = {
273248
.write_inode = adfs_write_inode,
274249
.put_super = adfs_put_super,
275250
.statfs = adfs_statfs,
276-
.remount_fs = adfs_remount,
277251
.show_options = adfs_show_options,
278252
};
279253

@@ -361,34 +335,21 @@ static int adfs_validate_dr0(struct super_block *sb, struct buffer_head *bh,
361335
return 0;
362336
}
363337

364-
static int adfs_fill_super(struct super_block *sb, void *data, int silent)
338+
static int adfs_fill_super(struct super_block *sb, struct fs_context *fc)
365339
{
366340
struct adfs_discrecord *dr;
367341
struct object_info root_obj;
368-
struct adfs_sb_info *asb;
342+
struct adfs_sb_info *asb = sb->s_fs_info;
369343
struct inode *root;
370344
int ret = -EINVAL;
345+
int silent = fc->sb_flags & SB_SILENT;
371346

372347
sb->s_flags |= ADFS_SB_FLAGS;
373348

374-
asb = kzalloc(sizeof(*asb), GFP_KERNEL);
375-
if (!asb)
376-
return -ENOMEM;
377-
378349
sb->s_fs_info = asb;
379350
sb->s_magic = ADFS_SUPER_MAGIC;
380351
sb->s_time_gran = 10000000;
381352

382-
/* set default options */
383-
asb->s_uid = GLOBAL_ROOT_UID;
384-
asb->s_gid = GLOBAL_ROOT_GID;
385-
asb->s_owner_mask = ADFS_DEFAULT_OWNER_MASK;
386-
asb->s_other_mask = ADFS_DEFAULT_OTHER_MASK;
387-
asb->s_ftsuffix = 0;
388-
389-
if (parse_options(sb, asb, data))
390-
goto error;
391-
392353
/* Try to probe the filesystem boot block */
393354
ret = adfs_probe(sb, ADFS_DISCRECORD, 1, adfs_validate_bblk);
394355
if (ret == -EILSEQ)
@@ -453,18 +414,61 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
453414
return ret;
454415
}
455416

456-
static struct dentry *adfs_mount(struct file_system_type *fs_type,
457-
int flags, const char *dev_name, void *data)
417+
static int adfs_get_tree(struct fs_context *fc)
418+
{
419+
return get_tree_bdev(fc, adfs_fill_super);
420+
}
421+
422+
static void adfs_free_fc(struct fs_context *fc)
458423
{
459-
return mount_bdev(fs_type, flags, dev_name, data, adfs_fill_super);
424+
struct adfs_context *asb = fc->s_fs_info;
425+
426+
kfree(asb);
427+
}
428+
429+
static const struct fs_context_operations adfs_context_ops = {
430+
.parse_param = adfs_parse_param,
431+
.get_tree = adfs_get_tree,
432+
.reconfigure = adfs_reconfigure,
433+
.free = adfs_free_fc,
434+
};
435+
436+
static int adfs_init_fs_context(struct fs_context *fc)
437+
{
438+
struct adfs_sb_info *asb;
439+
440+
asb = kzalloc(sizeof(struct adfs_sb_info), GFP_KERNEL);
441+
if (!asb)
442+
return -ENOMEM;
443+
444+
if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) {
445+
struct super_block *sb = fc->root->d_sb;
446+
struct adfs_sb_info *old_asb = ADFS_SB(sb);
447+
448+
/* structure copy existing options before parsing */
449+
*asb = *old_asb;
450+
} else {
451+
/* set default options */
452+
asb->s_uid = GLOBAL_ROOT_UID;
453+
asb->s_gid = GLOBAL_ROOT_GID;
454+
asb->s_owner_mask = ADFS_DEFAULT_OWNER_MASK;
455+
asb->s_other_mask = ADFS_DEFAULT_OTHER_MASK;
456+
asb->s_ftsuffix = 0;
457+
}
458+
459+
fc->ops = &adfs_context_ops;
460+
fc->s_fs_info = asb;
461+
462+
return 0;
460463
}
461464

462465
static struct file_system_type adfs_fs_type = {
463466
.owner = THIS_MODULE,
464467
.name = "adfs",
465-
.mount = adfs_mount,
466468
.kill_sb = kill_block_super,
467469
.fs_flags = FS_REQUIRES_DEV,
470+
.init_fs_context = adfs_init_fs_context,
471+
.parameters = adfs_param_spec,
468472
};
469473
MODULE_ALIAS_FS("adfs");
470474

0 commit comments

Comments
 (0)