uaccess.c 732 字节
Newer Older
1 2 3 4 5 6 7 8
/*
 * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk)
 * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
 * Licensed under the GPL
 */

#include <setjmp.h>
#include <string.h>
9
#include "longjmp.h"
10 11 12 13 14 15 16

unsigned long __do_user_copy(void *to, const void *from, int n,
			     void **fault_addr, void **fault_catcher,
			     void (*op)(void *to, const void *from,
					int n), int *faulted_out)
{
	unsigned long *faddrp = (unsigned long *) fault_addr, ret;
17
	int enable;
18

19
	jmp_buf jbuf;
20
	*fault_catcher = &jbuf;
21
	if(UML_SETJMP(&jbuf, enable) == 0){
22 23 24 25 26 27 28 29 30 31 32 33 34
		(*op)(to, from, n);
		ret = 0;
		*faulted_out = 0;
	}
	else {
		ret = *faddrp;
		*faulted_out = 1;
	}
	*fault_addr = NULL;
	*fault_catcher = NULL;
	return ret;
}