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