2 * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk)
3 * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
4 * Licensed under the GPL
10 #include "uml_uaccess.h"
12 int __do_copy_from_user(void *to, const void *from, int n,
13 void **fault_addr, void **fault_catcher)
18 fault = __do_user_copy(to, from, n, fault_addr, fault_catcher,
20 if(!faulted) return(0);
21 else return(n - (fault - (unsigned long) from));
24 static void __do_strncpy(void *dst, const void *src, int count)
26 strncpy(dst, src, count);
29 int __do_strncpy_from_user(char *dst, const char *src, unsigned long count,
30 void **fault_addr, void **fault_catcher)
35 fault = __do_user_copy(dst, src, count, fault_addr, fault_catcher,
36 __do_strncpy, &faulted);
37 if(!faulted) return(strlen(dst));
41 static void __do_clear(void *to, const void *from, int n)
46 int __do_clear_user(void *mem, unsigned long len,
47 void **fault_addr, void **fault_catcher)
52 fault = __do_user_copy(mem, NULL, len, fault_addr, fault_catcher,
53 __do_clear, &faulted);
54 if(!faulted) return(0);
55 else return(len - (fault - (unsigned long) mem));
58 int __do_strnlen_user(const char *str, unsigned long n,
59 void **fault_addr, void **fault_catcher)
62 unsigned long *faddrp = (unsigned long *)fault_addr;
65 *fault_catcher = &jbuf;
66 if(setjmp(jbuf) == 0){
67 ret = strlen(str) + 1;
70 ret = *faddrp - (unsigned long) str;
73 *fault_catcher = NULL;
78 * Overrides for Emacs so that we follow Linus's tabbing style.
79 * Emacs will notice this stuff at the end of the file and automatically
80 * adjust the settings for this buffer only. This must remain at the end
82 * ---------------------------------------------------------------------------
84 * c-file-style: "linux"