Changeset 656 for trunk/kernel/syscalls/sys_write.c
- Timestamp:
- Dec 6, 2019, 12:07:51 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_write.c
r635 r656 62 62 cxy_t file_cxy; // remote file cluster identifier 63 63 uint32_t file_type; // file type 64 uint32_t file_offset; // currentfile offset65 uint32_t file_attr; // file _attribute64 uint32_t file_offset; // file offset 65 uint32_t file_attr; // file attributes 66 66 vfs_inode_t * inode_ptr; // local pointer on associated inode 67 67 uint32_t nbytes; // number of bytes actually written … … 138 138 hal_enable_irq( &save_sr ); 139 139 140 // action depend on file type 140 // action depend on file type: 141 141 142 if( file_type == INODE_TYPE_FILE ) // write to a file mapper 142 143 { … … 159 160 vaddr, 160 161 count ); 161 if ( nbytes != count )162 {163 164 #if DEBUG_SYSCALLS_ERROR165 printk("\n[ERROR] in %s : thread[%x,%x] cannot write %d bytes into file %d\n",166 __FUNCTION__ , process->pid, this->trdid, count, file_id );167 #endif168 hal_restore_irq( save_sr );169 this->errno = EIO;170 return -1;171 172 }173 174 // update file size in inode descriptor175 // only if (file_offset + count) > current_size176 // note: the parent directory entry in mapper will177 // be updated by the close syscall178 xptr_t inode_xp = XPTR( file_cxy , inode_ptr );179 vfs_inode_update_size( inode_xp , file_offset + count );180 162 } 181 163 else if( file_type == INODE_TYPE_DEV ) // write to TXT device … … 186 168 vaddr, 187 169 count ); 188 if( nbytes != count ) 189 { 170 } 171 else // not FILE and not DEV 172 { 173 174 #if DEBUG_SYSCALLS_ERROR 175 printk("\n[ERROR] in %s : thread[%x,%x] / illegal inode type %\n", 176 __FUNCTION__, vfs_inode_type_str( file_type ) ); 177 #endif 178 hal_restore_irq( save_sr ); 179 this->errno = EBADFD; 180 return -1; 181 } 182 183 // chek error 184 if( nbytes == 0xFFFFFFFF ) 185 { 190 186 191 187 #if DEBUG_SYSCALLS_ERROR … … 193 189 __FUNCTION__ , process->pid, this->trdid, file_id ); 194 190 #endif 195 hal_restore_irq( save_sr );196 this->errno = EIO;197 return -1;198 }199 }200 else // not FILE and not DEV201 {202 203 #if DEBUG_SYSCALLS_ERROR204 printk("\n[ERROR] in %s : thread[%x,%x] / illegal inode type %\n",205 __FUNCTION__, vfs_inode_type_str( file_type ) );206 #endif207 191 hal_restore_irq( save_sr ); 208 this->errno = EBADFD;209 192 this->errno = EIO; 193 return -1; 210 194 } 211 195
Note: See TracChangeset
for help on using the changeset viewer.