Changeset 35f48f2 in mainline for uspace/srv/fs/ext4fs/ext4fs_ops.c
- Timestamp:
- 2011-11-09T08:48:06Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade
- Children:
- 1e65444
- Parents:
- 0f09d4ea
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/ext4fs/ext4fs_ops.c
r0f09d4ea r35f48f2 929 929 930 930 int rc; 931 int flags = BLOCK_FLAGS_NONE; 931 932 fs_node_t *fn; 932 933 ext4fs_node_t *enode; … … 937 938 block_t *write_block; 938 939 uint32_t fblock, iblock; 940 uint32_t old_inode_size; 939 941 940 942 rc = ext4fs_node_get(&fn, service_id, index); … … 960 962 bytes = min(len, block_size - (pos % block_size)); 961 963 964 if (bytes == block_size) { 965 flags = BLOCK_FLAGS_NOREAD; 966 } 967 962 968 EXT4FS_DBG("bytes == \%u", bytes); 963 969 … … 966 972 rc = ext4_filesystem_get_inode_data_block_index(fs, inode_ref->inode, iblock, &fblock); 967 973 968 969 // TODO allocation if fblock == 0970 974 if (fblock == 0) { 971 975 EXT4FS_DBG("Allocate block !!!"); 972 973 return ENOTSUP; 974 } 975 976 // TODO flags 977 rc = block_get(&write_block, service_id, fblock, 0); 976 rc = ext4_bitmap_alloc_block(fs, inode_ref, &fblock); 977 if (rc != EOK) { 978 ext4fs_node_put(fn); 979 async_answer_0(callid, rc); 980 return rc; 981 } 982 983 ext4_filesystem_set_inode_data_block_index(fs, inode_ref->inode, iblock, fblock); 984 inode_ref->dirty = true; 985 986 flags = BLOCK_FLAGS_NOREAD; 987 988 EXT4FS_DBG("block \%u allocated", fblock); 989 } 990 991 rc = block_get(&write_block, service_id, fblock, flags); 978 992 if (rc != EOK) { 979 993 ext4fs_node_put(fn); … … 982 996 } 983 997 984 /* 985 if (flags == BLOCK_FLAGS_NOREAD) 986 memset(b->data, 0, sbi->block_size); 987 */ 988 989 async_data_write_finalize(callid, write_block->data + (pos % block_size), bytes); 998 EXT4FS_DBG("block loaded"); 999 1000 if (flags == BLOCK_FLAGS_NOREAD) { 1001 EXT4FS_DBG("fill block with zeros"); 1002 memset(write_block->data, 0, block_size); 1003 } 1004 1005 rc = async_data_write_finalize(callid, write_block->data + (pos % block_size), bytes); 1006 if (rc != EOK) { 1007 EXT4FS_DBG("error in write finalize \%d", rc); 1008 } 1009 1010 char *data = write_block->data + (pos % block_size); 1011 for (uint32_t x = 0; x < bytes; ++x) { 1012 printf("%c", data[x]); 1013 } 1014 printf("\n"); 1015 990 1016 write_block->dirty = true; 991 1017 … … 996 1022 } 997 1023 998 /* 999 if (pos + bytes > ino_i->i_size) { 1000 ino_i->i_size = pos + bytes; 1001 ino_i->dirty = true; 1002 } 1003 *nsize = ino_i->i_size; 1024 EXT4FS_DBG("writing finished"); 1025 1026 old_inode_size = ext4_inode_get_size(fs->superblock, inode_ref->inode); 1027 if (pos + bytes > old_inode_size) { 1028 ext4_inode_set_size(inode_ref->inode, pos + bytes); 1029 inode_ref->dirty = true; 1030 } 1031 1032 *nsize = ext4_inode_get_size(fs->superblock, inode_ref->inode); 1004 1033 *wbytes = bytes; 1005 */ 1034 1006 1035 return ext4fs_node_put(fn); 1007 1036 } … … 1105 1134 static int ext4fs_sync(service_id_t service_id, fs_index_t index) 1106 1135 { 1107 EXT4FS_DBG("not supported"); 1108 1109 // TODO 1110 return ENOTSUP; 1136 EXT4FS_DBG(""); 1137 1138 int rc; 1139 fs_node_t *fn; 1140 ext4fs_node_t *enode; 1141 1142 rc = ext4fs_node_get(&fn, service_id, index); 1143 if (rc != EOK) { 1144 return rc; 1145 } 1146 1147 enode = EXT4FS_NODE(fn); 1148 enode->inode_ref->dirty = true; 1149 1150 return ext4fs_node_put(fn); 1111 1151 } 1112 1152
Note:
See TracChangeset
for help on using the changeset viewer.