Changeset b7fd2a0 in mainline for uspace/lib/ext4
- Timestamp:
- 2018-01-13T03:10:29Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a53ed3a
- Parents:
- 36f0738
- Location:
- uspace/lib/ext4
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/include/ext4/balloc.h
r36f0738 rb7fd2a0 37 37 #include "types.h" 38 38 39 extern int ext4_balloc_free_block(ext4_inode_ref_t *, uint32_t);40 extern int ext4_balloc_free_blocks(ext4_inode_ref_t *, uint32_t, uint32_t);39 extern errno_t ext4_balloc_free_block(ext4_inode_ref_t *, uint32_t); 40 extern errno_t ext4_balloc_free_blocks(ext4_inode_ref_t *, uint32_t, uint32_t); 41 41 extern uint32_t ext4_balloc_get_first_data_block_in_group(ext4_superblock_t *, 42 42 ext4_block_group_ref_t *); 43 extern int ext4_balloc_alloc_block(ext4_inode_ref_t *, uint32_t *);44 extern int ext4_balloc_try_alloc_block(ext4_inode_ref_t *, uint32_t, bool *);43 extern errno_t ext4_balloc_alloc_block(ext4_inode_ref_t *, uint32_t *); 44 extern errno_t ext4_balloc_try_alloc_block(ext4_inode_ref_t *, uint32_t, bool *); 45 45 46 46 #endif -
uspace/lib/ext4/include/ext4/bitmap.h
r36f0738 rb7fd2a0 40 40 extern void ext4_bitmap_set_bit(uint8_t *, uint32_t); 41 41 extern bool ext4_bitmap_is_free_bit(uint8_t *, uint32_t); 42 extern int ext4_bitmap_find_free_byte_and_set_bit(uint8_t *, uint32_t,42 extern errno_t ext4_bitmap_find_free_byte_and_set_bit(uint8_t *, uint32_t, 43 43 uint32_t *, uint32_t); 44 extern int ext4_bitmap_find_free_bit_and_set(uint8_t *, uint32_t, uint32_t *,44 extern errno_t ext4_bitmap_find_free_bit_and_set(uint8_t *, uint32_t, uint32_t *, 45 45 uint32_t); 46 46 -
uspace/lib/ext4/include/ext4/directory.h
r36f0738 rb7fd2a0 53 53 ext4_directory_entry_ll_t *, uint8_t); 54 54 55 extern int ext4_directory_iterator_init(ext4_directory_iterator_t *,55 extern errno_t ext4_directory_iterator_init(ext4_directory_iterator_t *, 56 56 ext4_inode_ref_t *, aoff64_t); 57 extern int ext4_directory_iterator_next(ext4_directory_iterator_t *);58 extern int ext4_directory_iterator_fini(ext4_directory_iterator_t *);57 extern errno_t ext4_directory_iterator_next(ext4_directory_iterator_t *); 58 extern errno_t ext4_directory_iterator_fini(ext4_directory_iterator_t *); 59 59 60 60 extern void ext4_directory_write_entry(ext4_superblock_t *, 61 61 ext4_directory_entry_ll_t *, uint16_t, ext4_inode_ref_t *, 62 62 const char *, size_t); 63 extern int ext4_directory_add_entry(ext4_inode_ref_t *, const char *,63 extern errno_t ext4_directory_add_entry(ext4_inode_ref_t *, const char *, 64 64 ext4_inode_ref_t *); 65 extern int ext4_directory_find_entry(ext4_directory_search_result_t *,65 extern errno_t ext4_directory_find_entry(ext4_directory_search_result_t *, 66 66 ext4_inode_ref_t *, const char *); 67 extern int ext4_directory_remove_entry(ext4_inode_ref_t *, const char *);67 extern errno_t ext4_directory_remove_entry(ext4_inode_ref_t *, const char *); 68 68 69 extern int ext4_directory_try_insert_entry(ext4_superblock_t *, block_t *,69 extern errno_t ext4_directory_try_insert_entry(ext4_superblock_t *, block_t *, 70 70 ext4_inode_ref_t *, const char *, uint32_t); 71 71 72 extern int ext4_directory_find_in_block(block_t *, ext4_superblock_t *, size_t,72 extern errno_t ext4_directory_find_in_block(block_t *, ext4_superblock_t *, size_t, 73 73 const char *, ext4_directory_entry_ll_t **); 74 74 75 extern int ext4_directory_destroy_result(ext4_directory_search_result_t *);75 extern errno_t ext4_directory_destroy_result(ext4_directory_search_result_t *); 76 76 77 77 #endif -
uspace/lib/ext4/include/ext4/directory_index.h
r36f0738 rb7fd2a0 65 65 uint32_t); 66 66 67 extern int ext4_directory_dx_init(ext4_inode_ref_t *);68 extern int ext4_directory_dx_find_entry(ext4_directory_search_result_t *,67 extern errno_t ext4_directory_dx_init(ext4_inode_ref_t *); 68 extern errno_t ext4_directory_dx_find_entry(ext4_directory_search_result_t *, 69 69 ext4_inode_ref_t *, size_t, const char *); 70 extern int ext4_directory_dx_add_entry(ext4_inode_ref_t *, ext4_inode_ref_t *,70 extern errno_t ext4_directory_dx_add_entry(ext4_inode_ref_t *, ext4_inode_ref_t *, 71 71 const char *); 72 72 -
uspace/lib/ext4/include/ext4/extent.h
r36f0738 rb7fd2a0 61 61 extern void ext4_extent_header_set_generation(ext4_extent_header_t *, uint32_t); 62 62 63 extern int ext4_extent_find_block(ext4_inode_ref_t *, uint32_t, uint32_t *);64 extern int ext4_extent_release_blocks_from(ext4_inode_ref_t *, uint32_t);63 extern errno_t ext4_extent_find_block(ext4_inode_ref_t *, uint32_t, uint32_t *); 64 extern errno_t ext4_extent_release_blocks_from(ext4_inode_ref_t *, uint32_t); 65 65 66 extern int ext4_extent_append_block(ext4_inode_ref_t *, uint32_t *, uint32_t *,66 extern errno_t ext4_extent_append_block(ext4_inode_ref_t *, uint32_t *, uint32_t *, 67 67 bool); 68 68 -
uspace/lib/ext4/include/ext4/filesystem.h
r36f0738 rb7fd2a0 39 39 #include "ext4/types.h" 40 40 41 extern int ext4_filesystem_probe(service_id_t);42 extern int ext4_filesystem_open(ext4_instance_t *, service_id_t,41 extern errno_t ext4_filesystem_probe(service_id_t); 42 extern errno_t ext4_filesystem_open(ext4_instance_t *, service_id_t, 43 43 enum cache_mode, aoff64_t *, ext4_filesystem_t **); 44 extern int ext4_filesystem_close(ext4_filesystem_t *);44 extern errno_t ext4_filesystem_close(ext4_filesystem_t *); 45 45 extern uint32_t ext4_filesystem_blockaddr2_index_in_group(ext4_superblock_t *, 46 46 uint32_t); … … 48 48 uint32_t, uint32_t); 49 49 extern uint32_t ext4_filesystem_blockaddr2group(ext4_superblock_t *, uint64_t); 50 extern int ext4_filesystem_get_block_group_ref(ext4_filesystem_t *, uint32_t,50 extern errno_t ext4_filesystem_get_block_group_ref(ext4_filesystem_t *, uint32_t, 51 51 ext4_block_group_ref_t **); 52 extern int ext4_filesystem_put_block_group_ref(ext4_block_group_ref_t *);53 extern int ext4_filesystem_get_inode_ref(ext4_filesystem_t *, uint32_t,52 extern errno_t ext4_filesystem_put_block_group_ref(ext4_block_group_ref_t *); 53 extern errno_t ext4_filesystem_get_inode_ref(ext4_filesystem_t *, uint32_t, 54 54 ext4_inode_ref_t **); 55 extern int ext4_filesystem_put_inode_ref(ext4_inode_ref_t *);56 extern int ext4_filesystem_alloc_inode(ext4_filesystem_t *, ext4_inode_ref_t **,55 extern errno_t ext4_filesystem_put_inode_ref(ext4_inode_ref_t *); 56 extern errno_t ext4_filesystem_alloc_inode(ext4_filesystem_t *, ext4_inode_ref_t **, 57 57 int); 58 extern int ext4_filesystem_free_inode(ext4_inode_ref_t *);59 extern int ext4_filesystem_truncate_inode(ext4_inode_ref_t *, aoff64_t);60 extern int ext4_filesystem_get_inode_data_block_index(ext4_inode_ref_t *,58 extern errno_t ext4_filesystem_free_inode(ext4_inode_ref_t *); 59 extern errno_t ext4_filesystem_truncate_inode(ext4_inode_ref_t *, aoff64_t); 60 extern errno_t ext4_filesystem_get_inode_data_block_index(ext4_inode_ref_t *, 61 61 aoff64_t iblock, uint32_t *); 62 extern int ext4_filesystem_set_inode_data_block_index(ext4_inode_ref_t *,62 extern errno_t ext4_filesystem_set_inode_data_block_index(ext4_inode_ref_t *, 63 63 aoff64_t, uint32_t); 64 extern int ext4_filesystem_release_inode_block(ext4_inode_ref_t *, uint32_t);65 extern int ext4_filesystem_append_inode_block(ext4_inode_ref_t *, uint32_t *,64 extern errno_t ext4_filesystem_release_inode_block(ext4_inode_ref_t *, uint32_t); 65 extern errno_t ext4_filesystem_append_inode_block(ext4_inode_ref_t *, uint32_t *, 66 66 uint32_t *); 67 67 uint32_t ext4_filesystem_bg_get_backup_blocks(ext4_block_group_ref_t *bg); -
uspace/lib/ext4/include/ext4/hash.h
r36f0738 rb7fd2a0 36 36 #include "ext4/types.h" 37 37 38 extern int ext4_hash_string(ext4_hash_info_t *, int, const char *);38 extern errno_t ext4_hash_string(ext4_hash_info_t *, int, const char *); 39 39 40 40 #endif -
uspace/lib/ext4/include/ext4/ialloc.h
r36f0738 rb7fd2a0 36 36 #include "ext4/types.h" 37 37 38 extern int ext4_ialloc_free_inode(ext4_filesystem_t *, uint32_t, bool);39 extern int ext4_ialloc_alloc_inode(ext4_filesystem_t *, uint32_t *, bool);38 extern errno_t ext4_ialloc_free_inode(ext4_filesystem_t *, uint32_t, bool); 39 extern errno_t ext4_ialloc_alloc_inode(ext4_filesystem_t *, uint32_t *, bool); 40 40 41 41 #endif -
uspace/lib/ext4/include/ext4/inode.h
r36f0738 rb7fd2a0 59 59 extern uint64_t ext4_inode_get_blocks_count(ext4_superblock_t *, 60 60 ext4_inode_t *); 61 extern int ext4_inode_set_blocks_count(ext4_superblock_t *, ext4_inode_t *,61 extern errno_t ext4_inode_set_blocks_count(ext4_superblock_t *, ext4_inode_t *, 62 62 uint64_t); 63 63 extern uint32_t ext4_inode_get_flags(ext4_inode_t *); -
uspace/lib/ext4/include/ext4/ops.h
r36f0738 rb7fd2a0 40 40 extern libfs_ops_t ext4_libfs_ops; 41 41 42 extern int ext4_global_init(void);43 extern int ext4_global_fini(void);42 extern errno_t ext4_global_init(void); 43 extern errno_t ext4_global_fini(void); 44 44 45 extern int ext4_node_get_core(fs_node_t **, ext4_instance_t *, fs_index_t);46 extern int ext4_node_put(fs_node_t *);45 extern errno_t ext4_node_get_core(fs_node_t **, ext4_instance_t *, fs_index_t); 46 extern errno_t ext4_node_put(fs_node_t *); 47 47 48 48 -
uspace/lib/ext4/include/ext4/superblock.h
r36f0738 rb7fd2a0 152 152 extern bool ext4_superblock_has_feature_read_only(ext4_superblock_t *, 153 153 uint32_t); 154 extern int ext4_superblock_read_direct(service_id_t, ext4_superblock_t **);155 extern int ext4_superblock_write_direct(service_id_t, ext4_superblock_t *);154 extern errno_t ext4_superblock_read_direct(service_id_t, ext4_superblock_t **); 155 extern errno_t ext4_superblock_write_direct(service_id_t, ext4_superblock_t *); 156 156 extern void ext4_superblock_release(ext4_superblock_t *); 157 extern int ext4_superblock_check_sanity(ext4_superblock_t *);157 extern errno_t ext4_superblock_check_sanity(ext4_superblock_t *); 158 158 159 159 extern uint32_t ext4_superblock_get_block_group_count(ext4_superblock_t *); -
uspace/lib/ext4/src/balloc.c
r36f0738 rb7fd2a0 53 53 * 54 54 */ 55 int ext4_balloc_free_block(ext4_inode_ref_t *inode_ref, uint32_t block_addr)55 errno_t ext4_balloc_free_block(ext4_inode_ref_t *inode_ref, uint32_t block_addr) 56 56 { 57 57 ext4_filesystem_t *fs = inode_ref->fs; … … 65 65 /* Load block group reference */ 66 66 ext4_block_group_ref_t *bg_ref; 67 int rc = ext4_filesystem_get_block_group_ref(fs, block_group, &bg_ref);67 errno_t rc = ext4_filesystem_get_block_group_ref(fs, block_group, &bg_ref); 68 68 if (rc != EOK) 69 69 return rc; … … 118 118 } 119 119 120 static int ext4_balloc_free_blocks_internal(ext4_inode_ref_t *inode_ref,120 static errno_t ext4_balloc_free_blocks_internal(ext4_inode_ref_t *inode_ref, 121 121 uint32_t first, uint32_t count) 122 122 { … … 134 134 /* Load block group reference */ 135 135 ext4_block_group_ref_t *bg_ref; 136 int rc = ext4_filesystem_get_block_group_ref(fs, block_group_first, &bg_ref);136 errno_t rc = ext4_filesystem_get_block_group_ref(fs, block_group_first, &bg_ref); 137 137 if (rc != EOK) 138 138 return rc; … … 198 198 * 199 199 */ 200 int ext4_balloc_free_blocks(ext4_inode_ref_t *inode_ref,200 errno_t ext4_balloc_free_blocks(ext4_inode_ref_t *inode_ref, 201 201 uint32_t first, uint32_t count) 202 202 { 203 int r;203 errno_t r; 204 204 uint32_t gid; 205 205 uint64_t limit; … … 293 293 * 294 294 */ 295 static int ext4_balloc_find_goal(ext4_inode_ref_t *inode_ref, uint32_t *goal)295 static errno_t ext4_balloc_find_goal(ext4_inode_ref_t *inode_ref, uint32_t *goal) 296 296 { 297 297 *goal = 0; … … 307 307 /* If inode has some blocks, get last block address + 1 */ 308 308 if (inode_block_count > 0) { 309 int rc = ext4_filesystem_get_inode_data_block_index(inode_ref,309 errno_t rc = ext4_filesystem_get_inode_data_block_index(inode_ref, 310 310 inode_block_count - 1, goal); 311 311 if (rc != EOK) … … 325 325 /* Load block group reference */ 326 326 ext4_block_group_ref_t *bg_ref; 327 int rc = ext4_filesystem_get_block_group_ref(inode_ref->fs,327 errno_t rc = ext4_filesystem_get_block_group_ref(inode_ref->fs, 328 328 block_group, &bg_ref); 329 329 if (rc != EOK) … … 343 343 * 344 344 */ 345 int ext4_balloc_alloc_block(ext4_inode_ref_t *inode_ref, uint32_t *fblock)345 errno_t ext4_balloc_alloc_block(ext4_inode_ref_t *inode_ref, uint32_t *fblock) 346 346 { 347 347 uint32_t allocated_block = 0; … … 354 354 355 355 /* Find GOAL */ 356 int rc = ext4_balloc_find_goal(inode_ref, &goal);356 errno_t rc = ext4_balloc_find_goal(inode_ref, &goal); 357 357 if (rc != EOK) 358 358 return rc; … … 625 625 * 626 626 */ 627 int ext4_balloc_try_alloc_block(ext4_inode_ref_t *inode_ref, uint32_t fblock,627 errno_t ext4_balloc_try_alloc_block(ext4_inode_ref_t *inode_ref, uint32_t fblock, 628 628 bool *free) 629 629 { 630 int rc;630 errno_t rc; 631 631 632 632 ext4_filesystem_t *fs = inode_ref->fs; -
uspace/lib/ext4/src/bitmap.c
r36f0738 rb7fd2a0 169 169 * 170 170 */ 171 int ext4_bitmap_find_free_byte_and_set_bit(uint8_t *bitmap, uint32_t start,171 errno_t ext4_bitmap_find_free_byte_and_set_bit(uint8_t *bitmap, uint32_t start, 172 172 uint32_t *index, uint32_t max) 173 173 { … … 211 211 * 212 212 */ 213 int ext4_bitmap_find_free_bit_and_set(uint8_t *bitmap, uint32_t start_idx,213 errno_t ext4_bitmap_find_free_bit_and_set(uint8_t *bitmap, uint32_t start_idx, 214 214 uint32_t *index, uint32_t max) 215 215 { -
uspace/lib/ext4/src/directory.c
r36f0738 rb7fd2a0 169 169 } 170 170 171 static int ext4_directory_iterator_seek(ext4_directory_iterator_t *, aoff64_t);172 static int ext4_directory_iterator_set(ext4_directory_iterator_t *, uint32_t);171 static errno_t ext4_directory_iterator_seek(ext4_directory_iterator_t *, aoff64_t); 172 static errno_t ext4_directory_iterator_set(ext4_directory_iterator_t *, uint32_t); 173 173 174 174 /** Initialize directory iterator. … … 183 183 * 184 184 */ 185 int ext4_directory_iterator_init(ext4_directory_iterator_t *it,185 errno_t ext4_directory_iterator_init(ext4_directory_iterator_t *it, 186 186 ext4_inode_ref_t *inode_ref, aoff64_t pos) 187 187 { … … 201 201 * 202 202 */ 203 int ext4_directory_iterator_next(ext4_directory_iterator_t *it)203 errno_t ext4_directory_iterator_next(ext4_directory_iterator_t *it) 204 204 { 205 205 assert(it->current != NULL); … … 220 220 * 221 221 */ 222 int ext4_directory_iterator_seek(ext4_directory_iterator_t *it, aoff64_t pos)222 errno_t ext4_directory_iterator_seek(ext4_directory_iterator_t *it, aoff64_t pos) 223 223 { 224 224 uint64_t size = ext4_inode_get_size(it->inode_ref->fs->superblock, … … 231 231 if (pos >= size) { 232 232 if (it->current_block) { 233 int rc = block_put(it->current_block);233 errno_t rc = block_put(it->current_block); 234 234 it->current_block = NULL; 235 235 … … 255 255 (current_block_idx != next_block_idx)) { 256 256 if (it->current_block) { 257 int rc = block_put(it->current_block);257 errno_t rc = block_put(it->current_block); 258 258 it->current_block = NULL; 259 259 … … 263 263 264 264 uint32_t next_block_phys_idx; 265 int rc = ext4_filesystem_get_inode_data_block_index(it->inode_ref,265 errno_t rc = ext4_filesystem_get_inode_data_block_index(it->inode_ref, 266 266 next_block_idx, &next_block_phys_idx); 267 267 if (rc != EOK) … … 289 289 * 290 290 */ 291 static int ext4_directory_iterator_set(ext4_directory_iterator_t *it,291 static errno_t ext4_directory_iterator_set(ext4_directory_iterator_t *it, 292 292 uint32_t block_size) 293 293 { … … 331 331 * 332 332 */ 333 int ext4_directory_iterator_fini(ext4_directory_iterator_t *it)333 errno_t ext4_directory_iterator_fini(ext4_directory_iterator_t *it) 334 334 { 335 335 it->inode_ref = NULL; … … 386 386 * 387 387 */ 388 int ext4_directory_add_entry(ext4_inode_ref_t *parent, const char *name,388 errno_t ext4_directory_add_entry(ext4_inode_ref_t *parent, const char *name, 389 389 ext4_inode_ref_t *child) 390 390 { … … 395 395 EXT4_FEATURE_COMPAT_DIR_INDEX)) && 396 396 (ext4_inode_has_flag(parent->inode, EXT4_INODE_FLAG_INDEX))) { 397 int rc = ext4_directory_dx_add_entry(parent, child, name);397 errno_t rc = ext4_directory_dx_add_entry(parent, child, name); 398 398 399 399 /* Check if index is not corrupted */ … … 419 419 bool success = false; 420 420 for (iblock = 0; iblock < total_blocks; ++iblock) { 421 int rc = ext4_filesystem_get_inode_data_block_index(parent,421 errno_t rc = ext4_filesystem_get_inode_data_block_index(parent, 422 422 iblock, &fblock); 423 423 if (rc != EOK) … … 447 447 iblock = 0; 448 448 fblock = 0; 449 int rc = ext4_filesystem_append_inode_block(parent, &fblock, &iblock);449 errno_t rc = ext4_filesystem_append_inode_block(parent, &fblock, &iblock); 450 450 if (rc != EOK) 451 451 return rc; … … 479 479 * 480 480 */ 481 int ext4_directory_find_entry(ext4_directory_search_result_t *result,481 errno_t ext4_directory_find_entry(ext4_directory_search_result_t *result, 482 482 ext4_inode_ref_t *parent, const char *name) 483 483 { … … 490 490 EXT4_FEATURE_COMPAT_DIR_INDEX)) && 491 491 (ext4_inode_has_flag(parent->inode, EXT4_INODE_FLAG_INDEX))) { 492 int rc = ext4_directory_dx_find_entry(result, parent, name_len,492 errno_t rc = ext4_directory_dx_find_entry(result, parent, name_len, 493 493 name); 494 494 … … 517 517 for (iblock = 0; iblock < total_blocks; ++iblock) { 518 518 /* Load block address */ 519 int rc = ext4_filesystem_get_inode_data_block_index(parent, iblock,519 errno_t rc = ext4_filesystem_get_inode_data_block_index(parent, iblock, 520 520 &fblock); 521 521 if (rc != EOK) … … 561 561 * 562 562 */ 563 int ext4_directory_remove_entry(ext4_inode_ref_t *parent, const char *name)563 errno_t ext4_directory_remove_entry(ext4_inode_ref_t *parent, const char *name) 564 564 { 565 565 /* Check if removing from directory */ … … 570 570 /* Try to find entry */ 571 571 ext4_directory_search_result_t result; 572 int rc = ext4_directory_find_entry(&result, parent, name);572 errno_t rc = ext4_directory_find_entry(&result, parent, name); 573 573 if (rc != EOK) 574 574 return rc; … … 626 626 * 627 627 */ 628 int ext4_directory_try_insert_entry(ext4_superblock_t *sb,628 errno_t ext4_directory_try_insert_entry(ext4_superblock_t *sb, 629 629 block_t *target_block, ext4_inode_ref_t *child, const char *name, 630 630 uint32_t name_len) … … 705 705 * 706 706 */ 707 int ext4_directory_find_in_block(block_t *block, ext4_superblock_t *sb,707 errno_t ext4_directory_find_in_block(block_t *block, ext4_superblock_t *sb, 708 708 size_t name_len, const char *name, ext4_directory_entry_ll_t **res_entry) 709 709 { … … 756 756 * 757 757 */ 758 int ext4_directory_destroy_result(ext4_directory_search_result_t *result)758 errno_t ext4_directory_destroy_result(ext4_directory_search_result_t *result) 759 759 { 760 760 if (result->block) -
uspace/lib/ext4/src/directory_index.c
r36f0738 rb7fd2a0 236 236 * 237 237 */ 238 int ext4_directory_dx_init(ext4_inode_ref_t *dir)238 errno_t ext4_directory_dx_init(ext4_inode_ref_t *dir) 239 239 { 240 240 /* Load block 0, where will be index root located */ 241 241 uint32_t fblock; 242 int rc = ext4_filesystem_get_inode_data_block_index(dir, 0,242 errno_t rc = ext4_filesystem_get_inode_data_block_index(dir, 0, 243 243 &fblock); 244 244 if (rc != EOK) … … 322 322 * 323 323 */ 324 static int ext4_directory_hinfo_init(ext4_hash_info_t *hinfo,324 static errno_t ext4_directory_hinfo_init(ext4_hash_info_t *hinfo, 325 325 block_t *root_block, ext4_superblock_t *sb, size_t name_len, 326 326 const char *name) … … 384 384 * 385 385 */ 386 static int ext4_directory_dx_get_leaf(ext4_hash_info_t *hinfo,386 static errno_t ext4_directory_dx_get_leaf(ext4_hash_info_t *hinfo, 387 387 ext4_inode_ref_t *inode_ref, block_t *root_block, 388 388 ext4_directory_dx_block_t **dx_block, ext4_directory_dx_block_t *dx_blocks) … … 443 443 444 444 uint32_t fblock; 445 int rc = ext4_filesystem_get_inode_data_block_index(inode_ref,445 errno_t rc = ext4_filesystem_get_inode_data_block_index(inode_ref, 446 446 next_block, &fblock); 447 447 if (rc != EOK) … … 484 484 * 485 485 */ 486 static int ext4_directory_dx_next_block(ext4_inode_ref_t *inode_ref,486 static errno_t ext4_directory_dx_next_block(ext4_inode_ref_t *inode_ref, 487 487 uint32_t hash, ext4_directory_dx_block_t *dx_block, 488 488 ext4_directory_dx_block_t *dx_blocks) … … 520 520 uint32_t block_addr; 521 521 522 int rc = ext4_filesystem_get_inode_data_block_index(inode_ref,522 errno_t rc = ext4_filesystem_get_inode_data_block_index(inode_ref, 523 523 block_idx, &block_addr); 524 524 if (rc != EOK) … … 556 556 * 557 557 */ 558 int ext4_directory_dx_find_entry(ext4_directory_search_result_t *result,558 errno_t ext4_directory_dx_find_entry(ext4_directory_search_result_t *result, 559 559 ext4_inode_ref_t *inode_ref, size_t name_len, const char *name) 560 560 { 561 561 /* Load direct block 0 (index root) */ 562 562 uint32_t root_block_addr; 563 int rc2;564 int rc = ext4_filesystem_get_inode_data_block_index(inode_ref, 0,563 errno_t rc2; 564 errno_t rc = ext4_filesystem_get_inode_data_block_index(inode_ref, 0, 565 565 &root_block_addr); 566 566 if (rc != EOK) … … 728 728 * 729 729 */ 730 static int ext4_directory_dx_split_data(ext4_inode_ref_t *inode_ref,730 static errno_t ext4_directory_dx_split_data(ext4_inode_ref_t *inode_ref, 731 731 ext4_hash_info_t *hinfo, block_t *old_data_block, 732 732 ext4_directory_dx_block_t *index_block, block_t **new_data_block) 733 733 { 734 int rc = EOK;734 errno_t rc = EOK; 735 735 736 736 /* Allocate buffer for directory entries */ … … 897 897 * 898 898 */ 899 static int ext4_directory_dx_split_index(ext4_inode_ref_t *inode_ref,899 static errno_t ext4_directory_dx_split_index(ext4_inode_ref_t *inode_ref, 900 900 ext4_directory_dx_block_t *dx_blocks, ext4_directory_dx_block_t *dx_block) 901 901 { … … 937 937 uint32_t new_fblock; 938 938 uint32_t new_iblock; 939 int rc = ext4_filesystem_append_inode_block(inode_ref,939 errno_t rc = ext4_filesystem_append_inode_block(inode_ref, 940 940 &new_fblock, &new_iblock); 941 941 if (rc != EOK) … … 1045 1045 * 1046 1046 */ 1047 int ext4_directory_dx_add_entry(ext4_inode_ref_t *parent,1047 errno_t ext4_directory_dx_add_entry(ext4_inode_ref_t *parent, 1048 1048 ext4_inode_ref_t *child, const char *name) 1049 1049 { 1050 int rc2 = EOK;1050 errno_t rc2 = EOK; 1051 1051 1052 1052 /* Get direct block 0 (index root) */ 1053 1053 uint32_t root_block_addr; 1054 int rc = ext4_filesystem_get_inode_data_block_index(parent, 0,1054 errno_t rc = ext4_filesystem_get_inode_data_block_index(parent, 0, 1055 1055 &root_block_addr); 1056 1056 if (rc != EOK) -
uspace/lib/ext4/src/extent.c
r36f0738 rb7fd2a0 372 372 * 373 373 */ 374 int ext4_extent_find_block(ext4_inode_ref_t *inode_ref, uint32_t iblock,374 errno_t ext4_extent_find_block(ext4_inode_ref_t *inode_ref, uint32_t iblock, 375 375 uint32_t *fblock) 376 376 { 377 int rc = EOK;377 errno_t rc = EOK; 378 378 /* Compute bound defined by i-node size */ 379 379 uint64_t inode_size = … … 454 454 * 455 455 */ 456 static int ext4_extent_find_extent(ext4_inode_ref_t *inode_ref, uint32_t iblock,456 static errno_t ext4_extent_find_extent(ext4_inode_ref_t *inode_ref, uint32_t iblock, 457 457 ext4_extent_path_t **ret_path) 458 458 { … … 475 475 /* Walk through the extent tree */ 476 476 uint16_t pos = 0; 477 int rc;477 errno_t rc; 478 478 while (ext4_extent_header_get_depth(eh) != 0) { 479 479 /* Search index in index node by iblock */ … … 515 515 ; 516 516 517 int rc2 = EOK;517 errno_t rc2 = EOK; 518 518 519 519 /* … … 543 543 * 544 544 */ 545 static int ext4_extent_release(ext4_inode_ref_t *inode_ref,545 static errno_t ext4_extent_release(ext4_inode_ref_t *inode_ref, 546 546 ext4_extent_t *extent) 547 547 { … … 565 565 * 566 566 */ 567 static int ext4_extent_release_branch(ext4_inode_ref_t *inode_ref,567 static errno_t ext4_extent_release_branch(ext4_inode_ref_t *inode_ref, 568 568 ext4_extent_index_t *index) 569 569 { … … 571 571 572 572 block_t* block; 573 int rc = block_get(&block, inode_ref->fs->device, fblock, BLOCK_FLAGS_NONE);573 errno_t rc = block_get(&block, inode_ref->fs->device, fblock, BLOCK_FLAGS_NONE); 574 574 if (rc != EOK) 575 575 return rc; … … 618 618 * 619 619 */ 620 int ext4_extent_release_blocks_from(ext4_inode_ref_t *inode_ref,620 errno_t ext4_extent_release_blocks_from(ext4_inode_ref_t *inode_ref, 621 621 uint32_t iblock_from) 622 622 { 623 623 /* Find the first extent to modify */ 624 624 ext4_extent_path_t *path; 625 int rc = ext4_extent_find_extent(inode_ref, iblock_from, &path);625 errno_t rc = ext4_extent_find_extent(inode_ref, iblock_from, &path); 626 626 if (rc != EOK) 627 627 return rc; … … 736 736 ; 737 737 738 int rc2 = EOK;738 errno_t rc2 = EOK; 739 739 740 740 /* … … 767 767 * 768 768 */ 769 static int ext4_extent_append_extent(ext4_inode_ref_t *inode_ref,769 static errno_t ext4_extent_append_extent(ext4_inode_ref_t *inode_ref, 770 770 ext4_extent_path_t *path, uint32_t iblock) 771 771 { … … 785 785 /* Full node - allocate block for new one */ 786 786 uint32_t fblock; 787 int rc = ext4_balloc_alloc_block(inode_ref, &fblock);787 errno_t rc = ext4_balloc_alloc_block(inode_ref, &fblock); 788 788 if (rc != EOK) 789 789 return rc; … … 863 863 if (entries == limit) { 864 864 uint32_t new_fblock; 865 int rc = ext4_balloc_alloc_block(inode_ref, &new_fblock);865 errno_t rc = ext4_balloc_alloc_block(inode_ref, &new_fblock); 866 866 if (rc != EOK) 867 867 return rc; … … 964 964 * 965 965 */ 966 int ext4_extent_append_block(ext4_inode_ref_t *inode_ref, uint32_t *iblock,966 errno_t ext4_extent_append_block(ext4_inode_ref_t *inode_ref, uint32_t *iblock, 967 967 uint32_t *fblock, bool update_size) 968 968 { … … 982 982 /* Load the nearest leaf (with extent) */ 983 983 ext4_extent_path_t *path; 984 int rc = ext4_extent_find_extent(inode_ref, new_block_idx, &path);984 errno_t rc = ext4_extent_find_extent(inode_ref, new_block_idx, &path); 985 985 if (rc != EOK) 986 986 return rc; … … 1088 1088 ; 1089 1089 1090 int rc2 = EOK;1090 errno_t rc2 = EOK; 1091 1091 1092 1092 /* Set return values */ -
uspace/lib/ext4/src/filesystem.c
r36f0738 rb7fd2a0 54 54 #include "ext4/superblock.h" 55 55 56 static int ext4_filesystem_check_features(ext4_filesystem_t *, bool *);56 static errno_t ext4_filesystem_check_features(ext4_filesystem_t *, bool *); 57 57 58 58 /** Initialize filesystem for opening. … … 67 67 * 68 68 */ 69 static int ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id,69 static errno_t ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id, 70 70 enum cache_mode cmode) 71 71 { 72 int rc;72 errno_t rc; 73 73 ext4_superblock_t *temp_superblock = NULL; 74 74 … … 164 164 * 165 165 */ 166 int ext4_filesystem_probe(service_id_t service_id)166 errno_t ext4_filesystem_probe(service_id_t service_id) 167 167 { 168 168 ext4_filesystem_t *fs = NULL; 169 int rc;169 errno_t rc; 170 170 171 171 fs = calloc(1, sizeof(ext4_filesystem_t)); … … 195 195 * 196 196 */ 197 int ext4_filesystem_open(ext4_instance_t *inst, service_id_t service_id,197 errno_t 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 int rc;202 errno_t rc; 203 203 204 204 fs = calloc(1, sizeof(ext4_filesystem_t)); … … 256 256 * 257 257 */ 258 int ext4_filesystem_close(ext4_filesystem_t *fs)258 errno_t 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 int rc = ext4_superblock_write_direct(fs->device, fs->superblock);262 errno_t rc = ext4_superblock_write_direct(fs->device, fs->superblock); 263 263 if (rc != EOK) 264 264 return rc; … … 281 281 * 282 282 */ 283 static int ext4_filesystem_check_features(ext4_filesystem_t *fs,283 static errno_t ext4_filesystem_check_features(ext4_filesystem_t *fs, 284 284 bool *read_only) 285 285 { … … 380 380 * 381 381 */ 382 static int ext4_filesystem_init_block_bitmap(ext4_block_group_ref_t *bg_ref)382 static errno_t 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 int rc = block_get(&bitmap_block, bg_ref->fs->device,396 errno_t 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 int ext4_filesystem_init_inode_bitmap(ext4_block_group_ref_t *bg_ref)453 static errno_t 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 int rc = block_get(&bitmap_block, bg_ref->fs->device,460 errno_t 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 int ext4_filesystem_init_inode_table(ext4_block_group_ref_t *bg_ref)496 static errno_t 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 int rc = block_get(&block, bg_ref->fs->device, fblock,521 errno_t rc = block_get(&block, bg_ref->fs->device, fblock, 522 522 BLOCK_FLAGS_NOREAD); 523 523 if (rc != EOK) … … 544 544 * 545 545 */ 546 int ext4_filesystem_get_block_group_ref(ext4_filesystem_t *fs, uint32_t bgid,546 errno_t 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 int rc = block_get(&newref->block, fs->device, block_id, 0);570 errno_t rc = block_get(&newref->block, fs->device, block_id, 0); 571 571 if (rc != EOK) { 572 572 free(newref); … … 804 804 * 805 805 */ 806 int ext4_filesystem_put_block_group_ref(ext4_block_group_ref_t *ref)806 errno_t 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 int rc = block_put(ref->block);821 errno_t rc = block_put(ref->block); 822 822 free(ref); 823 823 … … 834 834 * 835 835 */ 836 int ext4_filesystem_get_inode_ref(ext4_filesystem_t *fs, uint32_t index,836 errno_t 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 int rc = ext4_filesystem_get_block_group_ref(fs, block_group, &bg_ref);859 errno_t 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 int ext4_filesystem_put_inode_ref(ext4_inode_ref_t *ref)911 errno_t 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 int rc = block_put(ref->block);920 errno_t rc = block_put(ref->block); 921 921 free(ref); 922 922 … … 933 933 * 934 934 */ 935 int ext4_filesystem_alloc_inode(ext4_filesystem_t *fs,935 errno_t 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 int rc = ext4_ialloc_alloc_inode(fs, &index, is_dir);945 errno_t rc = ext4_ialloc_alloc_inode(fs, &index, is_dir); 946 946 if (rc != EOK) 947 947 return rc; … … 1025 1025 * 1026 1026 */ 1027 int ext4_filesystem_free_inode(ext4_inode_ref_t *inode_ref)1027 errno_t 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 int rc = ext4_balloc_free_block(inode_ref, fblock);1044 errno_t 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 int rc = block_get(&block, fs->device, fblock, BLOCK_FLAGS_NONE);1058 errno_t 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 int rc = block_get(&block, fs->device, fblock, BLOCK_FLAGS_NONE);1090 errno_t 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 int rc = ext4_balloc_free_block(inode_ref, xattr_block);1155 errno_t 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 int rc;1163 errno_t rc; 1164 1164 if (ext4_inode_is_type(fs->superblock, inode_ref->inode, 1165 1165 EXT4_INODE_MODE_DIRECTORY)) … … 1179 1179 * 1180 1180 */ 1181 int ext4_filesystem_truncate_inode(ext4_inode_ref_t *inode_ref,1181 errno_t 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 int rc = ext4_extent_release_blocks_from(inode_ref,1214 errno_t 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 int rc = ext4_filesystem_release_inode_block(inode_ref,1223 errno_t rc = ext4_filesystem_release_inode_block(inode_ref, 1224 1224 old_blocks_count - i); 1225 1225 if (rc != EOK) … … 1244 1244 * 1245 1245 */ 1246 int ext4_filesystem_get_inode_data_block_index(ext4_inode_ref_t *inode_ref,1246 errno_t 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 int rc = ext4_extent_find_block(inode_ref, iblock, ¤t_block);1263 errno_t 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 int rc = block_get(&block, fs->device, current_block, 0);1313 errno_t rc = block_get(&block, fs->device, current_block, 0); 1314 1314 if (rc != EOK) 1315 1315 return rc; … … 1357 1357 * 1358 1358 */ 1359 int ext4_filesystem_set_inode_data_block_index(ext4_inode_ref_t *inode_ref,1359 errno_t 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 int rc = ext4_balloc_alloc_block(inode_ref, &new_block_addr);1409 errno_t 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 int rc = block_get(&block, fs->device, current_block, 0);1443 errno_t rc = block_get(&block, fs->device, current_block, 0); 1444 1444 if (rc != EOK) 1445 1445 return rc; … … 1518 1518 * 1519 1519 */ 1520 int ext4_filesystem_release_inode_block(ext4_inode_ref_t *inode_ref,1520 errno_t 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 int rc = block_get(&block, fs->device, current_block, 0);1577 errno_t rc = block_get(&block, fs->device, current_block, 0); 1578 1578 if (rc != EOK) 1579 1579 return rc; … … 1625 1625 * 1626 1626 */ 1627 int ext4_filesystem_append_inode_block(ext4_inode_ref_t *inode_ref,1627 errno_t 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 int rc = ext4_balloc_alloc_block(inode_ref, &phys_block);1651 errno_t rc = ext4_balloc_alloc_block(inode_ref, &phys_block); 1652 1652 if (rc != EOK) 1653 1653 return rc; -
uspace/lib/ext4/src/hash.c
r36f0738 rb7fd2a0 38 38 #include "ext4/hash.h" 39 39 40 int ext4_hash_string(ext4_hash_info_t *hinfo, int len, const char *name)40 errno_t ext4_hash_string(ext4_hash_info_t *hinfo, int len, const char *name) 41 41 { 42 42 // TODO -
uspace/lib/ext4/src/ialloc.c
r36f0738 rb7fd2a0 97 97 * 98 98 */ 99 int ext4_ialloc_free_inode(ext4_filesystem_t *fs, uint32_t index, bool is_dir)99 errno_t ext4_ialloc_free_inode(ext4_filesystem_t *fs, uint32_t index, bool is_dir) 100 100 { 101 101 ext4_superblock_t *sb = fs->superblock; … … 105 105 106 106 ext4_block_group_ref_t *bg_ref; 107 int rc = ext4_filesystem_get_block_group_ref(fs, block_group, &bg_ref);107 errno_t rc = ext4_filesystem_get_block_group_ref(fs, block_group, &bg_ref); 108 108 if (rc != EOK) 109 109 return rc; … … 175 175 * 176 176 */ 177 int ext4_ialloc_alloc_inode(ext4_filesystem_t *fs, uint32_t *index, bool is_dir)177 errno_t ext4_ialloc_alloc_inode(ext4_filesystem_t *fs, uint32_t *index, bool is_dir) 178 178 { 179 179 ext4_superblock_t *sb = fs->superblock; … … 188 188 /* Load block group to check */ 189 189 ext4_block_group_ref_t *bg_ref; 190 int rc = ext4_filesystem_get_block_group_ref(fs, bgid, &bg_ref);190 errno_t rc = ext4_filesystem_get_block_group_ref(fs, bgid, &bg_ref); 191 191 if (rc != EOK) 192 192 return rc; -
uspace/lib/ext4/src/inode.c
r36f0738 rb7fd2a0 324 324 * 325 325 */ 326 int ext4_inode_set_blocks_count(ext4_superblock_t *sb, ext4_inode_t *inode,326 errno_t ext4_inode_set_blocks_count(ext4_superblock_t *sb, ext4_inode_t *inode, 327 327 uint64_t count) 328 328 { -
uspace/lib/ext4/src/ops.c
r36f0738 rb7fd2a0 58 58 /* Forward declarations of auxiliary functions */ 59 59 60 static int ext4_read_directory(ipc_callid_t, aoff64_t, size_t,60 static errno_t ext4_read_directory(ipc_callid_t, aoff64_t, size_t, 61 61 ext4_instance_t *, ext4_inode_ref_t *, size_t *); 62 static int ext4_read_file(ipc_callid_t, aoff64_t, size_t, ext4_instance_t *,62 static errno_t ext4_read_file(ipc_callid_t, aoff64_t, size_t, ext4_instance_t *, 63 63 ext4_inode_ref_t *, size_t *); 64 64 static bool ext4_is_dots(const uint8_t *, size_t); 65 static int ext4_instance_get(service_id_t, ext4_instance_t **);65 static errno_t ext4_instance_get(service_id_t, ext4_instance_t **); 66 66 67 67 /* Forward declarations of ext4 libfs operations. */ 68 68 69 static int ext4_root_get(fs_node_t **, service_id_t);70 static int ext4_match(fs_node_t **, fs_node_t *, const char *);71 static int ext4_node_get(fs_node_t **, service_id_t, fs_index_t);72 static int ext4_node_open(fs_node_t *);73 int ext4_node_put(fs_node_t *);74 static int ext4_create_node(fs_node_t **, service_id_t, int);75 static int ext4_destroy_node(fs_node_t *);76 static int ext4_link(fs_node_t *, fs_node_t *, const char *);77 static int ext4_unlink(fs_node_t *, fs_node_t *, const char *);78 static int ext4_has_children(bool *, fs_node_t *);69 static errno_t ext4_root_get(fs_node_t **, service_id_t); 70 static errno_t ext4_match(fs_node_t **, fs_node_t *, const char *); 71 static errno_t ext4_node_get(fs_node_t **, service_id_t, fs_index_t); 72 static errno_t ext4_node_open(fs_node_t *); 73 errno_t ext4_node_put(fs_node_t *); 74 static errno_t ext4_create_node(fs_node_t **, service_id_t, int); 75 static errno_t ext4_destroy_node(fs_node_t *); 76 static errno_t ext4_link(fs_node_t *, fs_node_t *, const char *); 77 static errno_t ext4_unlink(fs_node_t *, fs_node_t *, const char *); 78 static errno_t ext4_has_children(bool *, fs_node_t *); 79 79 static fs_index_t ext4_index_get(fs_node_t *); 80 80 static aoff64_t ext4_size_get(fs_node_t *); … … 83 83 static bool ext4_is_file(fs_node_t *node); 84 84 static service_id_t ext4_service_get(fs_node_t *node); 85 static int ext4_size_block(service_id_t, uint32_t *);86 static int ext4_total_block_count(service_id_t, uint64_t *);87 static int ext4_free_block_count(service_id_t, uint64_t *);85 static errno_t ext4_size_block(service_id_t, uint32_t *); 86 static errno_t ext4_total_block_count(service_id_t, uint64_t *); 87 static errno_t ext4_free_block_count(service_id_t, uint64_t *); 88 88 89 89 /* Static variables */ … … 138 138 * 139 139 */ 140 int ext4_global_init(void)140 errno_t ext4_global_init(void) 141 141 { 142 142 if (!hash_table_create(&open_nodes, 0, 0, &open_nodes_ops)) … … 152 152 * @return Error code 153 153 */ 154 int ext4_global_fini(void)154 errno_t ext4_global_fini(void) 155 155 { 156 156 hash_table_destroy(&open_nodes); … … 170 170 * 171 171 */ 172 int ext4_instance_get(service_id_t service_id, ext4_instance_t **inst)172 errno_t ext4_instance_get(service_id_t service_id, ext4_instance_t **inst) 173 173 { 174 174 fibril_mutex_lock(&instance_list_mutex); … … 199 199 * 200 200 */ 201 int ext4_root_get(fs_node_t **rfn, service_id_t service_id)201 errno_t ext4_root_get(fs_node_t **rfn, service_id_t service_id) 202 202 { 203 203 return ext4_node_get(rfn, service_id, EXT4_INODE_ROOT_INDEX); … … 215 215 * 216 216 */ 217 int ext4_match(fs_node_t **rfn, fs_node_t *pfn, const char *component)217 errno_t ext4_match(fs_node_t **rfn, fs_node_t *pfn, const char *component) 218 218 { 219 219 ext4_node_t *eparent = EXT4_NODE(pfn); … … 226 226 /* Try to find entry */ 227 227 ext4_directory_search_result_t result; 228 int rc = ext4_directory_find_entry(&result, eparent->inode_ref,228 errno_t rc = ext4_directory_find_entry(&result, eparent->inode_ref, 229 229 component); 230 230 if (rc != EOK) { … … 247 247 248 248 /* Destroy search result structure */ 249 int const rc2 = ext4_directory_destroy_result(&result);249 errno_t const rc2 = ext4_directory_destroy_result(&result); 250 250 return rc == EOK ? rc2 : rc; 251 251 } … … 262 262 * 263 263 */ 264 int ext4_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index)264 errno_t ext4_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index) 265 265 { 266 266 ext4_instance_t *inst; 267 int rc = ext4_instance_get(service_id, &inst);267 errno_t rc = ext4_instance_get(service_id, &inst); 268 268 if (rc != EOK) 269 269 return rc; … … 281 281 * 282 282 */ 283 int ext4_node_get_core(fs_node_t **rfn, ext4_instance_t *inst,283 errno_t ext4_node_get_core(fs_node_t **rfn, ext4_instance_t *inst, 284 284 fs_index_t index) 285 285 { … … 322 322 /* Load i-node from filesystem */ 323 323 ext4_inode_ref_t *inode_ref; 324 int rc = ext4_filesystem_get_inode_ref(inst->filesystem, index,324 errno_t rc = ext4_filesystem_get_inode_ref(inst->filesystem, index, 325 325 &inode_ref); 326 326 if (rc != EOK) { … … 355 355 * 356 356 */ 357 static int ext4_node_put_core(ext4_node_t *enode)357 static errno_t ext4_node_put_core(ext4_node_t *enode) 358 358 { 359 359 hash_table_remove_item(&open_nodes, &enode->link); … … 362 362 363 363 /* Put inode back in filesystem */ 364 int rc = ext4_filesystem_put_inode_ref(enode->inode_ref);364 errno_t rc = ext4_filesystem_put_inode_ref(enode->inode_ref); 365 365 if (rc != EOK) 366 366 return rc; … … 382 382 * 383 383 */ 384 int ext4_node_open(fs_node_t *fn)384 errno_t ext4_node_open(fs_node_t *fn) 385 385 { 386 386 /* Stateless operation */ … … 396 396 * 397 397 */ 398 int ext4_node_put(fs_node_t *fn)398 errno_t ext4_node_put(fs_node_t *fn) 399 399 { 400 400 fibril_mutex_lock(&open_nodes_lock); … … 404 404 enode->references--; 405 405 if (enode->references == 0) { 406 int rc = ext4_node_put_core(enode);406 errno_t rc = ext4_node_put_core(enode); 407 407 if (rc != EOK) { 408 408 fibril_mutex_unlock(&open_nodes_lock); … … 425 425 * 426 426 */ 427 int ext4_create_node(fs_node_t **rfn, service_id_t service_id, int flags)427 errno_t ext4_create_node(fs_node_t **rfn, service_id_t service_id, int flags) 428 428 { 429 429 /* Allocate enode */ … … 443 443 /* Load instance */ 444 444 ext4_instance_t *inst; 445 int rc = ext4_instance_get(service_id, &inst);445 errno_t rc = ext4_instance_get(service_id, &inst); 446 446 if (rc != EOK) { 447 447 free(enode); … … 486 486 * 487 487 */ 488 int ext4_destroy_node(fs_node_t *fn)488 errno_t ext4_destroy_node(fs_node_t *fn) 489 489 { 490 490 /* If directory, check for children */ 491 491 bool has_children; 492 int rc = ext4_has_children(&has_children, fn);492 errno_t rc = ext4_has_children(&has_children, fn); 493 493 if (rc != EOK) { 494 494 ext4_node_put(fn); … … 537 537 * 538 538 */ 539 int ext4_link(fs_node_t *pfn, fs_node_t *cfn, const char *name)539 errno_t ext4_link(fs_node_t *pfn, fs_node_t *cfn, const char *name) 540 540 { 541 541 /* Check maximum name length */ … … 548 548 549 549 /* Add entry to parent directory */ 550 int rc = ext4_directory_add_entry(parent->inode_ref, name,550 errno_t rc = ext4_directory_add_entry(parent->inode_ref, name, 551 551 child->inode_ref); 552 552 if (rc != EOK) … … 610 610 * 611 611 */ 612 int ext4_unlink(fs_node_t *pfn, fs_node_t *cfn, const char *name)612 errno_t ext4_unlink(fs_node_t *pfn, fs_node_t *cfn, const char *name) 613 613 { 614 614 bool has_children; 615 int rc = ext4_has_children(&has_children, cfn);615 errno_t rc = ext4_has_children(&has_children, cfn); 616 616 if (rc != EOK) 617 617 return rc; … … 683 683 * 684 684 */ 685 int ext4_has_children(bool *has_children, fs_node_t *fn)685 errno_t ext4_has_children(bool *has_children, fs_node_t *fn) 686 686 { 687 687 ext4_node_t *enode = EXT4_NODE(fn); … … 696 696 697 697 ext4_directory_iterator_t it; 698 int rc = ext4_directory_iterator_init(&it, enode->inode_ref, 0);698 errno_t rc = ext4_directory_iterator_init(&it, enode->inode_ref, 0); 699 699 if (rc != EOK) 700 700 return rc; … … 824 824 } 825 825 826 int ext4_size_block(service_id_t service_id, uint32_t *size)826 errno_t ext4_size_block(service_id_t service_id, uint32_t *size) 827 827 { 828 828 ext4_instance_t *inst; 829 int rc = ext4_instance_get(service_id, &inst);829 errno_t rc = ext4_instance_get(service_id, &inst); 830 830 if (rc != EOK) 831 831 return rc; … … 840 840 } 841 841 842 int ext4_total_block_count(service_id_t service_id, uint64_t *count)842 errno_t ext4_total_block_count(service_id_t service_id, uint64_t *count) 843 843 { 844 844 ext4_instance_t *inst; 845 int rc = ext4_instance_get(service_id, &inst);845 errno_t rc = ext4_instance_get(service_id, &inst); 846 846 if (rc != EOK) 847 847 return rc; … … 856 856 } 857 857 858 int ext4_free_block_count(service_id_t service_id, uint64_t *count)858 errno_t ext4_free_block_count(service_id_t service_id, uint64_t *count) 859 859 { 860 860 ext4_instance_t *inst; 861 int rc = ext4_instance_get(service_id, &inst);861 errno_t rc = ext4_instance_get(service_id, &inst); 862 862 if (rc != EOK) 863 863 return rc; … … 907 907 * @return Error code 908 908 */ 909 static int ext4_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info)909 static errno_t ext4_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 910 910 { 911 911 return ext4_filesystem_probe(service_id); … … 924 924 * 925 925 */ 926 static int ext4_mounted(service_id_t service_id, const char *opts,926 static errno_t ext4_mounted(service_id_t service_id, const char *opts, 927 927 fs_index_t *index, aoff64_t *size) 928 928 { … … 948 948 /* Initialize the filesystem */ 949 949 aoff64_t rnsize; 950 int rc = ext4_filesystem_open(inst, service_id, cmode, &rnsize, &fs);950 errno_t rc = ext4_filesystem_open(inst, service_id, cmode, &rnsize, &fs); 951 951 if (rc != EOK) { 952 952 free(inst); … … 974 974 * 975 975 */ 976 static int ext4_unmounted(service_id_t service_id)976 static errno_t ext4_unmounted(service_id_t service_id) 977 977 { 978 978 ext4_instance_t *inst; 979 int rc = ext4_instance_get(service_id, &inst);979 errno_t rc = ext4_instance_get(service_id, &inst); 980 980 if (rc != EOK) 981 981 return rc; … … 1016 1016 * 1017 1017 */ 1018 static int ext4_read(service_id_t service_id, fs_index_t index, aoff64_t pos,1018 static errno_t ext4_read(service_id_t service_id, fs_index_t index, aoff64_t pos, 1019 1019 size_t *rbytes) 1020 1020 { … … 1030 1030 1031 1031 ext4_instance_t *inst; 1032 int rc = ext4_instance_get(service_id, &inst);1032 errno_t rc = ext4_instance_get(service_id, &inst); 1033 1033 if (rc != EOK) { 1034 1034 async_answer_0(callid, rc); … … 1059 1059 } 1060 1060 1061 int const rc2 = ext4_filesystem_put_inode_ref(inode_ref);1061 errno_t const rc2 = ext4_filesystem_put_inode_ref(inode_ref); 1062 1062 1063 1063 return rc == EOK ? rc2 : rc; … … 1095 1095 * 1096 1096 */ 1097 int ext4_read_directory(ipc_callid_t callid, aoff64_t pos, size_t size,1097 errno_t ext4_read_directory(ipc_callid_t callid, aoff64_t pos, size_t size, 1098 1098 ext4_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes) 1099 1099 { 1100 1100 ext4_directory_iterator_t it; 1101 int rc = ext4_directory_iterator_init(&it, inode_ref, pos);1101 errno_t rc = ext4_directory_iterator_init(&it, inode_ref, pos); 1102 1102 if (rc != EOK) { 1103 1103 async_answer_0(callid, rc); … … 1186 1186 * 1187 1187 */ 1188 int ext4_read_file(ipc_callid_t callid, aoff64_t pos, size_t size,1188 errno_t ext4_read_file(ipc_callid_t callid, aoff64_t pos, size_t size, 1189 1189 ext4_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes) 1190 1190 { … … 1211 1211 /* Get the real block number */ 1212 1212 uint32_t fs_block; 1213 int rc = ext4_filesystem_get_inode_data_block_index(inode_ref,1213 errno_t rc = ext4_filesystem_get_inode_data_block_index(inode_ref, 1214 1214 file_block, &fs_block); 1215 1215 if (rc != EOK) { … … 1275 1275 * 1276 1276 */ 1277 static int ext4_write(service_id_t service_id, fs_index_t index, aoff64_t pos,1277 static errno_t ext4_write(service_id_t service_id, fs_index_t index, aoff64_t pos, 1278 1278 size_t *wbytes, aoff64_t *nsize) 1279 1279 { 1280 1280 fs_node_t *fn; 1281 int rc = ext4_node_get(&fn, service_id, index);1281 errno_t rc = ext4_node_get(&fn, service_id, index); 1282 1282 if (rc != EOK) 1283 1283 return rc; … … 1397 1397 ; 1398 1398 1399 int const rc2 = ext4_node_put(fn);1399 errno_t const rc2 = ext4_node_put(fn); 1400 1400 return rc == EOK ? rc2 : rc; 1401 1401 } … … 1412 1412 * 1413 1413 */ 1414 static int ext4_truncate(service_id_t service_id, fs_index_t index,1414 static errno_t ext4_truncate(service_id_t service_id, fs_index_t index, 1415 1415 aoff64_t new_size) 1416 1416 { 1417 1417 fs_node_t *fn; 1418 int rc = ext4_node_get(&fn, service_id, index);1418 errno_t rc = ext4_node_get(&fn, service_id, index); 1419 1419 if (rc != EOK) 1420 1420 return rc; … … 1424 1424 1425 1425 rc = ext4_filesystem_truncate_inode(inode_ref, new_size); 1426 int const rc2 = ext4_node_put(fn);1426 errno_t const rc2 = ext4_node_put(fn); 1427 1427 1428 1428 return rc == EOK ? rc2 : rc; … … 1437 1437 * 1438 1438 */ 1439 static int ext4_close(service_id_t service_id, fs_index_t index)1439 static errno_t ext4_close(service_id_t service_id, fs_index_t index) 1440 1440 { 1441 1441 return EOK; … … 1450 1450 * 1451 1451 */ 1452 static int ext4_destroy(service_id_t service_id, fs_index_t index)1452 static errno_t ext4_destroy(service_id_t service_id, fs_index_t index) 1453 1453 { 1454 1454 fs_node_t *fn; 1455 int rc = ext4_node_get(&fn, service_id, index);1455 errno_t rc = ext4_node_get(&fn, service_id, index); 1456 1456 if (rc != EOK) 1457 1457 return rc; … … 1467 1467 * 1468 1468 */ 1469 static int ext4_sync(service_id_t service_id, fs_index_t index)1469 static errno_t ext4_sync(service_id_t service_id, fs_index_t index) 1470 1470 { 1471 1471 fs_node_t *fn; 1472 int rc = ext4_node_get(&fn, service_id, index);1472 errno_t rc = ext4_node_get(&fn, service_id, index); 1473 1473 if (rc != EOK) 1474 1474 return rc; -
uspace/lib/ext4/src/superblock.c
r36f0738 rb7fd2a0 1127 1127 * 1128 1128 */ 1129 int ext4_superblock_read_direct(service_id_t service_id, ext4_superblock_t **sb)1129 errno_t ext4_superblock_read_direct(service_id_t service_id, ext4_superblock_t **sb) 1130 1130 { 1131 1131 /* Allocated memory for superblock structure */ … … 1135 1135 1136 1136 /* Read data from block device */ 1137 int rc = block_read_bytes_direct(service_id, EXT4_SUPERBLOCK_OFFSET,1137 errno_t rc = block_read_bytes_direct(service_id, EXT4_SUPERBLOCK_OFFSET, 1138 1138 EXT4_SUPERBLOCK_SIZE, data); 1139 1139 … … 1157 1157 * 1158 1158 */ 1159 int ext4_superblock_write_direct(service_id_t service_id, ext4_superblock_t *sb)1159 errno_t ext4_superblock_write_direct(service_id_t service_id, ext4_superblock_t *sb) 1160 1160 { 1161 1161 /* Load physical block size from block device */ 1162 1162 size_t phys_block_size; 1163 int rc = block_get_bsize(service_id, &phys_block_size);1163 errno_t rc = block_get_bsize(service_id, &phys_block_size); 1164 1164 if (rc != EOK) 1165 1165 return rc; … … 1199 1199 * 1200 1200 */ 1201 int ext4_superblock_check_sanity(ext4_superblock_t *sb)1201 errno_t ext4_superblock_check_sanity(ext4_superblock_t *sb) 1202 1202 { 1203 1203 if (ext4_superblock_get_magic(sb) != EXT4_SUPERBLOCK_MAGIC)
Note:
See TracChangeset
for help on using the changeset viewer.