sys_avr32.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (C) 2004-2006 Atmel Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #include <linux/errno.h>
  9. #include <linux/fs.h>
  10. #include <linux/file.h>
  11. #include <linux/mm.h>
  12. #include <linux/unistd.h>
  13. #include <asm/mman.h>
  14. #include <asm/uaccess.h>
  15. asmlinkage int sys_pipe(unsigned long __user *filedes)
  16. {
  17. int fd[2];
  18. int error;
  19. error = do_pipe(fd);
  20. if (!error) {
  21. if (copy_to_user(filedes, fd, sizeof(fd)))
  22. error = -EFAULT;
  23. }
  24. return error;
  25. }
  26. asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
  27. unsigned long prot, unsigned long flags,
  28. unsigned long fd, off_t offset)
  29. {
  30. int error = -EBADF;
  31. struct file *file = NULL;
  32. flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
  33. if (!(flags & MAP_ANONYMOUS)) {
  34. file = fget(fd);
  35. if (!file)
  36. return error;
  37. }
  38. down_write(&current->mm->mmap_sem);
  39. error = do_mmap_pgoff(file, addr, len, prot, flags, offset);
  40. up_write(&current->mm->mmap_sem);
  41. if (file)
  42. fput(file);
  43. return error;
  44. }
  45. int kernel_execve(const char *file, char **argv, char **envp)
  46. {
  47. register long scno asm("r8") = __NR_execve;
  48. register long sc1 asm("r12") = (long)file;
  49. register long sc2 asm("r11") = (long)argv;
  50. register long sc3 asm("r10") = (long)envp;
  51. asm volatile("scall"
  52. : "=r"(sc1)
  53. : "r"(scno), "0"(sc1), "r"(sc2), "r"(sc3)
  54. : "cc", "memory");
  55. return sc1;
  56. }