Changes in uspace/lib/ext4/src/superblock.c [5a6cc679:a35b458] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/src/superblock.c
r5a6cc679 ra35b458 241 241 uint32_t log = 0; 242 242 uint32_t tmp = size / EXT4_MIN_BLOCK_SIZE; 243 243 244 244 tmp >>= 1; 245 245 while (tmp) { … … 247 247 tmp >>= 1; 248 248 } 249 249 250 250 ext4_superblock_set_log_block_size(sb, log); 251 251 } … … 297 297 uint32_t log = 0; 298 298 uint32_t tmp = size / EXT4_MIN_BLOCK_SIZE; 299 299 300 300 tmp >>= 1; 301 301 while (tmp) { … … 303 303 tmp >>= 1; 304 304 } 305 305 306 306 ext4_superblock_set_log_frag_size(sb, log); 307 307 } … … 736 736 if (ext4_superblock_get_rev_level(sb) == 0) 737 737 return EXT4_REV0_INODE_SIZE; 738 738 739 739 return uint16_t_le2host(sb->inode_size); 740 740 } … … 1001 1001 { 1002 1002 uint16_t size = uint16_t_le2host(sb->desc_size); 1003 1003 1004 1004 if (size < EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) 1005 1005 size = EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE; 1006 1006 1007 1007 return size; 1008 1008 } … … 1021 1021 sb->desc_size = 1022 1022 host2uint16_t_le(EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE); 1023 1023 1024 1024 sb->desc_size = host2uint16_t_le(size); 1025 1025 } … … 1064 1064 if (ext4_superblock_get_flags(sb) & flag) 1065 1065 return true; 1066 1066 1067 1067 return false; 1068 1068 } … … 1081 1081 if (ext4_superblock_get_features_compatible(sb) & feature) 1082 1082 return true; 1083 1083 1084 1084 return false; 1085 1085 } … … 1098 1098 if (ext4_superblock_get_features_incompatible(sb) & feature) 1099 1099 return true; 1100 1100 1101 1101 return false; 1102 1102 } … … 1115 1115 if (ext4_superblock_get_features_read_only(sb) & feature) 1116 1116 return true; 1117 1117 1118 1118 return false; 1119 1119 } … … 1133 1133 if (data == NULL) 1134 1134 return ENOMEM; 1135 1135 1136 1136 /* Read data from block device */ 1137 1137 errno_t rc = block_read_bytes_direct(service_id, EXT4_SUPERBLOCK_OFFSET, 1138 1138 EXT4_SUPERBLOCK_SIZE, data); 1139 1139 1140 1140 if (rc != EOK) { 1141 1141 free(data); 1142 1142 return rc; 1143 1143 } 1144 1144 1145 1145 /* Set output value */ 1146 1146 (*sb) = data; 1147 1147 1148 1148 return EOK; 1149 1149 } … … 1164 1164 if (rc != EOK) 1165 1165 return rc; 1166 1166 1167 1167 /* Compute address of the first block */ 1168 1168 uint64_t first_block = EXT4_SUPERBLOCK_OFFSET / phys_block_size; 1169 1169 1170 1170 /* Compute number of block to write */ 1171 1171 size_t block_count = EXT4_SUPERBLOCK_SIZE / phys_block_size; 1172 1172 1173 1173 /* Check alignment */ 1174 1174 if (EXT4_SUPERBLOCK_SIZE % phys_block_size) 1175 1175 block_count++; 1176 1176 1177 1177 /* Write data */ 1178 1178 return block_write_direct(service_id, first_block, block_count, sb); … … 1203 1203 if (ext4_superblock_get_magic(sb) != EXT4_SUPERBLOCK_MAGIC) 1204 1204 return ENOTSUP; 1205 1205 1206 1206 if (ext4_superblock_get_inodes_count(sb) == 0) 1207 1207 return ENOTSUP; 1208 1208 1209 1209 if (ext4_superblock_get_blocks_count(sb) == 0) 1210 1210 return ENOTSUP; 1211 1211 1212 1212 if (ext4_superblock_get_blocks_per_group(sb) == 0) 1213 1213 return ENOTSUP; 1214 1214 1215 1215 if (ext4_superblock_get_inodes_per_group(sb) == 0) 1216 1216 return ENOTSUP; 1217 1217 1218 1218 if (ext4_superblock_get_inode_size(sb) < 128) 1219 1219 return ENOTSUP; 1220 1220 1221 1221 if (ext4_superblock_get_first_inode(sb) < 11) 1222 1222 return ENOTSUP; 1223 1223 1224 1224 if (ext4_superblock_get_desc_size(sb) < 1225 1225 EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) 1226 1226 return ENOTSUP; 1227 1227 1228 1228 if (ext4_superblock_get_desc_size(sb) > 1229 1229 EXT4_MAX_BLOCK_GROUP_DESCRIPTOR_SIZE) 1230 1230 return ENOTSUP; 1231 1231 1232 1232 return EOK; 1233 1233 } … … 1244 1244 uint64_t blocks_count = ext4_superblock_get_blocks_count(sb); 1245 1245 uint32_t blocks_per_group = ext4_superblock_get_blocks_per_group(sb); 1246 1246 1247 1247 uint32_t block_groups_count = blocks_count / blocks_per_group; 1248 1248 1249 1249 if (blocks_count % blocks_per_group) 1250 1250 block_groups_count++; 1251 1251 1252 1252 return block_groups_count; 1253 1253 } … … 1269 1269 uint64_t total_blocks = 1270 1270 ext4_superblock_get_blocks_count(sb); 1271 1271 1272 1272 if (bgid < block_group_count - 1) 1273 1273 return blocks_per_group; … … 1292 1292 uint32_t total_inodes = 1293 1293 ext4_superblock_get_inodes_count(sb); 1294 1294 1295 1295 if (bgid < block_group_count - 1) 1296 1296 return inodes_per_group;
Note:
See TracChangeset
for help on using the changeset viewer.