FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/vnode.h>
#include <sys/proc.h>
#include <sys/sbuf.h>
#include <sys/systm.h>
#include <sys/sysproto.h>
#include <sys/exec.h>
#include <sys/imgact.h>
#include <sys/kernel.h>
Go to the source code of this file.
Macros | |
#define | SHELLMAGIC 0x2123 /* #! */ |
Functions | |
__FBSDID ("$BSDSUniX$") | |
CTASSERT (MAXSHELLCMDLEN >=MAXINTERP+3) | |
int | exec_shell_imgact (struct image_params *imgp) |
EXEC_SET (shell, shell_execsw) | |
Variables | |
static struct execsw | shell_execsw = { exec_shell_imgact, "#!" } |
#define SHELLMAGIC 0x2123 /* #! */ |
Definition at line 41 of file imgact_shell.c.
Referenced by exec_shell_imgact().
__FBSDID | ( | "$BSDSUniX$" | ) |
CTASSERT | ( | MAXSHELLCMDLEN >=MAXINTERP+ | 3 | ) |
EXEC_SET | ( | shell | , |
shell_execsw | |||
) |
int exec_shell_imgact | ( | struct image_params * | imgp | ) |
Shell interpreter image activator. An interpreter name beginning at imgp->args->begin_argv is the minimal successful exit requirement.
If the given file is a shell-script, then the first line will start with the two characters `#!' (aka SHELLMAGIC), followed by the name of the shell-interpreter to run, followed by zero or more tokens.
The interpreter is then started up such that it will see: arg[0] -> The name of interpreter as specified after `#!' in the first line of the script. The interpreter name must not be longer than MAXSHELLCMDLEN bytes. arg[1] -> If there are any additional tokens on the first line, then we add a new arg[1], which is a copy of the rest of that line. The copy starts at the first token after the interpreter name. We leave it to the interpreter to parse the tokens in that value. arg[x] -> the full pathname of the script. This will either be arg[2] or arg[1], depending on whether or not tokens were found after the interpreter name. arg[x+1] -> all the arguments that were specified on the original command line.
This processing is described in the execve(2) man page.
Definition at line 100 of file imgact_shell.c.
References sbuf_data(), sbuf_delete(), sbuf_finish(), sbuf_printf(), and SHELLMAGIC.
|
static |
Definition at line 257 of file imgact_shell.c.