tools/lib/subcmd/exec-cmd.c
Source file repositories/reference/linux-study-clean/tools/lib/subcmd/exec-cmd.c
File Facts
- System
- Linux kernel
- Corpus path
tools/lib/subcmd/exec-cmd.c- Extension
.c- Size
- 4347 bytes
- Lines
- 219
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/compiler.hlinux/string.hsys/types.hsys/stat.hunistd.hstring.hstdlib.hstdio.hsubcmd-util.hexec-cmd.hsubcmd-config.h
Detected Declarations
function exec_cmd_initfunction is_absolute_pathfunction set_argv_exec_pathfunction add_pathfunction setup_pathfunction execv_cmdfunction execl_cmd
Annotated Snippet
int execv_cmd(const char **argv) {
const char **nargv = prepare_exec_cmd(argv);
/* execvp() can only ever return if it fails */
execvp(subcmd_config.exec_name, (char **)nargv);
free(nargv);
return -1;
}
int execl_cmd(const char *cmd,...)
{
int argc;
const char *argv[MAX_ARGS + 1];
const char *arg;
va_list param;
va_start(param, cmd);
argv[0] = cmd;
argc = 1;
while (argc < MAX_ARGS) {
arg = argv[argc++] = va_arg(param, char *);
if (!arg)
break;
}
va_end(param);
if (MAX_ARGS <= argc) {
fprintf(stderr, " Error: too many args to run %s\n", cmd);
return -1;
}
argv[argc] = NULL;
return execv_cmd(argv);
}
Annotation
- Immediate include surface: `linux/compiler.h`, `linux/string.h`, `sys/types.h`, `sys/stat.h`, `unistd.h`, `string.h`, `stdlib.h`, `stdio.h`.
- Detected declarations: `function exec_cmd_init`, `function is_absolute_path`, `function set_argv_exec_path`, `function add_path`, `function setup_path`, `function execv_cmd`, `function execl_cmd`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source 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.