Changeset 656 for trunk/kernel/syscalls/sys_read.c
- Timestamp:
- Dec 6, 2019, 12:07:51 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_read.c
r635 r656 63 63 cxy_t file_cxy; // remote file cluster identifier 64 64 uint32_t file_type; // file type 65 uint32_t file_attr; // file_attribute 65 uint32_t file_offset; // file offset 66 uint32_t file_attr; // file attributes 67 vfs_inode_t * inode_ptr; // local pointer on file inode 66 68 uint32_t nbytes; // number of bytes actually read 67 69 reg_t save_sr; // required to enable IRQs during syscall … … 129 131 file_cxy = GET_CXY( file_xp ); 130 132 131 // get file type and attributes 132 file_type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type ) ); 133 file_attr = hal_remote_l32( XPTR( file_cxy , &file_ptr->attr ) ); 133 // get inode, file type, offset and attributes 134 inode_ptr = hal_remote_lpt( XPTR( file_cxy , &file_ptr->inode ) ); 135 file_type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type ) ); 136 file_offset = hal_remote_l32( XPTR( file_cxy , &file_ptr->offset ) ); 137 file_attr = hal_remote_l32( XPTR( file_cxy , &file_ptr->attr ) ); 134 138 135 139 // enable IRQs 136 140 hal_enable_irq( &save_sr ); 137 141 138 // action depend on file type 142 // action depend on file type: 143 139 144 if( file_type == INODE_TYPE_FILE ) // read from file mapper 140 145 { … … 152 157 } 153 158 154 // move count bytes from mapper159 // try to move count bytes from mapper 155 160 nbytes = vfs_user_move( true, // from mapper to buffer 156 161 file_xp, 157 162 vaddr, 158 163 count ); 159 if( nbytes != count )160 {161 162 #if DEBUG_SYSCALLS_ERROR163 printk("\n[ERROR] in %s : thread[%x,‰x] cannot read %d bytes from file %d\n",164 __FUNCTION__, process->pid, this->trdid, count, file_id );165 #endif166 this->errno = EIO;167 hal_restore_irq( save_sr );168 return -1;169 }170 164 } 171 165 else if( file_type == INODE_TYPE_DEV ) // read from TXT device … … 184 178 txt_owner_xp = hal_remote_l64( XPTR( chdev_cxy , &chdev_ptr->ext.txt.owner_xp ) ); 185 179 186 // checkTXT_RX ownership180 // wait for TXT_RX ownership 187 181 if ( process_owner_xp != txt_owner_xp ) 188 182 { … … 202 196 } 203 197 204 // move count bytes fromdevice198 // try to move count bytes from TXT device 205 199 nbytes = devfs_user_move( true, // from device to buffer 206 200 file_xp, 207 201 vaddr, 208 202 count ); 209 if( nbytes != count )210 {211 212 #if DEBUG_SYSCALLS_ERROR213 printk("\n[ERROR] in %s : thread[%x,‰x] cannot read data from file %d\n",214 __FUNCTION__, process->pid, this->trdid, file_id );215 #endif216 this->errno = EIO;217 hal_restore_irq( save_sr );218 return -1;219 }220 203 } 221 204 else // not FILE and not DEV … … 229 212 hal_restore_irq( save_sr ); 230 213 return -1; 214 } 215 216 // check error 217 if( nbytes == 0xFFFFFFFF ) 218 { 219 220 #if DEBUG_SYSCALLS_ERROR 221 printk("\n[ERROR] in %s : thread[%x,‰x] cannot read data from file %d\n", 222 __FUNCTION__, process->pid, this->trdid, file_id ); 223 #endif 224 this->errno = EIO; 225 hal_restore_irq( save_sr ); 226 return -1; 231 227 } 232 228
Note: See TracChangeset
for help on using the changeset viewer.