exec_kern.c 2.0 KB

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