|
[ source navigation ] [ diff markup ] [ identifier search ] [ general search ] |
|||
|
001 /* Copyright (C) 2005 David Decotigny 001 /* Copyright (C) 2005 David Decotigny 002 002 003 This program is free software; you can redi 003 This program is free software; you can redistribute it and/or 004 modify it under the terms of the GNU Genera 004 modify it under the terms of the GNU General Public License 005 as published by the Free Software Foundatio 005 as published by the Free Software Foundation; either version 2 006 of the License, or (at your option) any lat 006 of the License, or (at your option) any later version. 007 007 008 This program is distributed in the hope tha 008 This program is distributed in the hope that it will be useful, 009 but WITHOUT ANY WARRANTY; without even the 009 but WITHOUT ANY WARRANTY; without even the implied warranty of 010 MERCHANTABILITY or FITNESS FOR A PARTICULAR 010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 011 GNU General Public License for more details 011 GNU General Public License for more details. 012 012 013 You should have received a copy of the GNU 013 You should have received a copy of the GNU General Public License 014 along with this program; if not, write to t 014 along with this program; if not, write to the Free Software 015 Foundation, Inc., 59 Temple Place - Suite 3 015 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 016 USA. 016 USA. 017 */ 017 */ 018 #ifndef _SOS_UACCESS_H_ 018 #ifndef _SOS_UACCESS_H_ 019 #define _SOS_UACCESS_H_ 019 #define _SOS_UACCESS_H_ 020 020 021 021 022 /** 022 /** 023 * @file uaccess.h 023 * @file uaccess.h 024 * 024 * 025 * Routines to access user-space data from ins 025 * Routines to access user-space data from inside the kernel space. 026 */ 026 */ 027 027 028 #include <sos/types.h> 028 #include <sos/types.h> 029 #include <sos/errno.h> 029 #include <sos/errno.h> 030 030 031 031 032 /** 032 /** 033 * Retrieve a bunch of data from the user spac 033 * Retrieve a bunch of data from the user space of the 034 * current_thread->process 034 * current_thread->process 035 * 035 * 036 * @return <0 on error ! Return the number of 036 * @return <0 on error ! Return the number of bytes successfully copied 037 * otherwise. 037 * otherwise. 038 */ 038 */ 039 sos_ret_t sos_memcpy_from_user(sos_vaddr_t ker 039 sos_ret_t sos_memcpy_from_user(sos_vaddr_t kernel_to, 040 sos_uaddr_t use 040 sos_uaddr_t user_from, 041 sos_size_t size 041 sos_size_t size); 042 042 043 043 044 /** 044 /** 045 * Transfer a bunch of data to the user space 045 * Transfer a bunch of data to the user space of the 046 * current_thread->process 046 * current_thread->process 047 * 047 * 048 * @return <0 n error ! Return the number of b 048 * @return <0 n error ! Return the number of bytes successfully copied 049 * otherwise. 049 * otherwise. 050 */ 050 */ 051 sos_ret_t sos_memcpy_to_user(sos_uaddr_t user_ 051 sos_ret_t sos_memcpy_to_user(sos_uaddr_t user_to, 052 sos_vaddr_t kerne 052 sos_vaddr_t kernel_from, 053 sos_size_t size); 053 sos_size_t size); 054 054 055 055 056 /** 056 /** 057 * @return the length of the given user space 057 * @return the length of the given user space string user_str 058 * (excluding the trailing \0), up to max_len 058 * (excluding the trailing \0), up to max_len bytes. <0 on error 059 * (unresolved page fault, etc.) 059 * (unresolved page fault, etc.) 060 */ 060 */ 061 sos_ret_t sos_strnlen_from_user(sos_uaddr_t us 061 sos_ret_t sos_strnlen_from_user(sos_uaddr_t user_str, sos_size_t max_len); 062 062 063 063 064 /** 064 /** 065 * Copy the given user space string to kernel 065 * Copy the given user space string to kernel space, up to max_len 066 * bytes (including trailing \0) 066 * bytes (including trailing \0) 067 * 067 * 068 * @return SOS_OK on success, <0 otherwise (un 068 * @return SOS_OK on success, <0 otherwise (unresolved page fault, etc.) 069 */ 069 */ 070 sos_ret_t sos_strzcpy_from_user(char *kernel_t 070 sos_ret_t sos_strzcpy_from_user(char *kernel_to, sos_uaddr_t user_from, 071 sos_size_t max 071 sos_size_t max_len); 072 072 073 073 074 /** 074 /** 075 * Copy the given kernel string to user space, 075 * Copy the given kernel string to user space, up to max_len bytes 076 * (including trailing \0) 076 * (including trailing \0) 077 * 077 * 078 * @return SOS_OK on success, <0 otherwise (un 078 * @return SOS_OK on success, <0 otherwise (unresolved page fault, etc.) 079 */ 079 */ 080 sos_ret_t sos_strzcpy_to_user(sos_uaddr_t user 080 sos_ret_t sos_strzcpy_to_user(sos_uaddr_t user_to, const char *kernel_from, 081 sos_size_t max_l 081 sos_size_t max_len); 082 082 083 083 084 /** 084 /** 085 * Copy the given user space string into a new 085 * Copy the given user space string into a new allocated kernel space 086 * area of the correct size, up to max_len byt 086 * area of the correct size, up to max_len bytes (including trailing 087 * \0) 087 * \0) 088 * 088 * 089 * @return SOS_OK on success + *kernel_to is s 089 * @return SOS_OK on success + *kernel_to is set to the freshly 090 * allocated kernel string, <0 otherwise (unre 090 * allocated kernel string, <0 otherwise (unresolved page fault, etc.) 091 */ 091 */ 092 sos_ret_t sos_strndup_from_user(char ** kernel 092 sos_ret_t sos_strndup_from_user(char ** kernel_to, sos_uaddr_t from_user, 093 sos_size_t max 093 sos_size_t max_len, 094 sos_ui32_t kma 094 sos_ui32_t kmalloc_flags); 095 095 096 #endif /* _SOS_UACCESS_H_ */ 096 #endif /* _SOS_UACCESS_H_ */
[ source navigation ] | [ diff markup ] | [ identifier search ] | [ general search ] |