本文整理汇总了C++中do_execve函数的典型用法代码示例。如果您正苦于以下问题:C++ do_execve函数的具体用法?C++ do_execve怎么用?C++ do_execve使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了do_execve函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: open_and_exec
static int open_and_exec(t_shell *shell, t_tree *tree)
{
t_tree *current;
int idx;
int fd_idx;
current = tree;
fd_idx = 0;
while (current->up != NULL)
{
idx = 0;
while (idx != current->up->token)
idx += 1;
if (shell->tk_parsing[idx].f(shell, current, fd_idx++) == -1)
return (-1);
current = current->up;
}
if (do_execve(shell, current->left) == -1)
return (-1);
waiting_all_children(shell);
if (dup2(shell->base_in_out[0], 0) == -1 ||
dup2(shell->base_in_out[1], 1) == -1)
return (-1);
return (0);
}
示例2: sys_exec
static uint32_t
sys_exec(uint32_t arg[]) {
const char *name = (const char *)arg[0];
const char **argv = (const char **)arg[1];//kprintf("sys_exec : name=%s argc=%d\n", name, argc);int d;for (d = 0; d < argc; ++d) kprintf("\t#%d: %s\n", d, argv[d]);
const char **envp = (const char **)arg[2];
return do_execve(name, argv, envp);
}
示例3: fork_handler
void fork_handler(t_shell *shell, char **args)
{
pid_t p;
p = fork();
if (p == 0)
{
if (execve(args[0], args, shell->env) == -1)
{
if (shell->env == NULL)
{
my_putstr_err(args[0]);
my_putstr_err(": Command not found.\n");
exit(0);
}
do_execve(shell->env, args);
}
exit(0);
}
else if (p != -1)
{
waitpid(0, &shell->status, 0);
}
else
my_putstr_err("FATAL ERROR : Fork failed\n");
}
示例4: sys_execve
static uint32_t
sys_execve(uint32_t arg[]) {
const char *name = (const char *)arg[0];
const char **argv = (const char **)arg[1];
const char **envp = (const char **)arg[2];
return do_execve(name, argv, envp);
}
示例5: real_execve
asmlinkage int real_execve(struct pt_regs *regs)
{
int error;
char * filename;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
lock_kernel();
#endif
filename = getname((char *) regs->ebx);
error = PTR_ERR(filename);
if (IS_ERR(filename))
goto out;
error = do_execve(filename, (char **) regs->ecx, (char **) regs->edx, regs);
if (error == 0) {
#ifdef PT_DTRACE
current->ptrace &= ~PT_DTRACE;
#else
current->flags &= ~PF_DTRACE;
#endif
}
putname(filename);
out:
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
unlock_kernel();
#endif
return error;
}
示例6: sys_exec
static uint32_t sys_exec(uint32_t arg[])
{
const char *name = (const char *)arg[0];
int argc = (int)arg[1];
const char **argv = (const char **)arg[2];
return do_execve(name, argc, argv);
}
示例7: my_sys_execve
asmlinkage static int my_sys_execve(struct pt_regs regs)
{
char * filename;
int ret;
MOD_INC_USE_COUNT;
lock_execve();
filename = getname((char *)regs.ebx);
if (IS_ERR(filename)) {
ret = PTR_ERR(filename);
goto out;
}
ret = do_execve(filename, (char **)regs.ecx, (char **)regs.edx, ®s);
if (!ret) {
PTRACE_OFF(current);
oprof_output_maps(current);
}
putname(filename);
out:
unlock_execve();
MOD_DEC_USE_COUNT;
return ret;
}
示例8: DEFINE_SYSCALL
DEFINE_SYSCALL(execve, const char *, filename, char **, argv, char **, envp)
{
/* TODO: Deal with argv/envp == NULL */
/* TODO: Don't destroy things on failure */
log_info("execve(%s, %p, %p)", filename, argv, envp);
/* Copy argv[] and envp[] to startup data */
char *current_startup_base = flip_startup_base();
/* Save filename in startup data area */
int flen = strlen(filename);
memcpy(current_startup_base, filename, flen + 1);
filename = current_startup_base;
current_startup_base += flen + 1;
char *base = current_startup_base;
int argc, env_size;
for (argc = 0; argv[argc]; argc++)
base += strlen(argv[argc]) + 1;
for (env_size = 0; envp[env_size]; env_size++)
base += strlen(envp[env_size]) + 1;
/* TODO: Test if we have enough size to hold the startup data */
char **new_argv = (char **)((uintptr_t)(base + sizeof(void*) - 1) & -sizeof(void*));
char **new_envp = new_argv + argc + 1;
base = current_startup_base;
for (int i = 0; i < argc; i++)
{
new_argv[i] = base;
int len = strlen(argv[i]);
memcpy(base, argv[i], len + 1);
base += len + 1;
}
new_argv[argc] = NULL;
for (int i = 0; i < env_size; i++)
{
new_envp[i] = base;
int len = strlen(envp[i]);
memcpy(base, envp[i], len + 1);
base += len + 1;
}
new_envp[env_size] = NULL;
for (int i = 0; i < argc; i++)
log_info("argv[%d] = \"%s\"", i, new_argv[i]);
for (int i = 0; i < env_size; i++)
log_info("envp[%d] = \"%s\"", i, new_envp[i]);
base = (char *)(new_envp + env_size + 1);
int r = do_execve(filename, argc, new_argv, env_size, new_envp, base, execve_initialize_routine);
if (r < 0) /* Should always be the case */
{
log_warning("execve() failed.");
flip_startup_base();
}
return r;
}
示例9: sys_exec
static int sys_exec(uint32_t arg[])
{
const char *name = (const char *) arg[0];
size_t len = (size_t) arg[1];
unsigned char *binary = (unsigned char *) arg[2];
size_t size = (size_t) arg[3];
return do_execve(name, len, binary, size);
}
示例10: sys_execve
asmlinkage int
sys_execve(struct pt_regs* regs)
{
dprintk("sys_execve: %s, %p, %p\n",
regs->gregs[0], regs->gregs[1], regs->gregs[2]);
return do_execve((void*)regs->gregs[0], (void*)regs->gregs[1],
(void*)regs->gregs[2], regs);
}
示例11: sys_exec
static uint32_t sys_exec(uint32_t arg[])
{
const char *name = (const char *)arg[0];
int argc = (int)arg[1];
const char **argv = (const char **)arg[2];
current->arch.forking = 1;
int ret = do_execve(name, argc, argv);
current->arch.forking = 0;
return ret;
}
示例12: kern_execve
/*
* XXX: kern_execve has the astonishing property of not always returning to
* the caller. If sufficiently bad things happen during the call to
* do_execve(), it can end up calling exit1(); as a result, callers must
* avoid doing anything which they might need to undo (e.g., allocating
* memory).
*/
int
kern_execve(struct thread *td, struct image_args *args, struct mac *mac_p)
{
AUDIT_ARG_ARGV(args->begin_argv, args->argc,
args->begin_envv - args->begin_argv);
AUDIT_ARG_ENVV(args->begin_envv, args->envc,
args->endp - args->begin_envv);
return (do_execve(td, args, mac_p));
}
示例13: kernel_execve
/**
* Exec a user program called by user_main kernel_thread
* Note: we don't need to emulate an interrupt here.
* @param name the name of the process
* @param argv the arguments
*/
int kernel_execve(const char *name, const char **argv)
{
int argc = 0, ret;
while (argv[argc] != NULL) {
argc++;
}
ret = do_execve(name, argc, argv);
kprintf("error with code: %d\n", ret);
return ret;
}
示例14: execve1
static int execve1(char *file, char **argv, char **env)
{
int error;
error = do_execve(file, argv, env, ¤t->thread.regs);
if (error == 0){
current->ptrace &= ~PT_DTRACE;
set_cmdline(current_cmd());
}
return(error);
}
示例15: sys_execve
/*
* sys_execve() executes a new program.
*/
asmlinkage int sys_execve(struct pt_regs *regs)
{
int error;
char * filename;
error = getname((char *) regs->reg4, &filename);
if (error)
return error;
error = do_execve(filename, (char **) regs->reg5,
(char **) regs->reg6, regs);
putname(filename);
return error;
}