|
iPXE
|
Command execution. More...
#include <stdint.h>#include <string.h>#include <stdlib.h>#include <stdio.h>#include <ctype.h>#include <unistd.h>#include <getopt.h>#include <errno.h>#include <assert.h>#include <ipxe/tables.h>#include <ipxe/command.h>#include <ipxe/parseopt.h>#include <ipxe/settings.h>#include <ipxe/shell.h>Go to the source code of this file.
Data Structures | |
| struct | echo_options |
| "echo" options More... | |
| struct | exit_options |
| "exit" options More... | |
| struct | isset_options |
| "isset" options More... | |
| struct | iseq_options |
| "iseq" options More... | |
| struct | sleep_options |
| "sleep" options More... | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
| FILE_SECBOOT (PERMITTED) | |
| int | execv (const char *command, char *const argv[]) |
| Execute command. | |
| static int | split_command (char *command, char **tokens) |
| Split command line into tokens. | |
| static int | process_on_success (int rc) |
| Process next command only if previous command succeeded. | |
| static int | process_on_failure (int rc) |
| Process next command only if previous command failed. | |
| static int | process_always (int rc __unused) |
| Process next command regardless of status from previous command. | |
| static int | command_terminator (char **tokens, int(**process_next)(int rc)) |
| Find command terminator. | |
| void | shell_stop (int stop) |
| Set shell stop state. | |
| int | shell_stopped (int stop) |
| Test and consume shell stop state. | |
| static int | expand_tokens (int argc, char **tokens, char **argv) |
| Expand settings within a token list. | |
| static void | free_tokens (char **argv) |
| Free an expanded token list. | |
| int | system (const char *command) |
| Execute command line. | |
| char * | concat_args (char **args) |
| Concatenate arguments. | |
| static int | echo_exec (int argc, char **argv) |
| "echo" command | |
| COMMAND (echo, echo_exec) | |
| "echo" command | |
| static int | exit_exec (int argc, char **argv) |
| "exit" command | |
| COMMAND (exit, exit_exec) | |
| "exit" command | |
| static int | isset_exec (int argc, char **argv) |
| "isset" command | |
| COMMAND (isset, isset_exec) | |
| "isset" command | |
| static int | iseq_exec (int argc, char **argv) |
| "iseq" command | |
| COMMAND (iseq, iseq_exec) | |
| "iseq" command | |
| static int | sleep_exec (int argc, char **argv) |
| "sleep" command | |
| COMMAND (sleep, sleep_exec) | |
| "sleep" command | |
Variables | |
| static int | stop_state |
| Shell stop state. | |
| static struct option_descriptor | echo_opts [] |
| "echo" option list | |
| static struct command_descriptor | echo_cmd |
| "echo" command descriptor | |
| static struct option_descriptor | exit_opts [] = {} |
| "exit" option list | |
| static struct command_descriptor | exit_cmd |
| "exit" command descriptor | |
| static struct option_descriptor | isset_opts [] = {} |
| "isset" option list | |
| static struct command_descriptor | isset_cmd |
| "isset" command descriptor | |
| static struct option_descriptor | iseq_opts [] = {} |
| "iseq" option list | |
| static struct command_descriptor | iseq_cmd |
| "iseq" command descriptor | |
| static struct option_descriptor | sleep_opts [] = {} |
| "sleep" option list | |
| static struct command_descriptor | sleep_cmd |
| "sleep" command descriptor | |
Command execution.
Definition in file exec.c.
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
| FILE_SECBOOT | ( | PERMITTED | ) |
| int execv | ( | const char * | command, |
| char *const | argv[] ) |
Execute command.
| command | Command name |
| argv | Argument list |
| rc | Return status code |
Execute the named command. Unlike a traditional POSIX execv(), this function returns the exit status of the command.
Definition at line 61 of file exec.c.
References cmd, COMMANDS, DBG, done, EINVAL, ENOEXEC, errno, for_each_table_entry, NULL, printf(), rc, reset_getopt(), and strcmp().
Referenced by system(), and time_exec().
|
static |
Split command line into tokens.
| command | Command line |
| tokens | Token list to populate, or NULL |
| count | Number of tokens |
Splits the command line into whitespace-delimited tokens. If tokens is non-NULL, any whitespace in the command line will be replaced with NULs.
Definition at line 122 of file exec.c.
References count, and isspace().
Referenced by system().
|
static |
Process next command only if previous command succeeded.
| rc | Status of previous command |
| process | Process next command |
Definition at line 153 of file exec.c.
References rc.
Referenced by command_terminator().
|
static |
Process next command only if previous command failed.
| rc | Status of previous command |
| process | Process next command |
Definition at line 163 of file exec.c.
References rc.
Referenced by command_terminator().
|
static |
Process next command regardless of status from previous command.
| rc | Status of previous command |
| process | Process next command |
Definition at line 173 of file exec.c.
Referenced by command_terminator().
|
static |
Find command terminator.
| tokens | Token list |
| process_next | "Should next command be processed?" function |
| argc | Argument count |
Definition at line 184 of file exec.c.
References NULL, process_always(), process_on_failure(), process_on_success(), rc, and strcmp().
Referenced by system().
| void shell_stop | ( | int | stop | ) |
Set shell stop state.
| stop | Shell stop state |
Definition at line 218 of file exec.c.
References stop_state.
Referenced by exit_exec(), goto_exec(), and imgexec().
| int shell_stopped | ( | int | stop | ) |
Test and consume shell stop state.
| stop | Shell stop state to consume |
| stopped | Shell had been stopped |
Definition at line 228 of file exec.c.
References stop_state.
Referenced by shell(), system(), and terminate_on_exit_or_failure().
|
static |
Expand settings within a token list.
| argc | Argument count |
| tokens | Token list |
| argv | Argument list to fill in |
| rc | Return status code |
Definition at line 249 of file exec.c.
References assert, ENOMEM, expand_settings(), free, and NULL.
Referenced by system().
|
static |
| int system | ( | const char * | command | ) |
Execute command line.
| command | Command line |
| rc | Return status code |
Execute the named command and arguments.
Definition at line 288 of file exec.c.
References command_terminator(), count, ENOMEM, execv(), expand_tokens(), free, free_tokens(), NULL, rc, SHELL_STOP_COMMAND, shell_stopped(), split_command(), and strdup().
| char * concat_args | ( | char ** | args | ) |
Concatenate arguments.
| args | Argument list (NULL-terminated) |
| string | Concatenated arguments |
The returned string is allocated with malloc(). The caller is responsible for eventually free()ing this string.
Definition at line 359 of file exec.c.
References assert, len, NULL, sprintf, string, strlen(), and zalloc().
Referenced by dynui_exec(), echo_exec(), imgsingle_exec(), item_exec(), param_exec(), prompt_exec(), and set_value().
|
static |
"echo" command
| argc | Argument count |
| argv | Argument list |
| rc | Return status code |
Definition at line 410 of file exec.c.
References concat_args(), echo_cmd, ENOMEM, free, optind, opts, parse_options(), printf(), and rc.
Referenced by COMMAND().
"echo" command
References echo(), and echo_exec().
|
static |
"exit" command
| argc | Argument count |
| argv | Argument list |
| rc | Return status code |
Definition at line 451 of file exec.c.
References exit_cmd, optind, opts, parse_integer(), parse_options(), rc, shell_stop(), and SHELL_STOP_COMMAND_SEQUENCE.
Referenced by COMMAND().
| COMMAND | ( | exit | , |
| exit_exec | ) |
"exit" command
References exit_exec().
|
static |
"isset" command
| argc | Argument count |
| argv | Argument list |
| rc | Return status code |
Definition at line 492 of file exec.c.
References ENOENT, isset_cmd, optind, opts, parse_options(), and rc.
Referenced by COMMAND().
| COMMAND | ( | isset | , |
| isset_exec | ) |
"isset" command
References isset_exec().
|
static |
"iseq" command
| argc | Argument count |
| argv | Argument list |
| rc | Return status code |
Definition at line 525 of file exec.c.
References ERANGE, iseq_cmd, optind, opts, parse_options(), rc, and strcmp().
Referenced by COMMAND().
| COMMAND | ( | iseq | , |
| iseq_exec | ) |
"iseq" command
References iseq_exec().
|
static |
"sleep" command
| argc | Argument count |
| argv | Argument list |
| rc | Return status code |
Definition at line 558 of file exec.c.
References ECANCELED, optind, opts, parse_integer(), parse_options(), rc, seconds, sleep(), and sleep_cmd.
Referenced by COMMAND().
| COMMAND | ( | sleep | , |
| sleep_exec | ) |
"sleep" command
References sleep(), and sleep_exec().
|
static |
Shell stop state.
Definition at line 49 of file exec.c.
Referenced by shell_stop(), and shell_stopped().
|
static |
"echo" option list
Definition at line 393 of file exec.c.
|
static |
"echo" command descriptor
Definition at line 399 of file exec.c.
Referenced by echo_exec().
|
static |
|
static |
"exit" command descriptor
Definition at line 441 of file exec.c.
Referenced by exit_exec().
|
static |
|
static |
"isset" command descriptor
Definition at line 482 of file exec.c.
Referenced by isset_exec().
|
static |
|
static |
"iseq" command descriptor
Definition at line 514 of file exec.c.
Referenced by iseq_exec().
|
static |
|
static |
"sleep" command descriptor
Definition at line 548 of file exec.c.
Referenced by sleep_exec().