am 10f8cd1d: Merge changes Ia15b2110,I5498c725
* commit '10f8cd1d87eccde36da2ac54ad7d390e34a6e224': Add ability to adjust init log level at runtime. Improve init's debug printing.
This commit is contained in:
commit
23340d8ada
5 changed files with 42 additions and 8 deletions
|
|
@ -862,11 +862,24 @@ int do_setsebool(int nargs, char **args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int do_loglevel(int nargs, char **args) {
|
int do_loglevel(int nargs, char **args) {
|
||||||
if (nargs == 2) {
|
int log_level;
|
||||||
klog_set_level(atoi(args[1]));
|
char log_level_str[PROP_VALUE_MAX] = "";
|
||||||
return 0;
|
if (nargs != 2) {
|
||||||
|
ERROR("loglevel: missing argument\n");
|
||||||
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
return -1;
|
|
||||||
|
if (expand_props(log_level_str, args[1], sizeof(log_level_str))) {
|
||||||
|
ERROR("loglevel: cannot expand '%s'\n", args[1]);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
log_level = atoi(log_level_str);
|
||||||
|
if (log_level < KLOG_ERROR_LEVEL || log_level > KLOG_DEBUG_LEVEL) {
|
||||||
|
ERROR("loglevel: invalid log level'%d'\n", log_level);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
klog_set_level(log_level);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int do_load_persist_props(int nargs, char **args) {
|
int do_load_persist_props(int nargs, char **args) {
|
||||||
|
|
|
||||||
15
init/init.c
15
init/init.c
|
|
@ -528,7 +528,8 @@ static int is_last_command(struct action *act, struct command *cmd)
|
||||||
|
|
||||||
void execute_one_command(void)
|
void execute_one_command(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret, i;
|
||||||
|
char cmd_str[256] = "";
|
||||||
|
|
||||||
if (!cur_action || !cur_command || is_last_command(cur_action, cur_command)) {
|
if (!cur_action || !cur_command || is_last_command(cur_action, cur_command)) {
|
||||||
cur_action = action_remove_queue_head();
|
cur_action = action_remove_queue_head();
|
||||||
|
|
@ -545,7 +546,17 @@ void execute_one_command(void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ret = cur_command->func(cur_command->nargs, cur_command->args);
|
ret = cur_command->func(cur_command->nargs, cur_command->args);
|
||||||
INFO("command '%s' r=%d\n", cur_command->args[0], ret);
|
if (klog_get_level() >= KLOG_INFO_LEVEL) {
|
||||||
|
for (i = 0; i < cur_command->nargs; i++) {
|
||||||
|
strlcat(cmd_str, cur_command->args[i], sizeof(cmd_str));
|
||||||
|
if (i < cur_command->nargs - 1) {
|
||||||
|
strlcat(cmd_str, " ", sizeof(cmd_str));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
INFO("command '%s' action=%s status=%d (%s:%d)\n",
|
||||||
|
cmd_str, cur_action ? cur_action->name : "", ret, cur_command->filename,
|
||||||
|
cur_command->line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wait_for_coldboot_done_action(int nargs, char **args)
|
static int wait_for_coldboot_done_action(int nargs, char **args)
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,14 @@ struct command
|
||||||
struct listnode clist;
|
struct listnode clist;
|
||||||
|
|
||||||
int (*func)(int nargs, char **args);
|
int (*func)(int nargs, char **args);
|
||||||
|
|
||||||
|
int line;
|
||||||
|
const char *filename;
|
||||||
|
|
||||||
int nargs;
|
int nargs;
|
||||||
char *args[1];
|
char *args[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct action {
|
struct action {
|
||||||
/* node in list of all actions */
|
/* node in list of all actions */
|
||||||
struct listnode alist;
|
struct listnode alist;
|
||||||
|
|
@ -43,7 +47,7 @@ struct action {
|
||||||
|
|
||||||
unsigned hash;
|
unsigned hash;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
struct listnode commands;
|
struct listnode commands;
|
||||||
struct command *current;
|
struct command *current;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -584,6 +584,7 @@ void queue_builtin_action(int (*func)(int nargs, char **args), char *name)
|
||||||
cmd = calloc(1, sizeof(*cmd));
|
cmd = calloc(1, sizeof(*cmd));
|
||||||
cmd->func = func;
|
cmd->func = func;
|
||||||
cmd->args[0] = name;
|
cmd->args[0] = name;
|
||||||
|
cmd->nargs = 1;
|
||||||
list_add_tail(&act->commands, &cmd->clist);
|
list_add_tail(&act->commands, &cmd->clist);
|
||||||
|
|
||||||
list_add_tail(&action_list, &act->alist);
|
list_add_tail(&action_list, &act->alist);
|
||||||
|
|
@ -870,6 +871,8 @@ static void parse_line_action(struct parse_state* state, int nargs, char **args)
|
||||||
}
|
}
|
||||||
cmd = malloc(sizeof(*cmd) + sizeof(char*) * nargs);
|
cmd = malloc(sizeof(*cmd) + sizeof(char*) * nargs);
|
||||||
cmd->func = kw_func(kw);
|
cmd->func = kw_func(kw);
|
||||||
|
cmd->line = state->line;
|
||||||
|
cmd->filename = state->filename;
|
||||||
cmd->nargs = nargs;
|
cmd->nargs = nargs;
|
||||||
memcpy(cmd->args, args, sizeof(char*) * nargs);
|
memcpy(cmd->args, args, sizeof(char*) * nargs);
|
||||||
list_add_tail(&act->commands, &cmd->clist);
|
list_add_tail(&act->commands, &cmd->clist);
|
||||||
|
|
|
||||||
|
|
@ -428,6 +428,9 @@ on boot
|
||||||
on nonencrypted
|
on nonencrypted
|
||||||
class_start late_start
|
class_start late_start
|
||||||
|
|
||||||
|
on property:sys.init_log_level=*
|
||||||
|
loglevel ${sys.init_log_level}
|
||||||
|
|
||||||
on charger
|
on charger
|
||||||
class_start charger
|
class_start charger
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue