uaccess.c 712 B

123456789101112131415161718192021222324252627282930313233
  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. #include <stddef.h>
  7. #include "longjmp.h"
  8. unsigned long __do_user_copy(void *to, const void *from, int n,
  9. void **fault_addr, jmp_buf **fault_catcher,
  10. void (*op)(void *to, const void *from,
  11. int n), int *faulted_out)
  12. {
  13. unsigned long *faddrp = (unsigned long *) fault_addr, ret;
  14. jmp_buf jbuf;
  15. *fault_catcher = &jbuf;
  16. if (UML_SETJMP(&jbuf) == 0) {
  17. (*op)(to, from, n);
  18. ret = 0;
  19. *faulted_out = 0;
  20. }
  21. else {
  22. ret = *faddrp;
  23. *faulted_out = 1;
  24. }
  25. *fault_addr = NULL;
  26. *fault_catcher = NULL;
  27. return ret;
  28. }