fs/fs_parser.c
Source file repositories/reference/linux-study-clean/fs/fs_parser.c
File Facts
- System
- Linux kernel
- Corpus path
fs/fs_parser.c- Extension
.c- Size
- 10752 bytes
- Lines
- 391
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/fs_context.hlinux/fs_parser.hlinux/slab.hlinux/security.hlinux/namei.hinternal.h
Detected Declarations
function __lookup_constantfunction lookup_constantfunction is_flagfunction __fs_parsefunction fs_lookup_paramfunction fs_param_bad_valuefunction fs_param_is_boolfunction fs_param_is_u32function fs_param_is_s32function fs_param_is_u64function fs_param_is_enumfunction fs_param_is_stringfunction fs_param_is_fdfunction fs_param_is_file_or_stringfunction fs_param_is_uidfunction fs_param_is_gidfunction fs_param_is_blockdevfunction fs_validate_descriptionexport lookup_constantexport __fs_parseexport fs_lookup_paramexport fs_param_is_boolexport fs_param_is_u32export fs_param_is_s32export fs_param_is_u64export fs_param_is_enumexport fs_param_is_stringexport fs_param_is_fdexport fs_param_is_file_or_stringexport fs_param_is_uidexport fs_param_is_gidexport fs_param_is_blockdev
Annotated Snippet
if (name[0] == 'n' && name[1] == 'o' && name[2]) {
for (p = desc; p->name; p++) {
if (strcmp(p->name, name + 2) != 0)
continue;
if (!(p->flags & fs_param_neg_with_no))
continue;
*negated = true;
return p;
}
}
}
return other;
}
/*
* __fs_parse - Parse a filesystem configuration parameter
* @log: The filesystem context to log errors through.
* @desc: The parameter description to use.
* @param: The parameter.
* @result: Where to place the result of the parse
*
* Parse a filesystem configuration parameter and attempt a conversion for a
* simple parameter for which this is requested. If successful, the determined
* parameter ID is placed into @result->key, the desired type is indicated in
* @result->t and any converted value is placed into an appropriate member of
* the union in @result.
*
* The function returns the parameter number if the parameter was matched,
* -ENOPARAM if it wasn't matched and @desc->ignore_unknown indicated that
* unknown parameters are okay and -EINVAL if there was a conversion issue or
* the parameter wasn't recognised and unknowns aren't okay.
*/
int __fs_parse(struct p_log *log,
const struct fs_parameter_spec *desc,
struct fs_parameter *param,
struct fs_parse_result *result)
{
const struct fs_parameter_spec *p;
result->uint_64 = 0;
p = fs_lookup_key(desc, param, &result->negated);
if (!p)
return -ENOPARAM;
if (p->flags & fs_param_deprecated)
warn_plog(log, "Deprecated parameter '%s'", param->key);
/* Try to turn the type we were given into the type desired by the
* parameter and give an error if we can't.
*/
if (is_flag(p)) {
if (param->type != fs_value_is_flag)
return inval_plog(log, "Unexpected value for '%s'",
param->key);
result->boolean = !result->negated;
} else {
int ret = p->type(log, p, param, result);
if (ret)
return ret;
}
return p->opt;
}
EXPORT_SYMBOL(__fs_parse);
/**
* fs_lookup_param - Look up a path referred to by a parameter
* @fc: The filesystem context to log errors through.
* @param: The parameter.
* @want_bdev: T if want a blockdev
* @flags: Pathwalk flags passed to filename_lookup()
* @_path: The result of the lookup
*/
int fs_lookup_param(struct fs_context *fc,
struct fs_parameter *param,
bool want_bdev,
unsigned int flags,
struct path *_path)
{
struct filename *f;
bool put_f;
int ret;
switch (param->type) {
case fs_value_is_string:
f = getname_kernel(param->string);
if (IS_ERR(f))
return PTR_ERR(f);
param->dirfd = AT_FDCWD;
put_f = true;
Annotation
- Immediate include surface: `linux/export.h`, `linux/fs_context.h`, `linux/fs_parser.h`, `linux/slab.h`, `linux/security.h`, `linux/namei.h`, `internal.h`.
- Detected declarations: `function __lookup_constant`, `function lookup_constant`, `function is_flag`, `function __fs_parse`, `function fs_lookup_param`, `function fs_param_bad_value`, `function fs_param_is_bool`, `function fs_param_is_u32`, `function fs_param_is_s32`, `function fs_param_is_u64`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.