diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/um/kernel/tt/uaccess_user.c |
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/um/kernel/tt/uaccess_user.c')
-rw-r--r-- | arch/um/kernel/tt/uaccess_user.c | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/arch/um/kernel/tt/uaccess_user.c b/arch/um/kernel/tt/uaccess_user.c new file mode 100644 index 00000000000..f01475512ec --- /dev/null +++ b/arch/um/kernel/tt/uaccess_user.c | |||
@@ -0,0 +1,98 @@ | |||
1 | /* | ||
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 | ||
5 | */ | ||
6 | |||
7 | #include <setjmp.h> | ||
8 | #include <string.h> | ||
9 | #include "user_util.h" | ||
10 | #include "uml_uaccess.h" | ||
11 | #include "task.h" | ||
12 | #include "kern_util.h" | ||
13 | |||
14 | int __do_copy_from_user(void *to, const void *from, int n, | ||
15 | void **fault_addr, void **fault_catcher) | ||
16 | { | ||
17 | struct tt_regs save = TASK_REGS(get_current())->tt; | ||
18 | unsigned long fault; | ||
19 | int faulted; | ||
20 | |||
21 | fault = __do_user_copy(to, from, n, fault_addr, fault_catcher, | ||
22 | __do_copy, &faulted); | ||
23 | TASK_REGS(get_current())->tt = save; | ||
24 | |||
25 | if(!faulted) return(0); | ||
26 | else return(n - (fault - (unsigned long) from)); | ||
27 | } | ||
28 | |||
29 | static void __do_strncpy(void *dst, const void *src, int count) | ||
30 | { | ||
31 | strncpy(dst, src, count); | ||
32 | } | ||
33 | |||
34 | int __do_strncpy_from_user(char *dst, const char *src, unsigned long count, | ||
35 | void **fault_addr, void **fault_catcher) | ||
36 | { | ||
37 | struct tt_regs save = TASK_REGS(get_current())->tt; | ||
38 | unsigned long fault; | ||
39 | int faulted; | ||
40 | |||
41 | fault = __do_user_copy(dst, src, count, fault_addr, fault_catcher, | ||
42 | __do_strncpy, &faulted); | ||
43 | TASK_REGS(get_current())->tt = save; | ||
44 | |||
45 | if(!faulted) return(strlen(dst)); | ||
46 | else return(-1); | ||
47 | } | ||
48 | |||
49 | static void __do_clear(void *to, const void *from, int n) | ||
50 | { | ||
51 | memset(to, 0, n); | ||
52 | } | ||
53 | |||
54 | int __do_clear_user(void *mem, unsigned long len, | ||
55 | void **fault_addr, void **fault_catcher) | ||
56 | { | ||
57 | struct tt_regs save = TASK_REGS(get_current())->tt; | ||
58 | unsigned long fault; | ||
59 | int faulted; | ||
60 | |||
61 | fault = __do_user_copy(mem, NULL, len, fault_addr, fault_catcher, | ||
62 | __do_clear, &faulted); | ||
63 | TASK_REGS(get_current())->tt = save; | ||
64 | |||
65 | if(!faulted) return(0); | ||
66 | else return(len - (fault - (unsigned long) mem)); | ||
67 | } | ||
68 | |||
69 | int __do_strnlen_user(const char *str, unsigned long n, | ||
70 | void **fault_addr, void **fault_catcher) | ||
71 | { | ||
72 | struct tt_regs save = TASK_REGS(get_current())->tt; | ||
73 | int ret; | ||
74 | unsigned long *faddrp = (unsigned long *)fault_addr; | ||
75 | sigjmp_buf jbuf; | ||
76 | |||
77 | *fault_catcher = &jbuf; | ||
78 | if(sigsetjmp(jbuf, 1) == 0) | ||
79 | ret = strlen(str) + 1; | ||
80 | else ret = *faddrp - (unsigned long) str; | ||
81 | |||
82 | *fault_addr = NULL; | ||
83 | *fault_catcher = NULL; | ||
84 | |||
85 | TASK_REGS(get_current())->tt = save; | ||
86 | return ret; | ||
87 | } | ||
88 | |||
89 | /* | ||
90 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
91 | * Emacs will notice this stuff at the end of the file and automatically | ||
92 | * adjust the settings for this buffer only. This must remain at the end | ||
93 | * of the file. | ||
94 | * --------------------------------------------------------------------------- | ||
95 | * Local variables: | ||
96 | * c-file-style: "linux" | ||
97 | * End: | ||
98 | */ | ||