13.4 Option Processing for the Init Process
After processing the parameters preceding the -- marker, the start_kernel() function utilizes the macro definition IS_ERR_OR_NULL() to determine whether the after_dashes pointer evaluates to null or falls within the exception range between -1 and -4095. If it is a valid pointer, the kernel invokes the parse_args() function once again to tokenize the parameters trailing the -- delimiter within static_command_line. If these arguments conform to the required syntax layout, they are stored directly into the argv_init array. The function is invoked in the following manner:
parse_args("Setting init args", after_dashes, NULL, 0, -1, -1, NULL, set_init_arg);
Similarly, due to the parameter configuration passed to parse_args(), the parse_args() function bypasses internal table lookups and hands the variables tracked by after_dashes directly to the set_init_arg() function for parsing. This function is located within the file git/init/main.c and is defined as follows:
static int __init set_init_arg(char *param, char *val, const char *unused, void *arg)
{
unsigned int i;
if (panic_later)
return 0;
repair_env_string(param, val);
for (i = 0; argv_init[i]; i++) {
if (i == MAX_INIT_ARGS) {
panic_later = "init";
panic_param = param;
return 0;
}
}
argv_init[i] = param;
return 0;
}
Upon invoking the function repair_env_string(param, val) to uniformly restore arguments structured as param=val or param="val" back into the explicit param=val schema, the routine verifies if the argv_init array contains sufficient unallocated slots. If space is available, each individual parameter is appended into the argv_init array. If the array bounds are exceeded, the routine populates the tracking variables panic_later and panic_param accordingly.
Furthermore, if the supplemental init process variable string extra_init_args is present, start_kernel() invokes parse_args() one final time, leveraging the set_init_arg() function to archive the diverse variables pointed to by extra_init_args into the argv_init array.