Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / sparc64 / lib / user_fixup.c
blob0278e34125dbe773b38685bb3433797739b9ecf1
1 /* user_fixup.c: Fix up user copy faults.
3 * Copyright (C) 2004 David S. Miller <davem@redhat.com>
4 */
6 #include <linux/compiler.h>
7 #include <linux/kernel.h>
8 #include <linux/string.h>
9 #include <linux/errno.h>
10 #include <asm/uaccess.h>
12 /* Calculating the exact fault address when using
13 * block loads and stores can be very complicated.
14 * Instead of trying to be clever and handling all
15 * of the cases, just fix things up simply here.
18 unsigned long copy_from_user_fixup(void *to, const void __user *from, unsigned long size)
20 char *dst = to;
21 const char __user *src = from;
23 while (size) {
24 if (__get_user(*dst, src))
25 break;
26 dst++;
27 src++;
28 size--;
31 if (size)
32 memset(dst, 0, size);
34 return size;
37 unsigned long copy_to_user_fixup(void __user *to, const void *from, unsigned long size)
39 char __user *dst = to;
40 const char *src = from;
42 while (size) {
43 if (__put_user(*src, dst))
44 break;
45 dst++;
46 src++;
47 size--;
50 return size;
53 unsigned long copy_in_user_fixup(void __user *to, void __user *from, unsigned long size)
55 char __user *dst = to;
56 char __user *src = from;
58 while (size) {
59 char tmp;
61 if (__get_user(tmp, src))
62 break;
63 if (__put_user(tmp, dst))
64 break;
65 dst++;
66 src++;
67 size--;
70 return size;