Changeset 1d6f507 in mainline for uspace/lib/ext2/libext2_superblock.c
- Timestamp:
- 2011-02-14T22:20:09Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d241aae
- Parents:
- 3949e8a0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext2/libext2_superblock.c
r3949e8a0 r1d6f507 247 247 } 248 248 249 /** 250 * Get count of inodes per block group 251 * 252 * @param sb pointer to superblock 253 */ 254 inline uint32_t ext2_superblock_get_inodes_per_group(ext2_superblock_t *sb) 255 { 256 return uint32_t_le2host(sb->inodes_per_group); 257 } 258 259 /** 260 * Compute count of block groups present in the filesystem 261 * 262 * @param sb pointer to superblock 263 */ 264 inline uint32_t ext2_superblock_get_block_group_count(ext2_superblock_t *sb) 265 { 266 return ext2_superblock_get_total_block_count(sb) / 267 ext2_superblock_get_blocks_per_group(sb); 268 } 269 249 270 /** Read a superblock directly from device (i.e. no libblock cache) 250 271 * … … 276 297 } 277 298 299 /** Check a superblock for sanity 300 * 301 * @param sb Pointer to superblock 302 * 303 * @return EOK on success or negative error code on failure. 304 */ 305 int ext2_superblock_check_sanity(ext2_superblock_t *sb) 306 { 307 if (ext2_superblock_get_magic(sb) != EXT2_SUPERBLOCK_MAGIC) { 308 return ENOTSUP; 309 } 310 311 if (ext2_superblock_get_rev_major(sb) > 1) { 312 return ENOTSUP; 313 } 314 315 if (ext2_superblock_get_total_inode_count(sb) == 0) { 316 return ENOTSUP; 317 } 318 319 if (ext2_superblock_get_total_block_count(sb) == 0) { 320 return ENOTSUP; 321 } 322 323 if (ext2_superblock_get_blocks_per_group(sb) == 0) { 324 return ENOTSUP; 325 } 326 327 if (ext2_superblock_get_fragments_per_group(sb) == 0) { 328 return ENOTSUP; 329 } 330 331 // We don't support fragments smaller than block 332 if (ext2_superblock_get_block_size(sb) != 333 ext2_superblock_get_fragment_size(sb)) { 334 return ENOTSUP; 335 } 336 if (ext2_superblock_get_blocks_per_group(sb) != 337 ext2_superblock_get_fragments_per_group(sb)) { 338 return ENOTSUP; 339 } 340 341 if (ext2_superblock_get_inodes_per_group(sb) == 0) { 342 return ENOTSUP; 343 } 344 345 if (ext2_superblock_get_inode_size(sb) < 128) { 346 return ENOTSUP; 347 } 348 349 if (ext2_superblock_get_first_inode(sb) < 11) { 350 return ENOTSUP; 351 } 352 353 return EOK; 354 } 355 278 356 279 357 /** @}
Note:
See TracChangeset
for help on using the changeset viewer.