sys_avr32.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. }