Changeset fb04cd90 in mainline for uspace/lib/ext4/libext4_superblock.c
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 !!!
Note:
See TracChangeset
for help on using the changeset viewer.