uaccess.c 691 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk)
  3. * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.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, void **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. }