lib/cmdline.c
Source file repositories/reference/linux-study-clean/lib/cmdline.c
File Facts
- System
- Linux kernel
- Corpus path
lib/cmdline.c- Extension
.c- Size
- 6330 bytes
- Lines
- 286
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
Dependency Surface
linux/export.hlinux/kernel.hlinux/string.hlinux/ctype.h
Detected Declarations
function get_rangefunction get_optionfunction endfunction memparsefunction parse_option_strexport get_optionexport get_optionsexport memparseexport next_arg
Annotated Snippet
if (res == 3) {
int n = validate ? 0 : nints - i;
int range_nums;
range_nums = get_range((char **)&str, pint, n);
if (range_nums < 0)
break;
/*
* Decrement the result by one to leave out the
* last number in the range. The next iteration
* will handle the upper number in the range
*/
i += (range_nums - 1);
}
i++;
if (res == 1)
break;
}
ints[0] = i - 1;
return (char *)str;
}
EXPORT_SYMBOL(get_options);
/**
* memparse - parse a string with mem suffixes into a number
* @ptr: Where parse begins
* @retptr: (output) Optional pointer to next char after parse completes
*
* Parses a string into a number. The number stored at @ptr is
* potentially suffixed with K, M, G, T, P, E.
*
* Return: The value as recognized by simple_strtoull() multiplied
* by the value as specified by suffix, if any.
*/
unsigned long long memparse(const char *ptr, char **retptr)
{
char *endptr; /* local pointer to end of parsed string */
unsigned long long ret = simple_strtoull(ptr, &endptr, 0);
unsigned int shl = 0;
/* Consume valid suffix even in case of overflow. */
switch (*endptr) {
case 'E':
case 'e':
shl += 10;
fallthrough;
case 'P':
case 'p':
shl += 10;
fallthrough;
case 'T':
case 't':
shl += 10;
fallthrough;
case 'G':
case 'g':
shl += 10;
fallthrough;
case 'M':
case 'm':
shl += 10;
fallthrough;
case 'K':
case 'k':
shl += 10;
fallthrough;
default:
break;
}
if (shl && likely(ptr != endptr)) {
/* Have valid suffix with preceding number. */
if (unlikely(check_shl_overflow(ret, shl, &ret)))
ret = ULLONG_MAX;
endptr++;
}
if (retptr)
*retptr = endptr;
return ret;
}
EXPORT_SYMBOL(memparse);
/**
* parse_option_str - Parse a string and check an option is set or not
* @str: String to be parsed
* @option: option name
*
Annotation
- Immediate include surface: `linux/export.h`, `linux/kernel.h`, `linux/string.h`, `linux/ctype.h`.
- Detected declarations: `function get_range`, `function get_option`, `function end`, `function memparse`, `function parse_option_str`, `export get_option`, `export get_options`, `export memparse`, `export next_arg`.
- Atlas domain: Kernel Services / lib.
- 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.