Changeset 421 for trunk/kernel/syscalls/sys_read.c
- Timestamp:
- Jan 29, 2018, 5:40:34 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_read.c
r418 r421 98 98 99 99 // enable IRQs 100 //hal_enable_irq( &save_sr );100 hal_enable_irq( &save_sr ); 101 101 102 102 // get extended pointer on remote file descriptor … … 129 129 130 130 // action depend on file type 131 if( type == INODE_TYPE_FILE ) // transfer count bytes from file mapper 132 { 131 if( type == INODE_TYPE_FILE ) // check file readable & read from mapper 132 { 133 // check file readable 134 uint32_t attr = hal_remote_lw( XPTR( file_cxy , &file_ptr->attr ) ); 135 if( (attr & FD_ATTR_READ_ENABLE) == 0 ) 136 { 137 printk("\n[ERROR] in %s : file %d not readable in process %x\n", 138 __FUNCTION__ , file_id , process->pid ); 139 this->errno = EBADFD; 140 return -1; 141 } 142 143 // move count bytes from mapper 133 144 nbytes = vfs_user_move( true, // from mapper to buffer 134 145 file_xp, … … 136 147 count ); 137 148 } 138 else if( type == INODE_TYPE_DEV ) // transfer count bytes from device 139 { 149 else if( type == INODE_TYPE_DEV ) // check ownership & read from from device 150 { 151 // move count bytes from device 140 152 nbytes = devfs_user_move( true, // from device to buffer 141 153 file_xp, 142 154 vaddr, 143 155 count ); 156 157 // check ownership 158 xptr_t chdev_xp = chdev_from_file( file_xp ); 159 cxy_t chdev_cxy = GET_CXY( chdev_xp ); 160 chdev_t * chdev_ptr = (chdev_t *)GET_PTR( chdev_xp ); 161 xptr_t owner_xp = hal_remote_lwd( XPTR( chdev_cxy , &chdev_ptr->ext.txt.owner_xp ) ); 162 163 if( XPTR( local_cxy , process ) != owner_xp ) 164 { 165 printk("\n[ERROR] in %s : process %x not in foreground for TXT%d\n", 166 __FUNCTION__, process->pid, hal_remote_lw( XPTR(chdev_cxy,&chdev_ptr->channel) ) ); 167 this->errno = EBADFD; 168 return -1; 169 } 144 170 } 145 171 else 146 172 { 147 173 nbytes = 0; 148 panic("file type %d non supported yet", type );174 assert( false , __FUNCTION__ , "file type %d non supported yet\n", type ); 149 175 } 150 176 … … 158 184 159 185 // restore IRQs 160 //hal_restore_irq( save_sr );186 hal_restore_irq( save_sr ); 161 187 162 188 hal_fence(); … … 171 197 #endif 172 198 173 #if CONFIG_READ_DEBUG199 #if (CONFIG_READ_DEBUG & 0x1) 174 200 exit_sys_read = (uint32_t)tm_end; 175 201
Note: See TracChangeset
for help on using the changeset viewer.