mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/
synced 2026-05-02 10:04:31 -04:00
fs_parse: add uid & gid option option parsing helpers
Multiple filesystems take uid and gid as options, and the code to create the ID from an integer and validate it is standard boilerplate that can be moved into common helper functions, so do that for consistency and less cut&paste. This also helps avoid the buggy pattern noted by Seth Jenkins at https://lore.kernel.org/lkml/CALxfFW4BXhEwxR0Q5LSkg-8Vb4r2MONKCcUCVioehXQKr35eHg@mail.gmail.com/ because uid/gid parsing will fail before any assignment in most filesystems. Signed-off-by: Eric Sandeen <sandeen@sandeen.net> Link: https://lore.kernel.org/r/de859d0a-feb9-473d-a5e2-c195a3d47abb@redhat.com Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
committed by
Christian Brauner
parent
104eef133f
commit
9f111059e7
@@ -28,7 +28,7 @@ typedef int fs_param_type(struct p_log *,
|
||||
*/
|
||||
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;
|
||||
fs_param_is_path, fs_param_is_fd, fs_param_is_uid, fs_param_is_gid;
|
||||
|
||||
/*
|
||||
* Specification of the type of value a parameter wants.
|
||||
@@ -57,6 +57,8 @@ struct fs_parse_result {
|
||||
int int_32; /* For spec_s32/spec_enum */
|
||||
unsigned int uint_32; /* For spec_u32{,_octal,_hex}/spec_enum */
|
||||
u64 uint_64; /* For spec_u64 */
|
||||
kuid_t uid;
|
||||
kgid_t gid;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -131,6 +133,8 @@ static inline bool fs_validate_description(const char *name,
|
||||
#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)
|
||||
#define fsparam_uid(NAME, OPT) __fsparam(fs_param_is_uid, NAME, OPT, 0, NULL)
|
||||
#define fsparam_gid(NAME, OPT) __fsparam(fs_param_is_gid, NAME, OPT, 0, NULL)
|
||||
|
||||
/* String parameter that allows empty argument */
|
||||
#define fsparam_string_empty(NAME, OPT) \
|
||||
|
||||
Reference in New Issue
Block a user