RT-AC66 3.0.0.4.374.130 core
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / arch / um / kernel / exec.c
blob356e50f5aaed4c6567e8780adbba06f80494e2a2
1 /*
2 * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
6 #include "linux/slab.h"
7 #include "linux/smp_lock.h"
8 #include "linux/ptrace.h"
9 #include "asm/ptrace.h"
10 #include "asm/pgtable.h"
11 #include "asm/tlbflush.h"
12 #include "asm/uaccess.h"
13 #include "kern_util.h"
14 #include "as-layout.h"
15 #include "mem_user.h"
16 #include "kern.h"
17 #include "irq_user.h"
18 #include "tlb.h"
19 #include "os.h"
20 #include "choose-mode.h"
21 #include "mode_kern.h"
23 void flush_thread(void)
25 arch_flush_thread(&current->thread.arch);
26 CHOOSE_MODE(flush_thread_tt(), flush_thread_skas());
29 void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
31 CHOOSE_MODE_PROC(start_thread_tt, start_thread_skas, regs, eip, esp);
34 #ifdef CONFIG_TTY_LOG
35 extern void log_exec(char **argv, void *tty);
36 #endif
38 static long execve1(char *file, char __user * __user *argv,
39 char __user *__user *env)
41 long error;
42 #ifdef CONFIG_TTY_LOG
43 struct tty_struct *tty;
45 mutex_lock(&tty_mutex);
46 tty = get_current_tty();
47 if (tty)
48 log_exec(argv, tty);
49 mutex_unlock(&tty_mutex);
50 #endif
51 error = do_execve(file, argv, env, &current->thread.regs);
52 if (error == 0){
53 task_lock(current);
54 current->ptrace &= ~PT_DTRACE;
55 #ifdef SUBARCH_EXECVE1
56 SUBARCH_EXECVE1(&current->thread.regs.regs);
57 #endif
58 task_unlock(current);
59 set_cmdline(current_cmd());
61 return(error);
64 long um_execve(char *file, char __user *__user *argv, char __user *__user *env)
66 long err;
68 err = execve1(file, argv, env);
69 if(!err)
70 do_longjmp(current->thread.exec_buf, 1);
71 return(err);
74 long sys_execve(char __user *file, char __user *__user *argv,
75 char __user *__user *env)
77 long error;
78 char *filename;
80 lock_kernel();
81 filename = getname(file);
82 error = PTR_ERR(filename);
83 if (IS_ERR(filename)) goto out;
84 error = execve1(filename, argv, env);
85 putname(filename);
86 out:
87 unlock_kernel();
88 return(error);