exec_kern.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
  3. * Licensed under the GPL
  4. */
  5. #include "linux/slab.h"
  6. #include "linux/smp_lock.h"
  7. #include "linux/ptrace.h"
  8. #include "asm/ptrace.h"
  9. #include "asm/pgtable.h"
  10. #include "asm/tlbflush.h"
  11. #include "asm/uaccess.h"
  12. #include "user_util.h"
  13. #include "kern_util.h"
  14. #include "mem_user.h"
  15. #include "kern.h"
  16. #include "irq_user.h"
  17. #include "tlb.h"
  18. #include "os.h"
  19. #include "time_user.h"
  20. #include "choose-mode.h"
  21. #include "mode_kern.h"
  22. void flush_thread(void)
  23. {
  24. CHOOSE_MODE(flush_thread_tt(), flush_thread_skas());
  25. }
  26. void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
  27. {
  28. CHOOSE_MODE_PROC(start_thread_tt, start_thread_skas, regs, eip, esp);
  29. }
  30. extern void log_exec(char **argv, void *tty);
  31. static long execve1(char *file, char __user * __user *argv,
  32. char *__user __user *env)
  33. {
  34. long error;
  35. #ifdef CONFIG_TTY_LOG
  36. log_exec(argv, current->tty);
  37. #endif
  38. error = do_execve(file, argv, env, &current->thread.regs);
  39. if (error == 0){
  40. task_lock(current);
  41. current->ptrace &= ~PT_DTRACE;
  42. task_unlock(current);
  43. set_cmdline(current_cmd());
  44. }
  45. return(error);
  46. }
  47. long um_execve(char *file, char __user *__user *argv, char __user *__user *env)
  48. {
  49. long err;
  50. err = execve1(file, argv, env);
  51. if(!err)
  52. do_longjmp(current->thread.exec_buf, 1);
  53. return(err);
  54. }
  55. long sys_execve(char *file, char __user *__user *argv,
  56. char __user *__user *env)
  57. {
  58. long error;
  59. char *filename;
  60. lock_kernel();
  61. filename = getname((char __user *) file);
  62. error = PTR_ERR(filename);
  63. if (IS_ERR(filename)) goto out;
  64. error = execve1(filename, argv, env);
  65. putname(filename);
  66. out:
  67. unlock_kernel();
  68. return(error);
  69. }
  70. /*
  71. * Overrides for Emacs so that we follow Linus's tabbing style.
  72. * Emacs will notice this stuff at the end of the file and automatically
  73. * adjust the settings for this buffer only. This must remain at the end
  74. * of the file.
  75. * ---------------------------------------------------------------------------
  76. * Local variables:
  77. * c-file-style: "linux"
  78. * End:
  79. */