Skip to content

Commit

Permalink
fs_parse: fold fs_parameter_desc/fs_parameter_spec
Browse files Browse the repository at this point in the history
The former contains nothing but a pointer to an array of the latter...

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Feb 7, 2020
1 parent 96cafb9 commit d7167b1
Show file tree
Hide file tree
Showing 29 changed files with 106 additions and 198 deletions.
10 changes: 3 additions & 7 deletions arch/powerpc/platforms/cell/spufs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,18 +583,14 @@ enum {
Opt_uid, Opt_gid, Opt_mode, Opt_debug,
};

static const struct fs_parameter_spec spufs_param_specs[] = {
static const struct fs_parameter_spec spufs_fs_parameters[] = {
fsparam_u32 ("gid", Opt_gid),
fsparam_u32oct ("mode", Opt_mode),
fsparam_u32 ("uid", Opt_uid),
fsparam_flag ("debug", Opt_debug),
{}
};

static const struct fs_parameter_description spufs_fs_parameters = {
.specs = spufs_param_specs,
};

static int spufs_show_options(struct seq_file *m, struct dentry *root)
{
struct spufs_sb_info *sbi = spufs_get_sb_info(root->d_sb);
Expand Down Expand Up @@ -622,7 +618,7 @@ static int spufs_parse_param(struct fs_context *fc, struct fs_parameter *param)
kgid_t gid;
int opt;

opt = fs_parse(fc, &spufs_fs_parameters, param, &result);
opt = fs_parse(fc, spufs_fs_parameters, param, &result);
if (opt < 0)
return opt;

Expand Down Expand Up @@ -773,7 +769,7 @@ static struct file_system_type spufs_type = {
.owner = THIS_MODULE,
.name = "spufs",
.init_fs_context = spufs_init_fs_context,
.parameters = &spufs_fs_parameters,
.parameters = spufs_fs_parameters,
.kill_sb = kill_litter_super,
};
MODULE_ALIAS_FS("spufs");
Expand Down
10 changes: 3 additions & 7 deletions arch/s390/hypfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,12 @@ static int hypfs_release(struct inode *inode, struct file *filp)

enum { Opt_uid, Opt_gid, };

static const struct fs_parameter_spec hypfs_param_specs[] = {
static const struct fs_parameter_spec hypfs_fs_parameters[] = {
fsparam_u32("gid", Opt_gid),
fsparam_u32("uid", Opt_uid),
{}
};

static const struct fs_parameter_description hypfs_fs_parameters = {
.specs = hypfs_param_specs,
};

static int hypfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
{
struct hypfs_sb_info *hypfs_info = fc->s_fs_info;
Expand All @@ -227,7 +223,7 @@ static int hypfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
kgid_t gid;
int opt;

opt = fs_parse(fc, &hypfs_fs_parameters, param, &result);
opt = fs_parse(fc, hypfs_fs_parameters, param, &result);
if (opt < 0)
return opt;

Expand Down Expand Up @@ -454,7 +450,7 @@ static struct file_system_type hypfs_type = {
.owner = THIS_MODULE,
.name = "s390_hypfs",
.init_fs_context = hypfs_init_fs_context,
.parameters = &hypfs_fs_parameters,
.parameters = hypfs_fs_parameters,
.kill_sb = hypfs_kill_super
};

Expand Down
10 changes: 3 additions & 7 deletions arch/x86/kernel/cpu/resctrl/rdtgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -2037,24 +2037,20 @@ enum rdt_param {
nr__rdt_params
};

static const struct fs_parameter_spec rdt_param_specs[] = {
static const struct fs_parameter_spec rdt_fs_parameters[] = {
fsparam_flag("cdp", Opt_cdp),
fsparam_flag("cdpl2", Opt_cdpl2),
fsparam_flag("mba_MBps", Opt_mba_mbps),
{}
};

static const struct fs_parameter_description rdt_fs_parameters = {
.specs = rdt_param_specs,
};

static int rdt_parse_param(struct fs_context *fc, struct fs_parameter *param)
{
struct rdt_fs_context *ctx = rdt_fc2context(fc);
struct fs_parse_result result;
int opt;

opt = fs_parse(fc, &rdt_fs_parameters, param, &result);
opt = fs_parse(fc, rdt_fs_parameters, param, &result);
if (opt < 0)
return opt;

Expand Down Expand Up @@ -2279,7 +2275,7 @@ static void rdt_kill_sb(struct super_block *sb)
static struct file_system_type rdt_fs_type = {
.name = "resctrl",
.init_fs_context = rdt_init_fs_context,
.parameters = &rdt_fs_parameters,
.parameters = rdt_fs_parameters,
.kill_sb = rdt_kill_sb,
};

Expand Down
4 changes: 2 additions & 2 deletions drivers/base/devtmpfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ static struct file_system_type internal_fs_type = {
.name = "devtmpfs",
#ifdef CONFIG_TMPFS
.init_fs_context = shmem_init_fs_context,
.parameters = &shmem_fs_parameters,
.parameters = shmem_fs_parameters,
#else
.init_fs_context = ramfs_init_fs_context,
.parameters = &ramfs_fs_parameters,
.parameters = ramfs_fs_parameters,
#endif
.kill_sb = kill_litter_super,
};
Expand Down
8 changes: 2 additions & 6 deletions drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ enum {
Opt_notrim,
};

static const struct fs_parameter_spec rbd_param_specs[] = {
static const struct fs_parameter_spec rbd_parameters[] = {
fsparam_u32 ("alloc_size", Opt_alloc_size),
fsparam_flag ("exclusive", Opt_exclusive),
fsparam_flag ("lock_on_read", Opt_lock_on_read),
Expand All @@ -863,10 +863,6 @@ static const struct fs_parameter_spec rbd_param_specs[] = {
{}
};

static const struct fs_parameter_description rbd_parameters = {
.specs = rbd_param_specs,
};

struct rbd_options {
int queue_depth;
int alloc_size;
Expand Down Expand Up @@ -6359,7 +6355,7 @@ static int rbd_parse_param(struct fs_parameter *param,
if (ret != -ENOPARAM)
return ret;

token = __fs_parse(&log, &rbd_parameters, param, &result);
token = __fs_parse(&log, rbd_parameters, param, &result);
dout("%s fs_parse '%s' token %d\n", __func__, param->key, token);
if (token < 0) {
if (token == -ENOPARAM)
Expand Down
10 changes: 3 additions & 7 deletions drivers/usb/gadget/function/f_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ enum {
Opt_gid,
};

static const struct fs_parameter_spec ffs_fs_param_specs[] = {
static const struct fs_parameter_spec ffs_fs_fs_parameters[] = {
fsparam_bool ("no_disconnect", Opt_no_disconnect),
fsparam_u32 ("rmode", Opt_rmode),
fsparam_u32 ("fmode", Opt_fmode),
Expand All @@ -1496,10 +1496,6 @@ static const struct fs_parameter_spec ffs_fs_param_specs[] = {
{}
};

static const struct fs_parameter_description ffs_fs_fs_parameters = {
.specs = ffs_fs_param_specs,
};

static int ffs_fs_parse_param(struct fs_context *fc, struct fs_parameter *param)
{
struct ffs_sb_fill_data *data = fc->fs_private;
Expand All @@ -1508,7 +1504,7 @@ static int ffs_fs_parse_param(struct fs_context *fc, struct fs_parameter *param)

ENTER();

opt = fs_parse(fc, &ffs_fs_fs_parameters, param, &result);
opt = fs_parse(fc, ffs_fs_fs_parameters, param, &result);
if (opt < 0)
return opt;

Expand Down Expand Up @@ -1640,7 +1636,7 @@ static struct file_system_type ffs_fs_type = {
.owner = THIS_MODULE,
.name = "functionfs",
.init_fs_context = ffs_fs_init_fs_context,
.parameters = &ffs_fs_fs_parameters,
.parameters = ffs_fs_fs_parameters,
.kill_sb = ffs_fs_kill_sb,
};
MODULE_ALIAS_FS("functionfs");
Expand Down
12 changes: 4 additions & 8 deletions fs/afs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ static int afs_statfs(struct dentry *dentry, struct kstatfs *buf);
static int afs_show_devname(struct seq_file *m, struct dentry *root);
static int afs_show_options(struct seq_file *m, struct dentry *root);
static int afs_init_fs_context(struct fs_context *fc);
static const struct fs_parameter_description afs_fs_parameters;
static const struct fs_parameter_spec afs_fs_parameters[];

struct file_system_type afs_fs_type = {
.owner = THIS_MODULE,
.name = "afs",
.init_fs_context = afs_init_fs_context,
.parameters = &afs_fs_parameters,
.parameters = afs_fs_parameters,
.kill_sb = afs_kill_super,
.fs_flags = FS_RENAME_DOES_D_MOVE,
};
Expand Down Expand Up @@ -81,18 +81,14 @@ static const struct constant_table afs_param_flock[] = {
{}
};

static const struct fs_parameter_spec afs_param_specs[] = {
static const struct fs_parameter_spec afs_fs_parameters[] = {
fsparam_flag ("autocell", Opt_autocell),
fsparam_flag ("dyn", Opt_dyn),
fsparam_enum ("flock", Opt_flock, afs_param_flock),
fsparam_string("source", Opt_source),
{}
};

static const struct fs_parameter_description afs_fs_parameters = {
.specs = afs_param_specs,
};

/*
* initialise the filesystem
*/
Expand Down Expand Up @@ -321,7 +317,7 @@ static int afs_parse_param(struct fs_context *fc, struct fs_parameter *param)
struct afs_fs_context *ctx = fc->fs_private;
int opt;

opt = fs_parse(fc, &afs_fs_parameters, param, &result);
opt = fs_parse(fc, afs_fs_parameters, param, &result);
if (opt < 0)
return opt;

Expand Down
8 changes: 2 additions & 6 deletions fs/ceph/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static const struct constant_table ceph_param_recover[] = {
{}
};

static const struct fs_parameter_spec ceph_mount_param_specs[] = {
static const struct fs_parameter_spec ceph_mount_parameters[] = {
fsparam_flag_no ("acl", Opt_acl),
fsparam_flag_no ("asyncreaddir", Opt_asyncreaddir),
fsparam_s32 ("caps_max", Opt_caps_max),
Expand Down Expand Up @@ -198,10 +198,6 @@ static const struct fs_parameter_spec ceph_mount_param_specs[] = {
{}
};

static const struct fs_parameter_description ceph_mount_parameters = {
.specs = ceph_mount_param_specs,
};

struct ceph_parse_opts_ctx {
struct ceph_options *copts;
struct ceph_mount_options *opts;
Expand Down Expand Up @@ -271,7 +267,7 @@ static int ceph_parse_mount_param(struct fs_context *fc,
if (ret != -ENOPARAM)
return ret;

token = fs_parse(fc, &ceph_mount_parameters, param, &result);
token = fs_parse(fc, ceph_mount_parameters, param, &result);
dout("%s fs_parse '%s' token %d\n", __func__, param->key, token);
if (token < 0)
return token;
Expand Down
53 changes: 25 additions & 28 deletions fs/fs_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,14 @@ int lookup_constant(const struct constant_table *tbl, const char *name, int not_
EXPORT_SYMBOL(lookup_constant);

static const struct fs_parameter_spec *fs_lookup_key(
const struct fs_parameter_description *desc,
const struct fs_parameter_spec *desc,
const char *name)
{
const struct fs_parameter_spec *p;

if (!desc->specs)
if (!desc)
return NULL;

for (p = desc->specs; p->name; p++)
for (p = desc; p->name; p++)
if (strcmp(p->name, name) == 0)
return p;

Expand All @@ -81,7 +80,7 @@ static const struct fs_parameter_spec *fs_lookup_key(
* the parameter wasn't recognised and unknowns aren't okay.
*/
int __fs_parse(struct p_log *log,
const struct fs_parameter_description *desc,
const struct fs_parameter_spec *desc,
struct fs_parameter *param,
struct fs_parse_result *result)
{
Expand Down Expand Up @@ -355,39 +354,37 @@ bool validate_constant_table(const struct constant_table *tbl, size_t tbl_size,
* @desc: The parameter description to validate.
*/
bool fs_validate_description(const char *name,
const struct fs_parameter_description *desc)
const struct fs_parameter_spec *desc)
{
const struct fs_parameter_spec *param, *p2;
bool good = true;

pr_notice("*** VALIDATE %s ***\n", name);

if (desc->specs) {
for (param = desc->specs; param->name; param++) {
enum fs_parameter_type t = param->type;
for (param = desc; param->name; param++) {
enum fs_parameter_type t = param->type;

/* Check that the type is in range */
if (t == __fs_param_wasnt_defined ||
t >= nr__fs_parameter_type) {
pr_err("VALIDATE %s: PARAM[%s] Bad type %u\n",
name, param->name, t);
/* Check that the type is in range */
if (t == __fs_param_wasnt_defined ||
t >= nr__fs_parameter_type) {
pr_err("VALIDATE %s: PARAM[%s] Bad type %u\n",
name, param->name, t);
good = false;
} else if (t == fs_param_is_enum) {
const struct constant_table *e = param->data;
if (!e || !e->name) {
pr_err("VALIDATE %s: PARAM[%s] enum with no values\n",
name, param->name);
good = false;
} else if (t == fs_param_is_enum) {
const struct constant_table *e = param->data;
if (!e || !e->name) {
pr_err("VALIDATE %s: PARAM[%s] enum with no values\n",
name, param->name);
good = false;
}
}
}

/* Check for duplicate parameter names */
for (p2 = desc->specs; p2 < param; p2++) {
if (strcmp(param->name, p2->name) == 0) {
pr_err("VALIDATE %s: PARAM[%s]: Duplicate\n",
name, param->name);
good = false;
}
/* Check for duplicate parameter names */
for (p2 = desc; p2 < param; p2++) {
if (strcmp(param->name, p2->name) == 0) {
pr_err("VALIDATE %s: PARAM[%s]: Duplicate\n",
name, param->name);
good = false;
}
}
}
Expand Down
12 changes: 4 additions & 8 deletions fs/fuse/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ enum {
OPT_ERR
};

static const struct fs_parameter_spec fuse_param_specs[] = {
static const struct fs_parameter_spec fuse_fs_parameters[] = {
fsparam_string ("source", OPT_SOURCE),
fsparam_u32 ("fd", OPT_FD),
fsparam_u32oct ("rootmode", OPT_ROOTMODE),
Expand All @@ -462,17 +462,13 @@ static const struct fs_parameter_spec fuse_param_specs[] = {
{}
};

static const struct fs_parameter_description fuse_fs_parameters = {
.specs = fuse_param_specs,
};

static int fuse_parse_param(struct fs_context *fc, struct fs_parameter *param)
{
struct fs_parse_result result;
struct fuse_fs_context *ctx = fc->fs_private;
int opt;

opt = fs_parse(fc, &fuse_fs_parameters, param, &result);
opt = fs_parse(fc, fuse_fs_parameters, param, &result);
if (opt < 0)
return opt;

Expand Down Expand Up @@ -1346,7 +1342,7 @@ static struct file_system_type fuse_fs_type = {
.name = "fuse",
.fs_flags = FS_HAS_SUBTYPE | FS_USERNS_MOUNT,
.init_fs_context = fuse_init_fs_context,
.parameters = &fuse_fs_parameters,
.parameters = fuse_fs_parameters,
.kill_sb = fuse_kill_sb_anon,
};
MODULE_ALIAS_FS("fuse");
Expand All @@ -1362,7 +1358,7 @@ static struct file_system_type fuseblk_fs_type = {
.owner = THIS_MODULE,
.name = "fuseblk",
.init_fs_context = fuse_init_fs_context,
.parameters = &fuse_fs_parameters,
.parameters = fuse_fs_parameters,
.kill_sb = fuse_kill_sb_blk,
.fs_flags = FS_REQUIRES_DEV | FS_HAS_SUBTYPE,
};
Expand Down
Loading

0 comments on commit d7167b1

Please sign in to comment.