This source file includes following definitions.
- hexagon_strncpy_from_user
1
2
3
4
5
6
7
8 #ifndef _ASM_UACCESS_H
9 #define _ASM_UACCESS_H
10
11
12
13 #include <linux/mm.h>
14 #include <asm/sections.h>
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 #define __access_ok(addr, size) \
37 ((get_fs().seg == KERNEL_DS.seg) || \
38 (((unsigned long)addr < get_fs().seg) && \
39 (unsigned long)size < (get_fs().seg - (unsigned long)addr)))
40
41
42
43
44
45
46
47
48
49
50
51 unsigned long raw_copy_from_user(void *to, const void __user *from,
52 unsigned long n);
53 unsigned long raw_copy_to_user(void __user *to, const void *from,
54 unsigned long n);
55 #define INLINE_COPY_FROM_USER
56 #define INLINE_COPY_TO_USER
57
58 __kernel_size_t __clear_user_hexagon(void __user *dest, unsigned long count);
59 #define __clear_user(a, s) __clear_user_hexagon((a), (s))
60
61 #define __strncpy_from_user(dst, src, n) hexagon_strncpy_from_user(dst, src, n)
62
63
64 #define __strnlen_user __strnlen_user
65
66 extern long __strnlen_user(const char __user *src, long n);
67
68 static inline long hexagon_strncpy_from_user(char *dst, const char __user *src,
69 long n);
70
71 #include <asm-generic/uaccess.h>
72
73
74 static inline long hexagon_strncpy_from_user(char *dst, const char __user *src,
75 long n)
76 {
77 long res = __strnlen_user(src, n);
78
79 if (unlikely(!res))
80 return -EFAULT;
81
82 if (res > n) {
83 long left = raw_copy_from_user(dst, src, n);
84 if (unlikely(left))
85 memset(dst + (n - left), 0, left);
86 return n;
87 } else {
88 long left = raw_copy_from_user(dst, src, res);
89 if (unlikely(left))
90 memset(dst + (res - left), 0, left);
91 return res-1;
92 }
93 }
94
95 #endif