Changeset fe61181 in mainline for uspace/lib/ext4/libext4_filesystem.c
- Timestamp:
- 2012-07-21T08:19:33Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0b293a6
- Parents:
- 34bc2fe
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_filesystem.c
r34bc2fe rfe61181 56 56 rc = block_init(EXCHANGE_SERIALIZE, fs->device, 4096); 57 57 if (rc != EOK) { 58 EXT4FS_DBG("block init error: \%d", rc);59 58 return rc; 60 59 } … … 65 64 if (rc != EOK) { 66 65 block_fini(fs->device); 67 EXT4FS_DBG("superblock read error: \%d", rc);68 66 return rc; 69 67 } … … 73 71 if (block_size > EXT4_MAX_BLOCK_SIZE) { 74 72 block_fini(fs->device); 75 EXT4FS_DBG("get blocksize error: \%d", rc);76 73 return ENOTSUP; 77 74 } … … 81 78 if (rc != EOK) { 82 79 block_fini(fs->device); 83 EXT4FS_DBG("block cache init error: \%d", rc);84 80 return rc; 85 81 } … … 104 100 block_cache_fini(fs->device); 105 101 block_fini(fs->device); 106 EXT4FS_DBG("Unable to mount: Invalid state error");107 102 return ENOTSUP; 108 103 } … … 114 109 block_cache_fini(fs->device); 115 110 block_fini(fs->device); 116 EXT4FS_DBG("state write error: \%d", rc);117 111 return rc; 118 112 } … … 192 186 incompatible_features &= ~EXT4_FEATURE_INCOMPAT_SUPP; 193 187 if (incompatible_features > 0) { 194 EXT4FS_DBG("Not supported incompatible features");195 188 return ENOTSUP; 196 189 } … … 203 196 compatible_read_only &= ~EXT4_FEATURE_RO_COMPAT_SUPP; 204 197 if (compatible_read_only > 0) { 205 EXT4FS_DBG("Not supported readonly features - mounting READ-ONLY");206 198 *read_only = true; 207 199 return EOK; … … 357 349 * @param bg_ref reference to block group 358 350 * @return error code 359 */static int ext4_filesystem_init_inode_table(ext4_block_group_ref_t *bg_ref) 351 */ 352 static int ext4_filesystem_init_inode_table(ext4_block_group_ref_t *bg_ref) 360 353 { 361 354 int rc; … … 1405 1398 } 1406 1399 1407 /** Add orphaned i-node to the orphans linked list.1408 *1409 * @param inode_ref i-node to be added to orphans list1410 * @return error code1411 */1412 int ext4_filesystem_add_orphan(ext4_inode_ref_t *inode_ref)1413 {1414 uint32_t next_orphan = ext4_superblock_get_last_orphan(1415 inode_ref->fs->superblock);1416 1417 /* Deletion time is used for holding next item of the list */1418 ext4_inode_set_deletion_time(inode_ref->inode, next_orphan);1419 1420 /* Head of the list is in the superblock */1421 ext4_superblock_set_last_orphan(1422 inode_ref->fs->superblock, inode_ref->index);1423 inode_ref->dirty = true;1424 1425 return EOK;1426 }1427 1428 /** Delete orphaned i-node from the orphans linked list.1429 *1430 * @param inode_ref i-node to be deleted from the orphans list1431 * @return error code1432 */1433 int ext4_filesystem_delete_orphan(ext4_inode_ref_t *inode_ref)1434 {1435 int rc;1436 1437 /* Get head of the linked list */1438 uint32_t last_orphan = ext4_superblock_get_last_orphan(1439 inode_ref->fs->superblock);1440 1441 assert (last_orphan != 0);1442 1443 ext4_inode_ref_t *current;1444 rc = ext4_filesystem_get_inode_ref(inode_ref->fs, last_orphan, ¤t);1445 if (rc != EOK) {1446 return rc;1447 }1448 1449 uint32_t next_orphan = ext4_inode_get_deletion_time(current->inode);1450 1451 /* Check if the head is the target */1452 if (last_orphan == inode_ref->index) {1453 ext4_superblock_set_last_orphan(inode_ref->fs->superblock, next_orphan);1454 return EOK;1455 }1456 1457 bool found = false;1458 1459 /* Walk thourgh the linked list */1460 while (next_orphan != 0) {1461 1462 /* Found? */1463 if (next_orphan == inode_ref->index) {1464 next_orphan = ext4_inode_get_deletion_time(inode_ref->inode);1465 ext4_inode_set_deletion_time(current->inode, next_orphan);1466 current->dirty = true;1467 found = true;1468 break;1469 }1470 1471 ext4_filesystem_put_inode_ref(current);1472 1473 rc = ext4_filesystem_get_inode_ref(inode_ref->fs, next_orphan, ¤t);1474 if (rc != EOK) {1475 return rc;1476 }1477 next_orphan = ext4_inode_get_deletion_time(current->inode);1478 1479 }1480 1481 rc = ext4_filesystem_put_inode_ref(current);1482 if (rc != EOK) {1483 return rc;1484 }1485 1486 if (!found) {1487 return ENOENT;1488 } else {1489 return EOK;1490 }1491 }1492 1493 1400 /** 1494 1401 * @}
Note:
See TracChangeset
for help on using the changeset viewer.