XenevaOS
Loading...
Searching...
No Matches
XenevaOS
BaseHdr
linux
lib
cmdline.h
Go to the documentation of this file.
1
/*
2
* DCL <linux/lib/cmdline.h> -- kernel command-line parsing.
3
*
4
* mainline keeps get_option() and get_options() in lib/cmdline.c and declares
5
* them here; get_cmdline() is the odd one out, living in fs/exec.c and
6
* declared here all the same. Same split here, with the bodies in
7
* DCL/linux_cmdline_shim.c.
8
*
9
* Declarations rather than static inlines, and that is forced rather than
10
* stylistic: the only caller is lib/string_helpers.c:146-154, whose include
11
* list (slab.h, string.h, string_helpers.h) does not reach this header. An
12
* implicit declaration there compiles -- the tree downgrades
13
* -Wimplicit-function-declaration to a warning -- but a static inline emits no
14
* symbol, so the two calls would link against nothing. An extern definition
15
* works whether or not the caller can see the header.
16
*
17
* The calling convention is worth reading before the bodies:
18
*
19
* get_options(buf, 0, &nints); // count only
20
* if (!nints)
21
* return -ENOENT;
22
* ints = kzalloc_objs(*ints, nints + 1);
23
* get_options(buf, nints + 1, ints); // now parse for real
24
*
25
* `nints` there is an int passed *as the ints array*, not as a count. That is
26
* mainline's contract, not a slip in the caller: get_options() writes the
27
* number of values it collected into ints[0] and the values after it, so an
28
* uninitialized local comes back holding the count. With nints == 0 it counts
29
* without writing past ints[0], which is why the first call can hand it a
30
* pointer to a single int.
31
*/
32
#ifndef _LINUX_LIB_CMDLINE_H
33
#define _LINUX_LIB_CMDLINE_H
34
35
/*
36
* get_option() -- read one integer off the front of *str, advancing it.
37
*
38
* Return values are mainline's and are what get_options() switches on:
39
* 0 nothing parseable, 1 an int with nothing after it, 2 an int followed by a
40
* comma (already consumed), 3 a hyphen, meaning the number just read is the
41
* bottom of a range. A NULL pint turns the call into a pure validator.
42
*/
43
int
get_option
(
const
char
** str,
int
* pint);
44
45
/*
46
* get_options() -- parse a comma-separated list of integers and M-N ranges
47
* into `ints`, writing the collected count into ints[0].
48
*
49
* Returns the position parsing stopped at. Neither caller in this tree reads
50
* it; both read ints[0].
51
*/
52
char
*
get_options
(
const
char
* str,
int
nints,
int
* ints);
53
54
/*
55
* get_cmdline() -- copy a task's command line into `buffer`, returning its
56
* length.
57
*
58
* Takes void* rather than mainline's `struct task_struct *` because this tree
59
* has no task_struct->mm to read; see the body for why 0 is the answer the
60
* caller can actually use.
61
*/
62
int
get_cmdline
(
void
* task,
char
* buffer,
int
buflen);
63
64
#endif
/* _LINUX_LIB_CMDLINE_H */
get_options
char * get_options(const char *str, int nints, int *ints)
get_option
int get_option(const char **str, int *pint)
get_cmdline
int get_cmdline(void *task, char *buffer, int buflen)
Generated by
1.9.8