Changeset 313 for trunk/kernel/syscalls
- Timestamp:
- Aug 2, 2017, 3:24:57 PM (7 years ago)
- Location:
- trunk/kernel/syscalls
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_read.c
r265 r313 41 41 { 42 42 error_t error; 43 paddr_t paddr; 44 char kbuf[CONFIG_VFS_KBUF_SIZE]; 45 43 paddr_t paddr; // required for user space checking 46 44 xptr_t file_xp; // remote file extended pointer 47 uint32_t nbytes; // number of bytes in one iteration48 45 49 46 thread_t * this = CURRENT_THREAD; … … 94 91 return -1; 95 92 } 96 97 // transfer at most CONFIG_VFS_KBUF_SIZE bytes per iteration 98 while( count ) 93 94 // transfer count bytes directly from mapper to user buffer 95 error = vfs_user_move( true, // to_buffer 96 file_xp , 97 buf, 98 count ); 99 100 if( error ) 99 101 { 100 if( count <= CONFIG_VFS_KBUF_SIZE ) 101 { 102 nbytes = count; 103 count = 0; 104 } 105 else 106 { 107 nbytes = CONFIG_VFS_KBUF_SIZE; 108 count = count - CONFIG_VFS_KBUF_SIZE; 109 } 110 111 // transfer nbytes to kernel buffer 112 error = vfs_move( true, // to_buffer 113 true, // is_user 114 file_xp , 115 kbuf , 116 nbytes ); 117 118 if( error ) 119 { 120 printk("\n[ERROR] in %s cannot read data from file %d\n", 121 __FUNCTION__ , file_id ); 122 this->errno = error; 123 return -1; 124 } 125 126 // copy kernel buffer to user space 127 hal_copy_to_uspace( buf , kbuf , nbytes ); 102 printk("\n[ERROR] in %s cannot read data from file %d\n", 103 __FUNCTION__ , file_id ); 104 this->errno = error; 105 return -1; 128 106 } 129 107 -
trunk/kernel/syscalls/sys_write.c
r265 r313 40 40 { 41 41 error_t error; 42 paddr_t paddr; 43 char kbuf[CONFIG_VFS_KBUF_SIZE]; 44 xptr_t file_xp; // remote file extended pointer 45 uint32_t nbytes; // number of bytes in one iteration 42 paddr_t paddr; // required for user space checking 43 xptr_t file_xp; // remote file extended pointer 46 44 47 45 thread_t * this = CURRENT_THREAD; … … 92 90 } 93 91 94 // transfer at most CONFIG_VFS_KBUF_SIZE bytes per iteration 95 while( count ) 92 // transfer count bytes directly from user buffer to mapper 93 error = vfs_user_move( false, // from buffer 94 file_xp, 95 kbuf , 96 nbytes ); 97 98 if( error ) 96 99 { 97 if( count <= CONFIG_VFS_KBUF_SIZE ) 98 { 99 nbytes = count; 100 count = 0; 101 } 102 else 103 { 104 nbytes = CONFIG_VFS_KBUF_SIZE; 105 count = count - CONFIG_VFS_KBUF_SIZE; 106 } 107 108 // copy user buffer to kernel buffer 109 hal_copy_to_uspace( buf , kbuf , nbytes ); 110 111 // transfer nbytes from kernel buffer 112 error = vfs_move( false, // from buffer 113 true, // is_user 114 file_xp, 115 kbuf , 116 nbytes ); 117 118 if( error ) 119 { 120 printk("\n[ERROR] in %s cannot read data from file %d\n", 121 __FUNCTION__ , file_id ); 122 this->errno = error; 123 return -1; 124 } 100 printk("\n[ERROR] in %s cannot read data from file %d\n", 101 __FUNCTION__ , file_id ); 102 this->errno = error; 103 return -1; 125 104 } 126 105
Note: See TracChangeset
for help on using the changeset viewer.