Merge branch 'origin'
[pandora-kernel.git] / arch / um / kernel / exec_kern.c
1 /* 
2  * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
3  * Licensed under the GPL
4  */
5
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 "user_util.h"
14 #include "kern_util.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"
22
23 void flush_thread(void)
24 {
25         CHOOSE_MODE(flush_thread_tt(), flush_thread_skas());
26 }
27
28 void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
29 {
30         CHOOSE_MODE_PROC(start_thread_tt, start_thread_skas, regs, eip, esp);
31 }
32
33 extern void log_exec(char **argv, void *tty);
34
35 static long execve1(char *file, char __user * __user *argv,
36                     char __user *__user *env)
37 {
38         long error;
39
40 #ifdef CONFIG_TTY_LOG
41         log_exec(argv, current->tty);
42 #endif
43         error = do_execve(file, argv, env, &current->thread.regs);
44         if (error == 0){
45                 task_lock(current);
46                 current->ptrace &= ~PT_DTRACE;
47                 task_unlock(current);
48                 set_cmdline(current_cmd());
49         }
50         return(error);
51 }
52
53 long um_execve(char *file, char __user *__user *argv, char __user *__user *env)
54 {
55         long err;
56
57         err = execve1(file, argv, env);
58         if(!err)
59                 do_longjmp(current->thread.exec_buf, 1);
60         return(err);
61 }
62
63 long sys_execve(char *file, char __user *__user *argv,
64                 char __user *__user *env)
65 {
66         long error;
67         char *filename;
68
69         lock_kernel();
70         filename = getname((char __user *) file);
71         error = PTR_ERR(filename);
72         if (IS_ERR(filename)) goto out;
73         error = execve1(filename, argv, env);
74         putname(filename);
75  out:
76         unlock_kernel();
77         return(error);
78 }
79
80 /*
81  * Overrides for Emacs so that we follow Linus's tabbing style.
82  * Emacs will notice this stuff at the end of the file and automatically
83  * adjust the settings for this buffer only.  This must remain at the end
84  * of the file.
85  * ---------------------------------------------------------------------------
86  * Local variables:
87  * c-file-style: "linux"
88  * End:
89  */