uaccess.c 778 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk)
  3. * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  4. * Licensed under the GPL
  5. */
  6. /*
  7. * These are here rather than tt/uaccess.c because skas mode needs them in
  8. * order to do SIGBUS recovery when a tmpfs mount runs out of room.
  9. */
  10. #include <linux/string.h>
  11. #include "os.h"
  12. static void __do_copy(void *to, const void *from, int n)
  13. {
  14. memcpy(to, from, n);
  15. }
  16. int __do_copy_to_user(void *to, const void *from, int n,
  17. void **fault_addr, jmp_buf **fault_catcher)
  18. {
  19. unsigned long fault;
  20. int faulted;
  21. fault = __do_user_copy(to, from, n, fault_addr, fault_catcher,
  22. __do_copy, &faulted);
  23. if (!faulted)
  24. return 0;
  25. else
  26. return n - (fault - (unsigned long) to);
  27. }