Changes in uspace/lib/ext4/src/filesystem.c [b7fd2a0:cde999a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/src/filesystem.c
rb7fd2a0 rcde999a 54 54 #include "ext4/superblock.h" 55 55 56 static errno_t ext4_filesystem_check_features(ext4_filesystem_t *, bool *);56 static int ext4_filesystem_check_features(ext4_filesystem_t *, bool *); 57 57 58 58 /** Initialize filesystem for opening. … … 67 67 * 68 68 */ 69 static errno_t ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id,69 static int ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id, 70 70 enum cache_mode cmode) 71 71 { 72 errno_t rc;72 int rc; 73 73 ext4_superblock_t *temp_superblock = NULL; 74 74 … … 164 164 * 165 165 */ 166 errno_t ext4_filesystem_probe(service_id_t service_id)166 int ext4_filesystem_probe(service_id_t service_id) 167 167 { 168 168 ext4_filesystem_t *fs = NULL; 169 errno_t rc;169 int rc; 170 170 171 171 fs = calloc(1, sizeof(ext4_filesystem_t)); … … 195 195 * 196 196 */ 197 errno_t ext4_filesystem_open(ext4_instance_t *inst, service_id_t service_id,197 int ext4_filesystem_open(ext4_instance_t *inst, service_id_t service_id, 198 198 enum cache_mode cmode, aoff64_t *size, ext4_filesystem_t **rfs) 199 199 { 200 200 ext4_filesystem_t *fs = NULL; 201 201 fs_node_t *root_node = NULL; 202 errno_t rc;202 int rc; 203 203 204 204 fs = calloc(1, sizeof(ext4_filesystem_t)); … … 256 256 * 257 257 */ 258 errno_t ext4_filesystem_close(ext4_filesystem_t *fs)258 int ext4_filesystem_close(ext4_filesystem_t *fs) 259 259 { 260 260 /* Write the superblock to the device */ 261 261 ext4_superblock_set_state(fs->superblock, EXT4_SUPERBLOCK_STATE_VALID_FS); 262 errno_t rc = ext4_superblock_write_direct(fs->device, fs->superblock);262 int rc = ext4_superblock_write_direct(fs->device, fs->superblock); 263 263 if (rc != EOK) 264 264 return rc; … … 281 281 * 282 282 */ 283 static errno_t ext4_filesystem_check_features(ext4_filesystem_t *fs,283 static int ext4_filesystem_check_features(ext4_filesystem_t *fs, 284 284 bool *read_only) 285 285 { … … 380 380 * 381 381 */ 382 static errno_t ext4_filesystem_init_block_bitmap(ext4_block_group_ref_t *bg_ref)382 static int ext4_filesystem_init_block_bitmap(ext4_block_group_ref_t *bg_ref) 383 383 { 384 384 uint64_t itb; … … 394 394 395 395 block_t *bitmap_block; 396 errno_t rc = block_get(&bitmap_block, bg_ref->fs->device,396 int rc = block_get(&bitmap_block, bg_ref->fs->device, 397 397 bitmap_block_addr, BLOCK_FLAGS_NOREAD); 398 398 if (rc != EOK) … … 451 451 * 452 452 */ 453 static errno_t ext4_filesystem_init_inode_bitmap(ext4_block_group_ref_t *bg_ref)453 static int ext4_filesystem_init_inode_bitmap(ext4_block_group_ref_t *bg_ref) 454 454 { 455 455 /* Load bitmap */ … … 458 458 block_t *bitmap_block; 459 459 460 errno_t rc = block_get(&bitmap_block, bg_ref->fs->device,460 int rc = block_get(&bitmap_block, bg_ref->fs->device, 461 461 bitmap_block_addr, BLOCK_FLAGS_NOREAD); 462 462 if (rc != EOK) … … 494 494 * 495 495 */ 496 static errno_t ext4_filesystem_init_inode_table(ext4_block_group_ref_t *bg_ref)496 static int ext4_filesystem_init_inode_table(ext4_block_group_ref_t *bg_ref) 497 497 { 498 498 ext4_superblock_t *sb = bg_ref->fs->superblock; … … 519 519 for (uint32_t fblock = first_block; fblock <= last_block; ++fblock) { 520 520 block_t *block; 521 errno_t rc = block_get(&block, bg_ref->fs->device, fblock,521 int rc = block_get(&block, bg_ref->fs->device, fblock, 522 522 BLOCK_FLAGS_NOREAD); 523 523 if (rc != EOK) … … 544 544 * 545 545 */ 546 errno_t ext4_filesystem_get_block_group_ref(ext4_filesystem_t *fs, uint32_t bgid,546 int ext4_filesystem_get_block_group_ref(ext4_filesystem_t *fs, uint32_t bgid, 547 547 ext4_block_group_ref_t **ref) 548 548 { … … 568 568 569 569 /* Load block with descriptors */ 570 errno_t rc = block_get(&newref->block, fs->device, block_id, 0);570 int rc = block_get(&newref->block, fs->device, block_id, 0); 571 571 if (rc != EOK) { 572 572 free(newref); … … 804 804 * 805 805 */ 806 errno_t ext4_filesystem_put_block_group_ref(ext4_block_group_ref_t *ref)806 int ext4_filesystem_put_block_group_ref(ext4_block_group_ref_t *ref) 807 807 { 808 808 /* Check if reference modified */ … … 819 819 820 820 /* Put back block, that contains block group descriptor */ 821 errno_t rc = block_put(ref->block);821 int rc = block_put(ref->block); 822 822 free(ref); 823 823 … … 834 834 * 835 835 */ 836 errno_t ext4_filesystem_get_inode_ref(ext4_filesystem_t *fs, uint32_t index,836 int ext4_filesystem_get_inode_ref(ext4_filesystem_t *fs, uint32_t index, 837 837 ext4_inode_ref_t **ref) 838 838 { … … 857 857 /* Load block group, where i-node is located */ 858 858 ext4_block_group_ref_t *bg_ref; 859 errno_t rc = ext4_filesystem_get_block_group_ref(fs, block_group, &bg_ref);859 int rc = ext4_filesystem_get_block_group_ref(fs, block_group, &bg_ref); 860 860 if (rc != EOK) { 861 861 free(newref); … … 909 909 * 910 910 */ 911 errno_t ext4_filesystem_put_inode_ref(ext4_inode_ref_t *ref)911 int ext4_filesystem_put_inode_ref(ext4_inode_ref_t *ref) 912 912 { 913 913 /* Check if reference modified */ … … 918 918 919 919 /* Put back block, that contains i-node */ 920 errno_t rc = block_put(ref->block);920 int rc = block_put(ref->block); 921 921 free(ref); 922 922 … … 933 933 * 934 934 */ 935 errno_t ext4_filesystem_alloc_inode(ext4_filesystem_t *fs,935 int ext4_filesystem_alloc_inode(ext4_filesystem_t *fs, 936 936 ext4_inode_ref_t **inode_ref, int flags) 937 937 { … … 943 943 /* Allocate inode by allocation algorithm */ 944 944 uint32_t index; 945 errno_t rc = ext4_ialloc_alloc_inode(fs, &index, is_dir);945 int rc = ext4_ialloc_alloc_inode(fs, &index, is_dir); 946 946 if (rc != EOK) 947 947 return rc; … … 1025 1025 * 1026 1026 */ 1027 errno_t ext4_filesystem_free_inode(ext4_inode_ref_t *inode_ref)1027 int ext4_filesystem_free_inode(ext4_inode_ref_t *inode_ref) 1028 1028 { 1029 1029 ext4_filesystem_t *fs = inode_ref->fs; … … 1042 1042 uint32_t fblock = ext4_inode_get_indirect_block(inode_ref->inode, 0); 1043 1043 if (fblock != 0) { 1044 errno_t rc = ext4_balloc_free_block(inode_ref, fblock);1044 int rc = ext4_balloc_free_block(inode_ref, fblock); 1045 1045 if (rc != EOK) 1046 1046 return rc; … … 1056 1056 fblock = ext4_inode_get_indirect_block(inode_ref->inode, 1); 1057 1057 if (fblock != 0) { 1058 errno_t rc = block_get(&block, fs->device, fblock, BLOCK_FLAGS_NONE);1058 int rc = block_get(&block, fs->device, fblock, BLOCK_FLAGS_NONE); 1059 1059 if (rc != EOK) 1060 1060 return rc; … … 1088 1088 fblock = ext4_inode_get_indirect_block(inode_ref->inode, 2); 1089 1089 if (fblock != 0) { 1090 errno_t rc = block_get(&block, fs->device, fblock, BLOCK_FLAGS_NONE);1090 int rc = block_get(&block, fs->device, fblock, BLOCK_FLAGS_NONE); 1091 1091 if (rc != EOK) 1092 1092 return rc; … … 1153 1153 inode_ref->inode, fs->superblock); 1154 1154 if (xattr_block) { 1155 errno_t rc = ext4_balloc_free_block(inode_ref, xattr_block);1155 int rc = ext4_balloc_free_block(inode_ref, xattr_block); 1156 1156 if (rc != EOK) 1157 1157 return rc; … … 1161 1161 1162 1162 /* Free inode by allocator */ 1163 errno_t rc;1163 int rc; 1164 1164 if (ext4_inode_is_type(fs->superblock, inode_ref->inode, 1165 1165 EXT4_INODE_MODE_DIRECTORY)) … … 1179 1179 * 1180 1180 */ 1181 errno_t ext4_filesystem_truncate_inode(ext4_inode_ref_t *inode_ref,1181 int ext4_filesystem_truncate_inode(ext4_inode_ref_t *inode_ref, 1182 1182 aoff64_t new_size) 1183 1183 { … … 1212 1212 (ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS))) { 1213 1213 /* Extents require special operation */ 1214 errno_t rc = ext4_extent_release_blocks_from(inode_ref,1214 int rc = ext4_extent_release_blocks_from(inode_ref, 1215 1215 old_blocks_count - diff_blocks_count); 1216 1216 if (rc != EOK) … … 1221 1221 /* Starting from 1 because of logical blocks are numbered from 0 */ 1222 1222 for (uint32_t i = 1; i <= diff_blocks_count; ++i) { 1223 errno_t rc = ext4_filesystem_release_inode_block(inode_ref,1223 int rc = ext4_filesystem_release_inode_block(inode_ref, 1224 1224 old_blocks_count - i); 1225 1225 if (rc != EOK) … … 1244 1244 * 1245 1245 */ 1246 errno_t ext4_filesystem_get_inode_data_block_index(ext4_inode_ref_t *inode_ref,1246 int ext4_filesystem_get_inode_data_block_index(ext4_inode_ref_t *inode_ref, 1247 1247 aoff64_t iblock, uint32_t *fblock) 1248 1248 { … … 1261 1261 EXT4_FEATURE_INCOMPAT_EXTENTS)) && 1262 1262 (ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS))) { 1263 errno_t rc = ext4_extent_find_block(inode_ref, iblock, ¤t_block);1263 int rc = ext4_extent_find_block(inode_ref, iblock, ¤t_block); 1264 1264 if (rc != EOK) 1265 1265 return rc; … … 1311 1311 while (level > 0) { 1312 1312 /* Load indirect block */ 1313 errno_t rc = block_get(&block, fs->device, current_block, 0);1313 int rc = block_get(&block, fs->device, current_block, 0); 1314 1314 if (rc != EOK) 1315 1315 return rc; … … 1357 1357 * 1358 1358 */ 1359 errno_t ext4_filesystem_set_inode_data_block_index(ext4_inode_ref_t *inode_ref,1359 int ext4_filesystem_set_inode_data_block_index(ext4_inode_ref_t *inode_ref, 1360 1360 aoff64_t iblock, uint32_t fblock) 1361 1361 { … … 1407 1407 if (current_block == 0) { 1408 1408 /* Allocate new indirect block */ 1409 errno_t rc = ext4_balloc_alloc_block(inode_ref, &new_block_addr);1409 int rc = ext4_balloc_alloc_block(inode_ref, &new_block_addr); 1410 1410 if (rc != EOK) 1411 1411 return rc; … … 1441 1441 */ 1442 1442 while (level > 0) { 1443 errno_t rc = block_get(&block, fs->device, current_block, 0);1443 int rc = block_get(&block, fs->device, current_block, 0); 1444 1444 if (rc != EOK) 1445 1445 return rc; … … 1518 1518 * 1519 1519 */ 1520 errno_t ext4_filesystem_release_inode_block(ext4_inode_ref_t *inode_ref,1520 int ext4_filesystem_release_inode_block(ext4_inode_ref_t *inode_ref, 1521 1521 uint32_t iblock) 1522 1522 { … … 1575 1575 return EOK; 1576 1576 1577 errno_t rc = block_get(&block, fs->device, current_block, 0);1577 int rc = block_get(&block, fs->device, current_block, 0); 1578 1578 if (rc != EOK) 1579 1579 return rc; … … 1625 1625 * 1626 1626 */ 1627 errno_t ext4_filesystem_append_inode_block(ext4_inode_ref_t *inode_ref,1627 int ext4_filesystem_append_inode_block(ext4_inode_ref_t *inode_ref, 1628 1628 uint32_t *fblock, uint32_t *iblock) 1629 1629 { … … 1649 1649 /* Allocate new physical block */ 1650 1650 uint32_t phys_block; 1651 errno_t rc = ext4_balloc_alloc_block(inode_ref, &phys_block);1651 int rc = ext4_balloc_alloc_block(inode_ref, &phys_block); 1652 1652 if (rc != EOK) 1653 1653 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.