Changeset 1d6f507 in mainline
- 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
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/ext2info/ext2info.c
r3949e8a0 r1d6f507 88 88 if (rc != EOK) { 89 89 printf(NAME ": Error initializing libext2.\n"); 90 return 3; 91 } 92 93 rc = ext2_filesystem_check_sanity(&filesystem); 94 if (rc != EOK) { 95 printf(NAME ": Filesystem did not pass sanity check.\n"); 90 96 return 3; 91 97 } -
uspace/lib/ext2/libext2_filesystem.c
r3949e8a0 r1d6f507 46 46 * @param fs Pointer to ext2_filesystem_t to initialize 47 47 * @param devmap_handle Device handle of the block device 48 * 49 * @return EOK on success or negative error code on failure 48 50 */ 49 51 int ext2_filesystem_init(ext2_filesystem_t *fs, devmap_handle_t devmap_handle) … … 85 87 86 88 /** 89 * Check filesystem for sanity 90 * 91 * @param fs Pointer to ext2_filesystem_t to check 92 * @return EOK on success or negative error code on failure 93 */ 94 int ext2_filesystem_check_sanity(ext2_filesystem_t *fs) 95 { 96 int rc; 97 98 rc = ext2_superblock_check_sanity(fs->superblock); 99 if (rc != EOK) { 100 return rc; 101 } 102 103 return EOK; 104 } 105 106 /** 87 107 * Finalize an instance of filesystem 88 108 * -
uspace/lib/ext2/libext2_filesystem.h
r3949e8a0 r1d6f507 51 51 52 52 extern int ext2_filesystem_init(ext2_filesystem_t *, devmap_handle_t); 53 extern int ext2_filesystem_check_sanity(ext2_filesystem_t *); 53 54 extern void ext2_filesystem_fini(ext2_filesystem_t *); 54 55 -
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 /** @} -
uspace/lib/ext2/libext2_superblock.h
r3949e8a0 r1d6f507 99 99 inline uint32_t ext2_superblock_get_free_block_count(ext2_superblock_t *); 100 100 inline uint32_t ext2_superblock_get_free_inode_count(ext2_superblock_t *); 101 inline uint32_t ext2_superblock_get_block_group_count(ext2_superblock_t *); 102 inline uint32_t ext2_superblock_get_inodes_per_group(ext2_superblock_t *); 101 103 102 104 extern int ext2_superblock_read_direct(devmap_handle_t, ext2_superblock_t **); 105 extern int ext2_superblock_check_sanity(ext2_superblock_t *); 103 106 104 107 #endif
Note:
See TracChangeset
for help on using the changeset viewer.