Path: blob/main/sys/compat/linuxkpi/common/include/asm/uaccess.h
39604 views
/*-1* Copyright (c) 2010 Isilon Systems, Inc.2* Copyright (c) 2010 iX Systems, Inc.3* Copyright (c) 2010 Panasas, Inc.4* Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.5* All rights reserved.6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice unmodified, this list of conditions, and the following12* disclaimer.13* 2. Redistributions in binary form must reproduce the above copyright14* notice, this list of conditions and the following disclaimer in the15* documentation and/or other materials provided with the distribution.16*17* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR18* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES19* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.20* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,21* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT22* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,23* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY24* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF26* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.27*/28#ifndef _LINUXKPI_ASM_UACCESS_H_29#define _LINUXKPI_ASM_UACCESS_H_3031#include <linux/uaccess.h>3233static inline long34copy_to_user(void *to, const void *from, unsigned long n)35{36if (linux_copyout(from, to, n) != 0)37return n;38return 0;39}40#define __copy_to_user(...) copy_to_user(__VA_ARGS__)4142static inline long43copy_from_user(void *to, const void *from, unsigned long n)44{45if (linux_copyin(from, to, n) != 0)46return n;47return 0;48}49#define __copy_from_user(...) copy_from_user(__VA_ARGS__)50#define __copy_in_user(...) copy_from_user(__VA_ARGS__)5152#define user_access_begin(ptr, len) access_ok(ptr, len)53#define user_access_end() do { } while (0)5455#define user_write_access_begin(ptr, len) access_ok(ptr, len)56#define user_write_access_end() do { } while (0)5758#define unsafe_get_user(x, ptr, err) do { \59if (unlikely(__get_user(x, ptr))) \60goto err; \61} while (0)6263#define unsafe_put_user(x, ptr, err) do { \64if (unlikely(__put_user(x, ptr))) \65goto err; \66} while (0)6768#endif /* _LINUXKPI_ASM_UACCESS_H_ */697071