Changeset fb04cd90 in mainline
- Timestamp:
- 2012-05-28T09:56:44Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4585bda
- Parents:
- d0c9b4b
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_block_group.c
rd0c9b4b rfb04cd90 48 48 ext4_superblock_t *sb) 49 49 { 50 if (ext4_superblock_get_desc_size(sb) > EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {50 if (ext4_superblock_get_desc_size(sb) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) { 51 51 return ((uint64_t)uint32_t_le2host(bg->block_bitmap_hi) << 32) | 52 52 uint32_t_le2host(bg->block_bitmap_lo); … … 67 67 bg->block_bitmap_lo = host2uint32_t_le((block_bitmap << 32) >> 32); 68 68 69 if (ext4_superblock_get_desc_size(sb) > EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {69 if (ext4_superblock_get_desc_size(sb) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) { 70 70 bg->block_bitmap_hi = host2uint32_t_le(block_bitmap >> 32); 71 71 } … … 81 81 ext4_superblock_t *sb) 82 82 { 83 if (ext4_superblock_get_desc_size(sb) > EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {83 if (ext4_superblock_get_desc_size(sb) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) { 84 84 return ((uint64_t)uint32_t_le2host(bg->inode_bitmap_hi) << 32) | 85 85 uint32_t_le2host(bg->inode_bitmap_lo); … … 101 101 bg->inode_bitmap_lo = host2uint32_t_le((inode_bitmap << 32) >> 32); 102 102 103 if (ext4_superblock_get_desc_size(sb) > EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {103 if (ext4_superblock_get_desc_size(sb) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) { 104 104 bg->inode_bitmap_hi = host2uint32_t_le(inode_bitmap >> 32); 105 105 } … … 115 115 ext4_superblock_t *sb) 116 116 { 117 if (ext4_superblock_get_desc_size(sb) > EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {117 if (ext4_superblock_get_desc_size(sb) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) { 118 118 return ((uint64_t)uint32_t_le2host(bg->inode_table_first_block_hi) << 32) | 119 119 uint32_t_le2host(bg->inode_table_first_block_lo); … … 136 136 137 137 if (ext4_superblock_get_desc_size(sb) > 138 EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {138 EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) { 139 139 140 140 bg->inode_table_first_block_hi = … … 153 153 { 154 154 if (ext4_superblock_get_desc_size(sb) > 155 EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {155 EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) { 156 156 157 157 return ((uint32_t)uint16_t_le2host(bg->free_blocks_count_hi) << 16) | … … 172 172 { 173 173 bg->free_blocks_count_lo = host2uint16_t_le((value << 16) >> 16); 174 if (ext4_superblock_get_desc_size(sb) > EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {174 if (ext4_superblock_get_desc_size(sb) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) { 175 175 bg->free_blocks_count_hi = host2uint16_t_le(value >> 16); 176 176 } … … 186 186 ext4_superblock_t *sb) 187 187 { 188 if (ext4_superblock_get_desc_size(sb) > EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {188 if (ext4_superblock_get_desc_size(sb) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) { 189 189 return ((uint32_t)uint16_t_le2host(bg->free_inodes_count_hi) << 16) | 190 190 uint16_t_le2host(bg->free_inodes_count_lo); … … 204 204 { 205 205 bg->free_inodes_count_lo = host2uint16_t_le((value << 16) >> 16); 206 if (ext4_superblock_get_desc_size(sb) > EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {206 if (ext4_superblock_get_desc_size(sb) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) { 207 207 bg->free_inodes_count_hi = host2uint16_t_le(value >> 16); 208 208 } … … 218 218 ext4_superblock_t *sb) 219 219 { 220 if (ext4_superblock_get_desc_size(sb) > EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {220 if (ext4_superblock_get_desc_size(sb) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) { 221 221 return ((uint32_t)uint16_t_le2host(bg->used_dirs_count_hi) << 16) | 222 222 uint16_t_le2host(bg->used_dirs_count_lo); … … 236 236 { 237 237 bg->used_dirs_count_lo = host2uint16_t_le((count << 16) >> 16); 238 if (ext4_superblock_get_desc_size(sb) > EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {238 if (ext4_superblock_get_desc_size(sb) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) { 239 239 bg->used_dirs_count_hi = host2uint16_t_le(count >> 16); 240 240 } … … 270 270 ext4_superblock_t *sb) 271 271 { 272 if (ext4_superblock_get_desc_size(sb) > EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {272 if (ext4_superblock_get_desc_size(sb) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) { 273 273 return ((uint32_t)uint16_t_le2host(bg->itable_unused_hi) << 16) | 274 274 uint16_t_le2host(bg->itable_unused_lo); … … 288 288 { 289 289 bg->itable_unused_lo = host2uint16_t_le((value << 16) >> 16); 290 if (ext4_superblock_get_desc_size(sb) > EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {290 if (ext4_superblock_get_desc_size(sb) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) { 291 291 bg->itable_unused_hi = host2uint16_t_le(value >> 16); 292 292 } -
uspace/lib/ext4/libext4_filesystem.c
rd0c9b4b rfb04cd90 95 95 fs->superblock = temp_superblock; 96 96 97 uint16_t state = ext4_superblock_get_state(fs->superblock); 98 99 if (state != EXT4_SUPERBLOCK_STATE_VALID_FS) { 100 return ENOTSUP; 101 } 102 103 // Mark system as mounted 104 ext4_superblock_set_state(fs->superblock, EXT4_SUPERBLOCK_STATE_ERROR_FS); 105 rc = ext4_superblock_write_direct(fs->device, fs->superblock); 106 if (rc != EOK) { 107 return rc; 108 } 109 97 110 return EOK; 98 111 } … … 104 117 * @return error code 105 118 */ 106 int ext4_filesystem_fini(ext4_filesystem_t *fs , bool write_sb)119 int ext4_filesystem_fini(ext4_filesystem_t *fs) 107 120 { 108 121 int rc = EOK; 109 122 110 // If needed, write the superblock to the device 111 if (write_sb) { 112 rc = ext4_superblock_write_direct(fs->device, fs->superblock); 113 } 123 // Write the superblock to the device 124 ext4_superblock_set_state(fs->superblock, EXT4_SUPERBLOCK_STATE_VALID_FS); 125 rc = ext4_superblock_write_direct(fs->device, fs->superblock); 114 126 115 127 // Release memory space for superblock -
uspace/lib/ext4/libext4_filesystem.h
rd0c9b4b rfb04cd90 38 38 39 39 extern int ext4_filesystem_init(ext4_filesystem_t *, service_id_t); 40 extern int ext4_filesystem_fini(ext4_filesystem_t *fs , bool);40 extern int ext4_filesystem_fini(ext4_filesystem_t *fs); 41 41 extern int ext4_filesystem_check_sanity(ext4_filesystem_t *fs); 42 42 extern int ext4_filesystem_check_features(ext4_filesystem_t *, bool *); -
uspace/lib/ext4/libext4_superblock.c
rd0c9b4b rfb04cd90 217 217 } 218 218 219 /** Get logarithmic fragment size (1024 << size) 220 * 221 * @param sb superblock 222 * @return logarithmic fragment size 223 */ 224 uint32_t ext4_superblock_get_log_frag_size(ext4_superblock_t *sb) 225 { 226 return uint32_t_le2host(sb->log_frag_size); 227 } 228 229 /** Set logarithmic fragment size (1024 << size) 230 * 231 * @param sb superblock 232 * @return logarithmic fragment size 233 */ 234 235 void ext4_superblock_set_log_frag_size(ext4_superblock_t *sb, uint32_t frag_size) 236 { 237 sb->log_frag_size = host2uint32_t_le(frag_size); 238 } 239 240 /** Get size of fragment (in bytes). 241 * 242 * @param sb superblock 243 * @return size of fragment 244 */ 245 uint32_t ext4_superblock_get_frag_size(ext4_superblock_t *sb) 246 { 247 return 1024 << ext4_superblock_get_log_frag_size(sb); 248 } 249 250 /** Set size of fragment (in bytes). 251 * 252 * @param sb superblock 253 * @param size size of fragment (must be power of 2, at least 1024) 254 */ 255 void ext4_superblock_set_frag_size(ext4_superblock_t *sb, uint32_t size) 256 { 257 uint32_t log = 0; 258 uint32_t tmp = size / EXT4_MIN_BLOCK_SIZE; 259 260 tmp >>= 1; 261 while (tmp) { 262 log++; 263 tmp >>= 1; 264 } 265 266 ext4_superblock_set_log_frag_size(sb, log); 267 } 268 219 269 /** Get number of data blocks per block group (except last BG) 220 270 * … … 236 286 sb->blocks_per_group = host2uint32_t_le(blocks); 237 287 } 288 289 /** Get number of fragments per block group (except last BG) 290 * 291 * @param sb superblock 292 * @return fragments per block group 293 */ 294 uint32_t ext4_superblock_get_frags_per_group(ext4_superblock_t *sb) 295 { 296 return uint32_t_le2host(sb->frags_per_group); 297 } 298 299 /** Set number of fragment per block group (except last BG) 300 * 301 * @param sb superblock 302 * @param frags fragments per block group 303 */ 304 void ext4_superblock_set_frags_per_group(ext4_superblock_t *sb, uint32_t frags) 305 { 306 sb->frags_per_group = host2uint32_t_le(frags); 307 } 308 238 309 239 310 /** Get number of i-nodes per block group (except last BG) … … 796 867 uint16_t size = uint16_t_le2host(sb->desc_size); 797 868 798 if (size < EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {799 size = EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE;869 if (size < EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) { 870 size = EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE; 800 871 } 801 872 … … 812 883 void ext4_superblock_set_desc_size(ext4_superblock_t *sb, uint16_t size) 813 884 { 814 if (size < EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {815 sb->desc_size = host2uint16_t_le(EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE);885 if (size < EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) { 886 sb->desc_size = host2uint16_t_le(EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE); 816 887 } 817 888 … … 978 1049 } 979 1050 980 // block size 981 // desc size 982 1051 if (ext4_superblock_get_inodes_count(sb) == 0) { 1052 return ENOTSUP; 1053 } 1054 1055 if (ext4_superblock_get_blocks_count(sb) == 0) { 1056 return ENOTSUP; 1057 } 1058 1059 if (ext4_superblock_get_blocks_per_group(sb) == 0) { 1060 return ENOTSUP; 1061 } 1062 1063 if (ext4_superblock_get_inodes_per_group(sb) == 0) { 1064 return ENOTSUP; 1065 } 1066 1067 if (ext4_superblock_get_inode_size(sb) < 128) { 1068 return ENOTSUP; 1069 } 1070 1071 if (ext4_superblock_get_first_inode(sb) < 11) { 1072 return ENOTSUP; 1073 } 1074 1075 if (ext4_superblock_get_desc_size(sb) < EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) { 1076 return ENOTSUP; 1077 } 1078 1079 if (ext4_superblock_get_desc_size(sb) > EXT4_MAX_BLOCK_GROUP_DESCRIPTOR_SIZE) { 1080 return ENOTSUP; 1081 } 983 1082 984 1083 // TODO more checks !!! -
uspace/lib/ext4/libext4_superblock.h
rd0c9b4b rfb04cd90 55 55 extern uint32_t ext4_superblock_get_block_size(ext4_superblock_t *); 56 56 extern void ext4_superblock_set_block_size(ext4_superblock_t *, uint32_t); 57 extern uint32_t ext4_superblock_get_log_frag_size(ext4_superblock_t *); 58 extern void ext4_superblock_set_log_frag_size(ext4_superblock_t *, uint32_t); 59 extern uint32_t ext4_superblock_get_frag_size(ext4_superblock_t *); 60 extern void ext4_superblock_set_frag_size(ext4_superblock_t *, uint32_t); 57 61 extern uint32_t ext4_superblock_get_blocks_per_group(ext4_superblock_t *); 58 62 extern void ext4_superblock_set_blocks_per_group(ext4_superblock_t *, uint32_t); 63 extern uint32_t ext4_superblock_get_frags_per_group(ext4_superblock_t *); 64 extern void ext4_superblock_set_frags_per_group(ext4_superblock_t *, uint32_t); 59 65 extern uint32_t ext4_superblock_get_inodes_per_group(ext4_superblock_t *); 60 66 extern void ext4_superblock_set_inodes_per_group(ext4_superblock_t *, uint32_t); -
uspace/lib/ext4/libext4_types.h
rd0c9b4b rfb04cd90 47 47 uint32_t first_data_block; // First Data Block 48 48 uint32_t log_block_size; // Block size 49 uint32_t obso_log_frag_size; // Obsoleted fragment size49 uint32_t log_frag_size; // Obsoleted fragment size 50 50 uint32_t blocks_per_group; // Number of blocks per group 51 uint32_t obso_frags_per_group; // Obsoleted fragments per group51 uint32_t frags_per_group; // Obsoleted fragments per group 52 52 uint32_t inodes_per_group; // Number of inodes per group 53 53 uint32_t mount_time; // Mount time … … 265 265 266 266 267 #define EXT4_ BLOCK_MIN_GROUP_DESCRIPTOR_SIZE 32268 #define EXT4_ BLOCK_MAX_GROUP_DESCRIPTOR_SIZE 64267 #define EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE 32 268 #define EXT4_MAX_BLOCK_GROUP_DESCRIPTOR_SIZE 64 269 269 270 270 /*****************************************************************************/ -
uspace/srv/fs/ext4fs/ext4fs_ops.c
rd0c9b4b rfb04cd90 936 936 rc = ext4_filesystem_check_sanity(fs); 937 937 if (rc != EOK) { 938 ext4_filesystem_fini(fs , false);938 ext4_filesystem_fini(fs); 939 939 free(fs); 940 940 free(inst); … … 946 946 rc = ext4_filesystem_check_features(fs, &read_only); 947 947 if (rc != EOK) { 948 ext4_filesystem_fini(fs , false);948 ext4_filesystem_fini(fs); 949 949 free(fs); 950 950 free(inst); … … 962 962 rc = ext4fs_node_get_core(&root_node, inst, EXT4_INODE_ROOT_INDEX); 963 963 if (rc != EOK) { 964 ext4_filesystem_fini(fs , false);964 ext4_filesystem_fini(fs); 965 965 free(fs); 966 966 free(inst); … … 1015 1015 fibril_mutex_unlock(&open_nodes_lock); 1016 1016 1017 return ext4_filesystem_fini(inst->filesystem , true);1017 return ext4_filesystem_fini(inst->filesystem); 1018 1018 } 1019 1019
Note:
See TracChangeset
for help on using the changeset viewer.