Changeset 94e46c9 in mainline for uspace/lib/ext4/libext4_filesystem.c
- Timestamp:
- 2015-05-23T04:09:11Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b5143bd
- Parents:
- a25d893 (diff), 0683992 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_filesystem.c
ra25d893 r94e46c9 53 53 enum cache_mode cmode) 54 54 { 55 ext4_superblock_t *temp_superblock = NULL; 56 55 57 fs->device = service_id; 56 58 57 59 /* Initialize block library (4096 is size of communication channel) */ 58 60 int rc = block_init(EXCHANGE_SERIALIZE, fs->device, 4096); 59 61 if (rc != EOK) 60 return rc;61 62 goto err; 63 62 64 /* Read superblock from device to memory */ 63 ext4_superblock_t *temp_superblock;64 65 rc = ext4_superblock_read_direct(fs->device, &temp_superblock); 65 if (rc != EOK) { 66 block_fini(fs->device); 67 return rc; 68 } 69 66 if (rc != EOK) 67 goto err_1; 68 70 69 /* Read block size from superblock and check */ 71 70 uint32_t block_size = ext4_superblock_get_block_size(temp_superblock); 72 71 if (block_size > EXT4_MAX_BLOCK_SIZE) { 73 block_fini(fs->device);74 return ENOTSUP;75 } 76 72 rc = ENOTSUP; 73 goto err_1; 74 } 75 77 76 /* Initialize block caching by libblock */ 78 77 rc = block_cache_init(service_id, block_size, 0, cmode); 79 if (rc != EOK) { 80 block_fini(fs->device); 81 return rc; 82 } 83 78 if (rc != EOK) 79 goto err_1; 80 84 81 /* Compute limits for indirect block levels */ 85 82 uint32_t block_ids_per_block = block_size / sizeof(uint32_t); … … 92 89 fs->inode_blocks_per_level[i]; 93 90 } 94 91 95 92 /* Return loaded superblock */ 96 93 fs->superblock = temp_superblock; 97 94 98 95 uint16_t state = ext4_superblock_get_state(fs->superblock); 99 96 100 97 if (((state & EXT4_SUPERBLOCK_STATE_VALID_FS) != 101 98 EXT4_SUPERBLOCK_STATE_VALID_FS) || 102 99 ((state & EXT4_SUPERBLOCK_STATE_ERROR_FS) == 103 100 EXT4_SUPERBLOCK_STATE_ERROR_FS)) { 104 block_cache_fini(fs->device); 105 block_fini(fs->device); 106 return ENOTSUP; 107 } 108 101 rc = ENOTSUP; 102 goto err_2; 103 } 104 109 105 /* Mark system as mounted */ 110 106 ext4_superblock_set_state(fs->superblock, EXT4_SUPERBLOCK_STATE_ERROR_FS); 111 107 rc = ext4_superblock_write_direct(fs->device, fs->superblock); 112 if (rc != EOK) { 113 block_cache_fini(fs->device); 114 block_fini(fs->device); 115 return rc; 116 } 117 108 if (rc != EOK) 109 goto err_2; 110 118 111 uint16_t mnt_count = ext4_superblock_get_mount_count(fs->superblock); 119 112 ext4_superblock_set_mount_count(fs->superblock, mnt_count + 1); 120 113 121 114 return EOK; 115 116 err_2: 117 block_cache_fini(fs->device); 118 err_1: 119 block_fini(fs->device); 120 err: 121 if (temp_superblock) 122 ext4_superblock_release(temp_superblock); 123 return rc; 122 124 } 123 125 … … 845 847 846 848 rc = block_put(subblock); 847 if (rc != EOK) 849 if (rc != EOK) { 850 block_put(block); 848 851 return rc; 852 } 849 853 } 850 854
Note:
See TracChangeset
for help on using the changeset viewer.