From 0f89589a8c6f1033cb847a606517998efb0da8ee Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 17 Dec 2019 14:15:04 -0500 Subject: Pass consistent param->type to fs_parse() As it is, vfs_parse_fs_string() makes "foo" and "foo=" indistinguishable; both get fs_value_is_string for ->type and NULL for ->string. To make it even more unpleasant, that combination is impossible to produce with fsconfig(). Much saner rules would be "foo" => fs_value_is_flag, NULL "foo=" => fs_value_is_string, "" "foo=bar" => fs_value_is_string, "bar" All cases are distinguishable, all results are expressable by fsconfig(), ->has_value checks are much simpler that way (to the point of the field being useless) and quite a few regressions go away (gfs2 has no business accepting -o nodebug=, for example). Partially based upon patches from Miklos. Signed-off-by: Al Viro --- include/linux/fs_parser.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/linux') diff --git a/include/linux/fs_parser.h b/include/linux/fs_parser.h index dee140db6240..45323203128b 100644 --- a/include/linux/fs_parser.h +++ b/include/linux/fs_parser.h @@ -72,7 +72,6 @@ struct fs_parameter_description { */ struct fs_parse_result { bool negated; /* T if param was "noxxx" */ - bool has_value; /* T if value supplied to param */ union { bool boolean; /* For spec_bool */ int int_32; /* For spec_s32/spec_enum */ -- cgit From 2710c957a8ef4fb00f21acb306e3bd6bcf80c81f Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 6 Sep 2019 22:12:08 -0400 Subject: fs_parse: get rid of ->enums Don't do a single array; attach them to fsparam_enum() entry instead. And don't bother trying to embed the names into those - it actually loses memory, with no real speedup worth mentioning. Simplifies validation as well. Signed-off-by: Al Viro --- include/linux/fs_parser.h | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'include/linux') diff --git a/include/linux/fs_parser.h b/include/linux/fs_parser.h index 45323203128b..498cba1bbf6e 100644 --- a/include/linux/fs_parser.h +++ b/include/linux/fs_parser.h @@ -53,18 +53,17 @@ struct fs_parameter_spec { #define fs_param_neg_with_no 0x0002 /* "noxxx" is negative param */ #define fs_param_neg_with_empty 0x0004 /* "xxx=" is negative param */ #define fs_param_deprecated 0x0008 /* The param is deprecated */ + const void *data; }; struct fs_parameter_enum { - u8 opt; /* Option number (as fs_parameter_spec::opt) */ - char name[14]; + const char *name; u8 value; }; struct fs_parameter_description { const char name[16]; /* Name for logging purposes */ const struct fs_parameter_spec *specs; /* List of param specifications */ - const struct fs_parameter_enum *enums; /* Enum values */ }; /* @@ -114,33 +113,34 @@ static inline bool fs_validate_description(const struct fs_parameter_description * work, but any such case is probably a sign that new helper is needed. * Helpers will remain stable; low-level implementation may change. */ -#define __fsparam(TYPE, NAME, OPT, FLAGS) \ +#define __fsparam(TYPE, NAME, OPT, FLAGS, DATA) \ { \ .name = NAME, \ .opt = OPT, \ .type = TYPE, \ - .flags = FLAGS \ + .flags = FLAGS, \ + .data = DATA \ } -#define fsparam_flag(NAME, OPT) __fsparam(fs_param_is_flag, NAME, OPT, 0) +#define fsparam_flag(NAME, OPT) __fsparam(fs_param_is_flag, NAME, OPT, 0, NULL) #define fsparam_flag_no(NAME, OPT) \ __fsparam(fs_param_is_flag, NAME, OPT, \ - fs_param_neg_with_no) -#define fsparam_bool(NAME, OPT) __fsparam(fs_param_is_bool, NAME, OPT, 0) -#define fsparam_u32(NAME, OPT) __fsparam(fs_param_is_u32, NAME, OPT, 0) + fs_param_neg_with_no, NULL) +#define fsparam_bool(NAME, OPT) __fsparam(fs_param_is_bool, NAME, OPT, 0, NULL) +#define fsparam_u32(NAME, OPT) __fsparam(fs_param_is_u32, NAME, OPT, 0, NULL) #define fsparam_u32oct(NAME, OPT) \ - __fsparam(fs_param_is_u32_octal, NAME, OPT, 0) + __fsparam(fs_param_is_u32_octal, NAME, OPT, 0, NULL) #define fsparam_u32hex(NAME, OPT) \ - __fsparam(fs_param_is_u32_hex, NAME, OPT, 0) -#define fsparam_s32(NAME, OPT) __fsparam(fs_param_is_s32, NAME, OPT, 0) -#define fsparam_u64(NAME, OPT) __fsparam(fs_param_is_u64, NAME, OPT, 0) -#define fsparam_enum(NAME, OPT) __fsparam(fs_param_is_enum, NAME, OPT, 0) + __fsparam(fs_param_is_u32_hex, NAME, OPT, 0, NULL) +#define fsparam_s32(NAME, OPT) __fsparam(fs_param_is_s32, NAME, OPT, 0, NULL) +#define fsparam_u64(NAME, OPT) __fsparam(fs_param_is_u64, NAME, OPT, 0, NULL) +#define fsparam_enum(NAME, OPT, array) __fsparam(fs_param_is_enum, NAME, OPT, 0, array) #define fsparam_string(NAME, OPT) \ - __fsparam(fs_param_is_string, NAME, OPT, 0) -#define fsparam_blob(NAME, OPT) __fsparam(fs_param_is_blob, NAME, OPT, 0) -#define fsparam_bdev(NAME, OPT) __fsparam(fs_param_is_blockdev, NAME, OPT, 0) -#define fsparam_path(NAME, OPT) __fsparam(fs_param_is_path, NAME, OPT, 0) -#define fsparam_fd(NAME, OPT) __fsparam(fs_param_is_fd, NAME, OPT, 0) + __fsparam(fs_param_is_string, NAME, OPT, 0, NULL) +#define fsparam_blob(NAME, OPT) __fsparam(fs_param_is_blob, NAME, OPT, 0, NULL) +#define fsparam_bdev(NAME, OPT) __fsparam(fs_param_is_blockdev, NAME, OPT, 0, NULL) +#define fsparam_path(NAME, OPT) __fsparam(fs_param_is_path, NAME, OPT, 0, NULL) +#define fsparam_fd(NAME, OPT) __fsparam(fs_param_is_fd, NAME, OPT, 0, NULL) #endif /* _LINUX_FS_PARSER_H */ -- cgit From 5eede625297f4d21dc12ea7a7418fd21672f131d Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 16 Dec 2019 13:33:32 -0500 Subject: fold struct fs_parameter_enum into struct constant_table no real difference now Signed-off-by: Al Viro --- include/linux/fs_parser.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'include/linux') diff --git a/include/linux/fs_parser.h b/include/linux/fs_parser.h index 498cba1bbf6e..5c91a0ac4446 100644 --- a/include/linux/fs_parser.h +++ b/include/linux/fs_parser.h @@ -56,11 +56,6 @@ struct fs_parameter_spec { const void *data; }; -struct fs_parameter_enum { - const char *name; - u8 value; -}; - struct fs_parameter_description { const char name[16]; /* Name for logging purposes */ const struct fs_parameter_spec *specs; /* List of param specifications */ -- cgit From 34264ae3fa22429ec4fd9151602342d1f21486eb Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 16 Dec 2019 13:45:41 -0500 Subject: don't bother with explicit length argument for __lookup_constant() Have the arrays of constant_table self-terminated (by NULL ->name in the final entry). Simplifies lookup_constant() and allows to reuse the search for enum params as well. Signed-off-by: Al Viro --- include/linux/fs_parser.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'include/linux') diff --git a/include/linux/fs_parser.h b/include/linux/fs_parser.h index 5c91a0ac4446..14bdaacf1218 100644 --- a/include/linux/fs_parser.h +++ b/include/linux/fs_parser.h @@ -83,9 +83,7 @@ extern int fs_lookup_param(struct fs_context *fc, bool want_bdev, struct path *_path); -extern int __lookup_constant(const struct constant_table tbl[], size_t tbl_size, - const char *name, int not_found); -#define lookup_constant(t, n, nf) __lookup_constant(t, ARRAY_SIZE(t), (n), (nf)) +extern int lookup_constant(const struct constant_table tbl[], const char *name, int not_found); #ifdef CONFIG_VALIDATE_FS_PARSER extern bool validate_constant_table(const struct constant_table *tbl, size_t tbl_size, -- cgit From aa1918f9491442a007a0cbe41a31539233209777 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 17 Dec 2019 20:09:08 -0500 Subject: get rid of fs_value_is_filename_empty Its behaviour is identical to that of fs_value_is_filename. It makes no sense, anyway - LOOKUP_EMPTY affects nothing whatsoever once the pathname has been imported from userland. And both fs_value_is_filename and fs_value_is_filename_empty carry an already imported pathname. Signed-off-by: Al Viro --- include/linux/fs_context.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/linux') diff --git a/include/linux/fs_context.h b/include/linux/fs_context.h index e5c14e2c53d3..c7c69640a6c6 100644 --- a/include/linux/fs_context.h +++ b/include/linux/fs_context.h @@ -54,7 +54,6 @@ enum fs_value_type { fs_value_is_string, /* Value is a string */ fs_value_is_blob, /* Value is a binary blob */ fs_value_is_filename, /* Value is a filename* + dirfd */ - fs_value_is_filename_empty, /* Value is a filename* + dirfd + AT_EMPTY_PATH */ fs_value_is_file, /* Value is a file* */ }; -- cgit From 9f09f649ca3350cdb49c81f7d5ac6e64a4d7e1a1 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 20 Dec 2019 22:10:36 -0500 Subject: teach logfc() to handle prefices, give it saner calling conventions Signed-off-by: Al Viro --- include/linux/fs_context.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'include/linux') diff --git a/include/linux/fs_context.h b/include/linux/fs_context.h index c7c69640a6c6..d18ff422e942 100644 --- a/include/linux/fs_context.h +++ b/include/linux/fs_context.h @@ -181,9 +181,13 @@ struct fc_log { char *buffer[8]; }; -extern __attribute__((format(printf, 2, 3))) -void logfc(struct fs_context *fc, const char *fmt, ...); +extern __attribute__((format(printf, 4, 5))) +void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt, ...); +#define __logfc(fc, l, fmt, ...) ({ \ + struct fs_context *__fc = (fc); \ + logfc(__fc ? __fc->log : NULL, NULL, \ + l, fmt, ## __VA_ARGS__);}) /** * infof - Store supplementary informational message * @fc: The context in which to log the informational message @@ -192,7 +196,7 @@ void logfc(struct fs_context *fc, const char *fmt, ...); * Store the supplementary informational message for the process if the process * has enabled the facility. */ -#define infof(fc, fmt, ...) ({ logfc(fc, "i "fmt, ## __VA_ARGS__); }) +#define infof(fc, fmt, ...) __logfc(fc, 'i', fmt, ## __VA_ARGS__) /** * warnf - Store supplementary warning message @@ -202,7 +206,7 @@ void logfc(struct fs_context *fc, const char *fmt, ...); * Store the supplementary warning message for the process if the process has * enabled the facility. */ -#define warnf(fc, fmt, ...) ({ logfc(fc, "w "fmt, ## __VA_ARGS__); }) +#define warnf(fc, fmt, ...) __logfc(fc, 'w', fmt, ## __VA_ARGS__) /** * errorf - Store supplementary error message @@ -212,7 +216,7 @@ void logfc(struct fs_context *fc, const char *fmt, ...); * Store the supplementary error message for the process if the process has * enabled the facility. */ -#define errorf(fc, fmt, ...) ({ logfc(fc, "e "fmt, ## __VA_ARGS__); }) +#define errorf(fc, fmt, ...) __logfc(fc, 'e', fmt, ## __VA_ARGS__) /** * invalf - Store supplementary invalid argument error message @@ -222,6 +226,6 @@ void logfc(struct fs_context *fc, const char *fmt, ...); * Store the supplementary error message for the process if the process has * enabled the facility and return -EINVAL. */ -#define invalf(fc, fmt, ...) ({ errorf(fc, fmt, ## __VA_ARGS__); -EINVAL; }) +#define invalf(fc, fmt, ...) (errorf(fc, fmt, ## __VA_ARGS__), -EINVAL) #endif /* _LINUX_FS_CONTEXT_H */ -- cgit From 3fbb8d5554a1481d9c5f54ee7dc59f416650efb1 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 20 Dec 2019 23:43:32 -0500 Subject: struct p_log, variants of warnf() et.al. taking that one instead primitives for prefixed logging Signed-off-by: Al Viro --- include/linux/fs_context.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include/linux') diff --git a/include/linux/fs_context.h b/include/linux/fs_context.h index d18ff422e942..6a7eeb252084 100644 --- a/include/linux/fs_context.h +++ b/include/linux/fs_context.h @@ -73,6 +73,11 @@ struct fs_parameter { int dirfd; }; +struct p_log { + const char *prefix; + struct fc_log *log; +}; + /* * Filesystem context for holding the parameters used in the creation or * reconfiguration of a superblock. @@ -188,6 +193,8 @@ void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt, struct fs_context *__fc = (fc); \ logfc(__fc ? __fc->log : NULL, NULL, \ l, fmt, ## __VA_ARGS__);}) +#define __plog(p, l, fmt, ...) logfc((p)->log, (p)->prefix, \ + l, fmt, ## __VA_ARGS__) /** * infof - Store supplementary informational message * @fc: The context in which to log the informational message @@ -197,6 +204,7 @@ void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt, * has enabled the facility. */ #define infof(fc, fmt, ...) __logfc(fc, 'i', fmt, ## __VA_ARGS__) +#define info_plog(p, fmt, ...) __plog(p, 'i', fmt, ## __VA_ARGS__) /** * warnf - Store supplementary warning message @@ -207,6 +215,7 @@ void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt, * enabled the facility. */ #define warnf(fc, fmt, ...) __logfc(fc, 'w', fmt, ## __VA_ARGS__) +#define warn_plog(p, fmt, ...) __plog(p, 'w', fmt, ## __VA_ARGS__) /** * errorf - Store supplementary error message @@ -217,6 +226,7 @@ void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt, * enabled the facility. */ #define errorf(fc, fmt, ...) __logfc(fc, 'e', fmt, ## __VA_ARGS__) +#define error_plog(p, fmt, ...) __plog(p, 'e', fmt, ## __VA_ARGS__) /** * invalf - Store supplementary invalid argument error message @@ -227,5 +237,6 @@ void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt, * enabled the facility and return -EINVAL. */ #define invalf(fc, fmt, ...) (errorf(fc, fmt, ## __VA_ARGS__), -EINVAL) +#define inval_plog(p, fmt, ...) (error_plog(p, fmt, ## __VA_ARGS__), -EINVAL) #endif /* _LINUX_FS_CONTEXT_H */ -- cgit From 7f5d38141e309bb4ba995d9726928af85a299c50 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 20 Dec 2019 23:52:55 -0500 Subject: new primitive: __fs_parse() fs_parse() analogue taking p_log instead of fs_context. fs_parse() turned into a wrapper, callers in ceph_common and rbd switched to __fs_parse(). As the result, fs_parse() never gets NULL fs_context and neither do fs_context-based logging primitives Signed-off-by: Al Viro --- include/linux/fs_context.h | 6 ++---- include/linux/fs_parser.h | 4 ++++ 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'include/linux') diff --git a/include/linux/fs_context.h b/include/linux/fs_context.h index 6a7eeb252084..41f37d33e358 100644 --- a/include/linux/fs_context.h +++ b/include/linux/fs_context.h @@ -189,10 +189,8 @@ struct fc_log { extern __attribute__((format(printf, 4, 5))) void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt, ...); -#define __logfc(fc, l, fmt, ...) ({ \ - struct fs_context *__fc = (fc); \ - logfc(__fc ? __fc->log : NULL, NULL, \ - l, fmt, ## __VA_ARGS__);}) +#define __logfc(fc, l, fmt, ...) logfc((fc)->log, NULL, \ + l, fmt, ## __VA_ARGS__) #define __plog(p, l, fmt, ...) logfc((p)->log, (p)->prefix, \ l, fmt, ## __VA_ARGS__) /** diff --git a/include/linux/fs_parser.h b/include/linux/fs_parser.h index 14bdaacf1218..b0fba26a4ffe 100644 --- a/include/linux/fs_parser.h +++ b/include/linux/fs_parser.h @@ -74,6 +74,10 @@ struct fs_parse_result { }; }; +extern int __fs_parse(struct p_log *log, + const struct fs_parameter_description *desc, + struct fs_parameter *value, + struct fs_parse_result *result); extern int fs_parse(struct fs_context *fc, const struct fs_parameter_description *desc, struct fs_parameter *value, -- cgit From c80c98f0dc5dc709b04254b5f30145c6ab8800a4 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 21 Dec 2019 00:06:01 -0500 Subject: ceph_parse_param(), ceph_parse_mon_ips(): switch to passing fc_log ... and now errorf() et.al. are never called with NULL fs_context, so we can get rid of conditional in those. Signed-off-by: Al Viro --- include/linux/ceph/libceph.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include/linux') diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h index 8fe9b80e80a5..ec73ebc4827d 100644 --- a/include/linux/ceph/libceph.h +++ b/include/linux/ceph/libceph.h @@ -281,11 +281,12 @@ extern int ceph_check_fsid(struct ceph_client *client, struct ceph_fsid *fsid); extern void *ceph_kvmalloc(size_t size, gfp_t flags); struct fs_parameter; +struct fc_log; struct ceph_options *ceph_alloc_options(void); int ceph_parse_mon_ips(const char *buf, size_t len, struct ceph_options *opt, - struct fs_context *fc); + struct fc_log *l); int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt, - struct fs_context *fc); + struct fc_log *l); int ceph_print_client_options(struct seq_file *m, struct ceph_client *client, bool show_all); extern void ceph_destroy_options(struct ceph_options *opt); -- cgit From cc3c0b533ab9142eac2e291628fbfca3685f38cd Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 21 Dec 2019 00:16:49 -0500 Subject: add prefix to fs_context->log ... turning it into struct p_log embedded into fs_context. Initialize the prefix with fs_type->name, turning fs_parse() into a trivial inline wrapper for __fs_parse(). This makes fs_parameter_description->name completely unused. Signed-off-by: Al Viro --- include/linux/fs_context.h | 4 ++-- include/linux/fs_parser.h | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'include/linux') diff --git a/include/linux/fs_context.h b/include/linux/fs_context.h index 41f37d33e358..b2ad9b0a7af4 100644 --- a/include/linux/fs_context.h +++ b/include/linux/fs_context.h @@ -97,7 +97,7 @@ struct fs_context { struct user_namespace *user_ns; /* The user namespace for this mount */ struct net *net_ns; /* The network namespace for this mount */ const struct cred *cred; /* The mounter's credentials */ - struct fc_log *log; /* Logging buffer */ + struct p_log log; /* Logging buffer */ const char *source; /* The source name (eg. dev path) */ void *security; /* Linux S&M options */ void *s_fs_info; /* Proposed s_fs_info */ @@ -189,7 +189,7 @@ struct fc_log { extern __attribute__((format(printf, 4, 5))) void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt, ...); -#define __logfc(fc, l, fmt, ...) logfc((fc)->log, NULL, \ +#define __logfc(fc, l, fmt, ...) logfc((fc)->log.log, NULL, \ l, fmt, ## __VA_ARGS__) #define __plog(p, l, fmt, ...) logfc((p)->log, (p)->prefix, \ l, fmt, ## __VA_ARGS__) diff --git a/include/linux/fs_parser.h b/include/linux/fs_parser.h index b0fba26a4ffe..37459124c1c1 100644 --- a/include/linux/fs_parser.h +++ b/include/linux/fs_parser.h @@ -78,10 +78,15 @@ extern int __fs_parse(struct p_log *log, const struct fs_parameter_description *desc, struct fs_parameter *value, struct fs_parse_result *result); -extern int fs_parse(struct fs_context *fc, - const struct fs_parameter_description *desc, - struct fs_parameter *value, - struct fs_parse_result *result); + +static inline int fs_parse(struct fs_context *fc, + const struct fs_parameter_description *desc, + struct fs_parameter *param, + struct fs_parse_result *result) +{ + return __fs_parse(&fc->log, desc, param, result); +} + extern int fs_lookup_param(struct fs_context *fc, struct fs_parameter *param, bool want_bdev, -- cgit From 96cafb9ccb153f6a82ff2c9bde68916d9d65501e Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Fri, 6 Dec 2019 10:45:01 -0600 Subject: fs_parser: remove fs_parameter_description name field Unused now. Signed-off-by: Eric Sandeen Acked-by: David Howells Signed-off-by: Al Viro --- include/linux/fs_parser.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include/linux') diff --git a/include/linux/fs_parser.h b/include/linux/fs_parser.h index 37459124c1c1..ac439ee50aab 100644 --- a/include/linux/fs_parser.h +++ b/include/linux/fs_parser.h @@ -57,7 +57,6 @@ struct fs_parameter_spec { }; struct fs_parameter_description { - const char name[16]; /* Name for logging purposes */ const struct fs_parameter_spec *specs; /* List of param specifications */ }; @@ -97,12 +96,14 @@ extern int lookup_constant(const struct constant_table tbl[], const char *name, #ifdef CONFIG_VALIDATE_FS_PARSER extern bool validate_constant_table(const struct constant_table *tbl, size_t tbl_size, int low, int high, int special); -extern bool fs_validate_description(const struct fs_parameter_description *desc); +extern bool fs_validate_description(const char *name, + const struct fs_parameter_description *desc); #else static inline bool validate_constant_table(const struct constant_table *tbl, size_t tbl_size, int low, int high, int special) { return true; } -static inline bool fs_validate_description(const struct fs_parameter_description *desc) +static inline bool fs_validate_description(const char *name, + const struct fs_parameter_description *desc) { return true; } #endif -- cgit From d7167b149943e38ad610191ecbb0800c78bbced9 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 7 Sep 2019 07:23:15 -0400 Subject: fs_parse: fold fs_parameter_desc/fs_parameter_spec The former contains nothing but a pointer to an array of the latter... Signed-off-by: Al Viro --- include/linux/fs.h | 4 ++-- include/linux/fs_parser.h | 12 ++++-------- include/linux/ramfs.h | 4 +++- include/linux/shmem_fs.h | 3 ++- 4 files changed, 11 insertions(+), 12 deletions(-) (limited to 'include/linux') diff --git a/include/linux/fs.h b/include/linux/fs.h index 98e0349adb52..5ace552a2a23 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -67,7 +67,7 @@ struct fscrypt_operations; struct fsverity_info; struct fsverity_operations; struct fs_context; -struct fs_parameter_description; +struct fs_parameter_spec; extern void __init inode_init(void); extern void __init inode_init_early(void); @@ -2224,7 +2224,7 @@ struct file_system_type { #define FS_DISALLOW_NOTIFY_PERM 16 /* Disable fanotify permission events */ #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */ int (*init_fs_context)(struct fs_context *); - const struct fs_parameter_description *parameters; + const struct fs_parameter_spec *parameters; struct dentry *(*mount) (struct file_system_type *, int, const char *, void *); void (*kill_sb) (struct super_block *); diff --git a/include/linux/fs_parser.h b/include/linux/fs_parser.h index ac439ee50aab..dcbac245e7a3 100644 --- a/include/linux/fs_parser.h +++ b/include/linux/fs_parser.h @@ -56,10 +56,6 @@ struct fs_parameter_spec { const void *data; }; -struct fs_parameter_description { - const struct fs_parameter_spec *specs; /* List of param specifications */ -}; - /* * Result of parse. */ @@ -74,12 +70,12 @@ struct fs_parse_result { }; extern int __fs_parse(struct p_log *log, - const struct fs_parameter_description *desc, + const struct fs_parameter_spec *desc, struct fs_parameter *value, struct fs_parse_result *result); static inline int fs_parse(struct fs_context *fc, - const struct fs_parameter_description *desc, + const struct fs_parameter_spec *desc, struct fs_parameter *param, struct fs_parse_result *result) { @@ -97,13 +93,13 @@ extern int lookup_constant(const struct constant_table tbl[], const char *name, extern bool validate_constant_table(const struct constant_table *tbl, size_t tbl_size, int low, int high, int special); extern bool fs_validate_description(const char *name, - const struct fs_parameter_description *desc); + const struct fs_parameter_spec *desc); #else static inline bool validate_constant_table(const struct constant_table *tbl, size_t tbl_size, int low, int high, int special) { return true; } static inline bool fs_validate_description(const char *name, - const struct fs_parameter_description *desc) + const struct fs_parameter_spec *desc) { return true; } #endif diff --git a/include/linux/ramfs.h b/include/linux/ramfs.h index b806a0ff6554..917528d102c4 100644 --- a/include/linux/ramfs.h +++ b/include/linux/ramfs.h @@ -2,6 +2,8 @@ #ifndef _LINUX_RAMFS_H #define _LINUX_RAMFS_H +#include // bleh... + struct inode *ramfs_get_inode(struct super_block *sb, const struct inode *dir, umode_t mode, dev_t dev); extern int ramfs_init_fs_context(struct fs_context *fc); @@ -16,7 +18,7 @@ ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize) extern int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize); #endif -extern const struct fs_parameter_description ramfs_fs_parameters; +extern const struct fs_parameter_spec ramfs_fs_parameters[]; extern const struct file_operations ramfs_file_operations; extern const struct vm_operations_struct generic_file_vm_ops; diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h index de8e4b71e3ba..d56fefef8905 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h @@ -8,6 +8,7 @@ #include #include #include +#include /* inode in-kernel data */ @@ -49,7 +50,7 @@ static inline struct shmem_inode_info *SHMEM_I(struct inode *inode) /* * Functions in mm/shmem.c called directly from elsewhere: */ -extern const struct fs_parameter_description shmem_fs_parameters; +extern const struct fs_parameter_spec shmem_fs_parameters[]; extern int shmem_init(void); extern int shmem_init_fs_context(struct fs_context *fc); extern struct file *shmem_file_setup(const char *name, -- cgit From 48ce73b1bef20331007b35de7ade8fe26cd55e84 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 17 Dec 2019 20:03:59 -0500 Subject: fs_parse: handle optional arguments sanely Don't bother with "mixed" options that would allow both the form with and without argument (i.e. both -o foo and -o foo=bar). Rather than trying to shove both into a single fs_parameter_spec, allow having with-argument and no-argument specs with the same name and teach fs_parse to handle that. There are very few options of that sort, and they are actually easier to handle that way - callers end up with less postprocessing. Signed-off-by: Al Viro --- include/linux/fs_parser.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/linux') diff --git a/include/linux/fs_parser.h b/include/linux/fs_parser.h index dcbac245e7a3..2e1e15f0cf4a 100644 --- a/include/linux/fs_parser.h +++ b/include/linux/fs_parser.h @@ -49,7 +49,6 @@ struct fs_parameter_spec { u8 opt; /* Option number (returned by fs_parse()) */ enum fs_parameter_type type:8; /* The desired parameter type */ unsigned short flags; -#define fs_param_v_optional 0x0001 /* The value is optional */ #define fs_param_neg_with_no 0x0002 /* "noxxx" is negative param */ #define fs_param_neg_with_empty 0x0004 /* "xxx=" is negative param */ #define fs_param_deprecated 0x0008 /* The param is deprecated */ -- cgit From 328de5287b10abc967c517461cf2948bd8a5b4e9 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 18 Dec 2019 00:02:31 -0500 Subject: turn fs_param_is_... into functions Signed-off-by: Al Viro --- include/linux/fs_parser.h | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) (limited to 'include/linux') diff --git a/include/linux/fs_parser.h b/include/linux/fs_parser.h index 2e1e15f0cf4a..2eab6d5f6736 100644 --- a/include/linux/fs_parser.h +++ b/include/linux/fs_parser.h @@ -17,26 +17,18 @@ struct constant_table { int value; }; +struct fs_parameter_spec; +struct fs_parse_result; +typedef int fs_param_type(struct p_log *, + const struct fs_parameter_spec *, + struct fs_parameter *, + struct fs_parse_result *); /* * The type of parameter expected. */ -enum fs_parameter_type { - __fs_param_wasnt_defined, - fs_param_is_flag, - fs_param_is_bool, - fs_param_is_u32, - fs_param_is_u32_octal, - fs_param_is_u32_hex, - fs_param_is_s32, - fs_param_is_u64, - fs_param_is_enum, - fs_param_is_string, - fs_param_is_blob, - fs_param_is_blockdev, - fs_param_is_path, - fs_param_is_fd, - nr__fs_parameter_type, -}; +fs_param_type fs_param_is_bool, fs_param_is_u32, fs_param_is_s32, fs_param_is_u64, + fs_param_is_enum, fs_param_is_string, fs_param_is_blob, fs_param_is_blockdev, + fs_param_is_path, fs_param_is_fd; /* * Specification of the type of value a parameter wants. @@ -46,8 +38,8 @@ enum fs_parameter_type { */ struct fs_parameter_spec { const char *name; + fs_param_type *type; /* The desired parameter type */ u8 opt; /* Option number (returned by fs_parse()) */ - enum fs_parameter_type type:8; /* The desired parameter type */ unsigned short flags; #define fs_param_neg_with_no 0x0002 /* "noxxx" is negative param */ #define fs_param_neg_with_empty 0x0004 /* "xxx=" is negative param */ @@ -120,16 +112,15 @@ static inline bool fs_validate_description(const char *name, .data = DATA \ } -#define fsparam_flag(NAME, OPT) __fsparam(fs_param_is_flag, NAME, OPT, 0, NULL) +#define fsparam_flag(NAME, OPT) __fsparam(NULL, NAME, OPT, 0, NULL) #define fsparam_flag_no(NAME, OPT) \ - __fsparam(fs_param_is_flag, NAME, OPT, \ - fs_param_neg_with_no, NULL) + __fsparam(NULL, NAME, OPT, fs_param_neg_with_no, NULL) #define fsparam_bool(NAME, OPT) __fsparam(fs_param_is_bool, NAME, OPT, 0, NULL) #define fsparam_u32(NAME, OPT) __fsparam(fs_param_is_u32, NAME, OPT, 0, NULL) #define fsparam_u32oct(NAME, OPT) \ - __fsparam(fs_param_is_u32_octal, NAME, OPT, 0, NULL) + __fsparam(fs_param_is_u32, NAME, OPT, 0, (void *)8) #define fsparam_u32hex(NAME, OPT) \ - __fsparam(fs_param_is_u32_hex, NAME, OPT, 0, NULL) + __fsparam(fs_param_is_u32_hex, NAME, OPT, 0, (void *16)) #define fsparam_s32(NAME, OPT) __fsparam(fs_param_is_s32, NAME, OPT, 0, NULL) #define fsparam_u64(NAME, OPT) __fsparam(fs_param_is_u64, NAME, OPT, 0, NULL) #define fsparam_enum(NAME, OPT, array) __fsparam(fs_param_is_enum, NAME, OPT, 0, array) @@ -140,5 +131,4 @@ static inline bool fs_validate_description(const char *name, #define fsparam_path(NAME, OPT) __fsparam(fs_param_is_path, NAME, OPT, 0, NULL) #define fsparam_fd(NAME, OPT) __fsparam(fs_param_is_fd, NAME, OPT, 0, NULL) - #endif /* _LINUX_FS_PARSER_H */ -- cgit From a3ff937b33d9dfd0923ac5279d87723048599057 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 21 Dec 2019 21:30:50 -0500 Subject: prefix-handling analogues of errorf() and friends called errorfc/infofc/warnfc/invalfc Signed-off-by: Al Viro --- include/linux/fs_context.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/linux') diff --git a/include/linux/fs_context.h b/include/linux/fs_context.h index b2ad9b0a7af4..e6c3e4c61dad 100644 --- a/include/linux/fs_context.h +++ b/include/linux/fs_context.h @@ -203,6 +203,7 @@ void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt, */ #define infof(fc, fmt, ...) __logfc(fc, 'i', fmt, ## __VA_ARGS__) #define info_plog(p, fmt, ...) __plog(p, 'i', fmt, ## __VA_ARGS__) +#define infofc(p, fmt, ...) __plog((&(fc)->log), 'i', fmt, ## __VA_ARGS__) /** * warnf - Store supplementary warning message @@ -214,6 +215,7 @@ void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt, */ #define warnf(fc, fmt, ...) __logfc(fc, 'w', fmt, ## __VA_ARGS__) #define warn_plog(p, fmt, ...) __plog(p, 'w', fmt, ## __VA_ARGS__) +#define warnfc(fc, fmt, ...) __plog((&(fc)->log), 'w', fmt, ## __VA_ARGS__) /** * errorf - Store supplementary error message @@ -225,6 +227,7 @@ void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt, */ #define errorf(fc, fmt, ...) __logfc(fc, 'e', fmt, ## __VA_ARGS__) #define error_plog(p, fmt, ...) __plog(p, 'e', fmt, ## __VA_ARGS__) +#define errorfc(fc, fmt, ...) __plog((&(fc)->log), 'e', fmt, ## __VA_ARGS__) /** * invalf - Store supplementary invalid argument error message @@ -236,5 +239,6 @@ void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt, */ #define invalf(fc, fmt, ...) (errorf(fc, fmt, ## __VA_ARGS__), -EINVAL) #define inval_plog(p, fmt, ...) (error_plog(p, fmt, ## __VA_ARGS__), -EINVAL) +#define invalfc(fc, fmt, ...) (errorfc(fc, fmt, ## __VA_ARGS__), -EINVAL) #endif /* _LINUX_FS_CONTEXT_H */ -- cgit