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/include/um_uaccess.h |
Linux-2.6.12-rc2v2.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/include/um_uaccess.h')
-rw-r--r-- | arch/um/include/um_uaccess.h | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/arch/um/include/um_uaccess.h b/arch/um/include/um_uaccess.h new file mode 100644 index 000000000000..6e348cb6de24 --- /dev/null +++ b/arch/um/include/um_uaccess.h | |||
@@ -0,0 +1,125 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __ARCH_UM_UACCESS_H | ||
7 | #define __ARCH_UM_UACCESS_H | ||
8 | |||
9 | #include "linux/config.h" | ||
10 | #include "choose-mode.h" | ||
11 | |||
12 | #ifdef CONFIG_MODE_TT | ||
13 | #include "uaccess-tt.h" | ||
14 | #endif | ||
15 | |||
16 | #ifdef CONFIG_MODE_SKAS | ||
17 | #include "uaccess-skas.h" | ||
18 | #endif | ||
19 | |||
20 | #define access_ok(type, addr, size) \ | ||
21 | CHOOSE_MODE_PROC(access_ok_tt, access_ok_skas, type, addr, size) | ||
22 | |||
23 | /* this function will go away soon - use access_ok() instead */ | ||
24 | static inline int __deprecated verify_area(int type, const void __user *addr, unsigned long size) | ||
25 | { | ||
26 | return (CHOOSE_MODE_PROC(verify_area_tt, verify_area_skas, type, addr, | ||
27 | size)); | ||
28 | } | ||
29 | |||
30 | static inline int copy_from_user(void *to, const void __user *from, int n) | ||
31 | { | ||
32 | return(CHOOSE_MODE_PROC(copy_from_user_tt, copy_from_user_skas, to, | ||
33 | from, n)); | ||
34 | } | ||
35 | |||
36 | static inline int copy_to_user(void __user *to, const void *from, int n) | ||
37 | { | ||
38 | return(CHOOSE_MODE_PROC(copy_to_user_tt, copy_to_user_skas, to, | ||
39 | from, n)); | ||
40 | } | ||
41 | |||
42 | /* | ||
43 | * strncpy_from_user: - Copy a NUL terminated string from userspace. | ||
44 | * @dst: Destination address, in kernel space. This buffer must be at | ||
45 | * least @count bytes long. | ||
46 | * @src: Source address, in user space. | ||
47 | * @count: Maximum number of bytes to copy, including the trailing NUL. | ||
48 | * | ||
49 | * Copies a NUL-terminated string from userspace to kernel space. | ||
50 | * | ||
51 | * On success, returns the length of the string (not including the trailing | ||
52 | * NUL). | ||
53 | * | ||
54 | * If access to userspace fails, returns -EFAULT (some data may have been | ||
55 | * copied). | ||
56 | * | ||
57 | * If @count is smaller than the length of the string, copies @count bytes | ||
58 | * and returns @count. | ||
59 | */ | ||
60 | |||
61 | static inline int strncpy_from_user(char *dst, const char __user *src, int count) | ||
62 | { | ||
63 | return(CHOOSE_MODE_PROC(strncpy_from_user_tt, strncpy_from_user_skas, | ||
64 | dst, src, count)); | ||
65 | } | ||
66 | |||
67 | /* | ||
68 | * __clear_user: - Zero a block of memory in user space, with less checking. | ||
69 | * @to: Destination address, in user space. | ||
70 | * @n: Number of bytes to zero. | ||
71 | * | ||
72 | * Zero a block of memory in user space. Caller must check | ||
73 | * the specified block with access_ok() before calling this function. | ||
74 | * | ||
75 | * Returns number of bytes that could not be cleared. | ||
76 | * On success, this will be zero. | ||
77 | */ | ||
78 | static inline int __clear_user(void *mem, int len) | ||
79 | { | ||
80 | return(CHOOSE_MODE_PROC(__clear_user_tt, __clear_user_skas, mem, len)); | ||
81 | } | ||
82 | |||
83 | /* | ||
84 | * clear_user: - Zero a block of memory in user space. | ||
85 | * @to: Destination address, in user space. | ||
86 | * @n: Number of bytes to zero. | ||
87 | * | ||
88 | * Zero a block of memory in user space. | ||
89 | * | ||
90 | * Returns number of bytes that could not be cleared. | ||
91 | * On success, this will be zero. | ||
92 | */ | ||
93 | static inline int clear_user(void __user *mem, int len) | ||
94 | { | ||
95 | return(CHOOSE_MODE_PROC(clear_user_tt, clear_user_skas, mem, len)); | ||
96 | } | ||
97 | |||
98 | /* | ||
99 | * strlen_user: - Get the size of a string in user space. | ||
100 | * @str: The string to measure. | ||
101 | * @n: The maximum valid length | ||
102 | * | ||
103 | * Get the size of a NUL-terminated string in user space. | ||
104 | * | ||
105 | * Returns the size of the string INCLUDING the terminating NUL. | ||
106 | * On exception, returns 0. | ||
107 | * If the string is too long, returns a value greater than @n. | ||
108 | */ | ||
109 | static inline int strnlen_user(const void __user *str, long len) | ||
110 | { | ||
111 | return(CHOOSE_MODE_PROC(strnlen_user_tt, strnlen_user_skas, str, len)); | ||
112 | } | ||
113 | |||
114 | #endif | ||
115 | |||
116 | /* | ||
117 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
118 | * Emacs will notice this stuff at the end of the file and automatically | ||
119 | * adjust the settings for this buffer only. This must remain at the end | ||
120 | * of the file. | ||
121 | * --------------------------------------------------------------------------- | ||
122 | * Local variables: | ||
123 | * c-file-style: "linux" | ||
124 | * End: | ||
125 | */ | ||