Changeset 421 for trunk/kernel/syscalls/sys_write.c
- Timestamp:
- Jan 29, 2018, 5:40:34 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_write.c
r418 r421 92 92 cxy_t file_cxy = GET_CXY( file_xp ); 93 93 94 // check file writable 95 uint32_t attr = hal_remote_lw( XPTR( file_cxy , &file_ptr->attr ) ); 96 if( (attr & FD_ATTR_WRITE_ENABLE) == 0 ) 97 { 98 printk("\n[ERROR] in %s : file %d not writable in process %x\n", 99 __FUNCTION__ , file_id , process->pid ); 100 this->errno = EBADFD; 101 return -1; 102 } 103 94 104 95 // get file type 105 96 vfs_inode_type_t type = hal_remote_lw( XPTR( file_cxy , &file_ptr->type ) ); 106 97 107 98 // action depend on file type 108 if( type == INODE_TYPE_FILE ) // transfer count bytes to filemapper99 if( type == INODE_TYPE_FILE ) // check file writable & write to mapper 109 100 { 101 // check file writable 102 uint32_t attr = hal_remote_lw( XPTR( file_cxy , &file_ptr->attr ) ); 103 if( (attr & FD_ATTR_WRITE_ENABLE) == 0 ) 104 { 105 printk("\n[ERROR] in %s : file %d not writable in process %x\n", 106 __FUNCTION__ , file_id , process->pid ); 107 this->errno = EBADFD; 108 return -1; 109 } 110 111 // move count bytes to mapper 110 112 nbytes = vfs_user_move( false, // from buffer to mapper 111 113 file_xp, … … 113 115 count ); 114 116 } 115 else if( type == INODE_TYPE_DEV ) // transfer count bytesto device117 else if( type == INODE_TYPE_DEV ) // check ownership & write to device 116 118 { 119 // move count bytes to device 117 120 nbytes = devfs_user_move( false, // from buffer to device 118 121 file_xp, … … 123 126 { 124 127 nbytes = 0; 125 panic("file type %d non supported", type );128 assert( false , __FUNCTION__ , "file type %d non supported\n", type ); 126 129 } 127 130 … … 148 151 #endif 149 152 150 #if CONFIG_WRITE_DEBUG153 #if (CONFIG_WRITE_DEBUG & 0x1) 151 154 printk("\n@@@@@@@@@@@@ timing to write character %c\n" 152 155 " - enter_sys_write = %d\n"
Note: See TracChangeset
for help on using the changeset viewer.