um: kill dead code around uaccess
[deliverable/linux.git] / arch / um / include / shared / um_uaccess.h
CommitLineData
1da177e4 1/*
ae2587e4 2 * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
1da177e4
LT
3 * Licensed under the GPL
4 */
5
6#ifndef __ARCH_UM_UACCESS_H
7#define __ARCH_UM_UACCESS_H
8
8192ab42
JD
9#include <asm/elf.h>
10#include <asm/fixmap.h>
11#include "sysdep/archsetjmp.h"
bf001b26 12
7a590611
PBG
13#define __under_task_size(addr, size) \
14 (((unsigned long) (addr) < TASK_SIZE) && \
ae2587e4 15 (((unsigned long) (addr) + (size)) < TASK_SIZE))
7a590611
PBG
16
17#define __access_ok_vsyscall(type, addr, size) \
18 ((type == VERIFY_READ) && \
19 ((unsigned long) (addr) >= FIXADDR_USER_START) && \
20 ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \
21 ((unsigned long) (addr) + (size) >= (unsigned long)(addr)))
22
23#define __addr_range_nowrap(addr, size) \
24 ((unsigned long) (addr) <= ((unsigned long) (addr) + (size)))
25
1da177e4 26#define access_ok(type, addr, size) \
7a590611
PBG
27 (__addr_range_nowrap(addr, size) && \
28 (__under_task_size(addr, size) || \
29 __access_ok_vsyscall(type, addr, size) || \
6aa802ce 30 segment_eq(get_fs(), KERNEL_DS)))
1da177e4 31
6aa802ce
JD
32extern int copy_from_user(void *to, const void __user *from, int n);
33extern int copy_to_user(void __user *to, const void *from, int n);
1da177e4
LT
34
35/*
36 * strncpy_from_user: - Copy a NUL terminated string from userspace.
37 * @dst: Destination address, in kernel space. This buffer must be at
38 * least @count bytes long.
39 * @src: Source address, in user space.
40 * @count: Maximum number of bytes to copy, including the trailing NUL.
41 *
42 * Copies a NUL-terminated string from userspace to kernel space.
43 *
44 * On success, returns the length of the string (not including the trailing
45 * NUL).
46 *
47 * If access to userspace fails, returns -EFAULT (some data may have been
48 * copied).
49 *
50 * If @count is smaller than the length of the string, copies @count bytes
51 * and returns @count.
52 */
53
6aa802ce 54extern int strncpy_from_user(char *dst, const char __user *src, int count);
1da177e4
LT
55
56/*
57 * __clear_user: - Zero a block of memory in user space, with less checking.
58 * @to: Destination address, in user space.
59 * @n: Number of bytes to zero.
60 *
61 * Zero a block of memory in user space. Caller must check
62 * the specified block with access_ok() before calling this function.
63 *
64 * Returns number of bytes that could not be cleared.
65 * On success, this will be zero.
66 */
6aa802ce 67extern int __clear_user(void __user *mem, int len);
1da177e4
LT
68
69/*
70 * clear_user: - Zero a block of memory in user space.
71 * @to: Destination address, in user space.
72 * @n: Number of bytes to zero.
73 *
74 * Zero a block of memory in user space.
75 *
76 * Returns number of bytes that could not be cleared.
77 * On success, this will be zero.
78 */
6aa802ce 79extern int clear_user(void __user *mem, int len);
1da177e4
LT
80
81/*
82 * strlen_user: - Get the size of a string in user space.
83 * @str: The string to measure.
84 * @n: The maximum valid length
85 *
86 * Get the size of a NUL-terminated string in user space.
87 *
88 * Returns the size of the string INCLUDING the terminating NUL.
89 * On exception, returns 0.
90 * If the string is too long, returns a value greater than @n.
91 */
6aa802ce 92extern int strnlen_user(const void __user *str, int len);
1da177e4
LT
93
94#endif
This page took 0.51392 seconds and 5 git commands to generate.