uaccess.c 738 B

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