Changeset edb14ca in mainline for uspace/srv/fs/fat/fat_ops.c
- Timestamp:
- 2009-09-21T16:11:52Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0daba21, d27ed12
- Parents:
- c1618ed (diff), 46c0498 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_ops.c
rc1618ed redb14ca 78 78 } 79 79 80 static voidfat_node_sync(fat_node_t *node)80 static int fat_node_sync(fat_node_t *node) 81 81 { 82 82 block_t *b; … … 96 96 rc = _fat_block_get(&b, bs, node->idx->dev_handle, node->idx->pfc, 97 97 (node->idx->pdi * sizeof(fat_dentry_t)) / bps, BLOCK_FLAGS_NONE); 98 assert(rc == EOK); 98 if (rc != EOK) 99 return rc; 99 100 100 101 d = ((fat_dentry_t *)b->data) + (node->idx->pdi % dps); … … 111 112 b->dirty = true; /* need to sync block */ 112 113 rc = block_put(b); 113 assert(rc == EOK);114 return rc; 114 115 } 115 116 … … 118 119 fs_node_t *fn; 119 120 fat_node_t *nodep; 121 int rc; 120 122 121 123 fibril_mutex_lock(&ffn_mutex); … … 133 135 list_remove(&nodep->ffn_link); 134 136 fibril_mutex_unlock(&ffn_mutex); 135 if (nodep->dirty) 136 fat_node_sync(nodep); 137 if (nodep->dirty) { 138 rc = fat_node_sync(nodep); 139 assert(rc == EOK); 140 } 137 141 idxp_tmp->nodep = NULL; 138 142 fibril_mutex_unlock(&nodep->lock); … … 441 445 for (i = 0; i < blocks; i++) { 442 446 rc = fat_block_get(&b, bs, parentp, i, BLOCK_FLAGS_NONE); 443 assert(rc == EOK); 447 if (rc != EOK) { 448 fibril_mutex_unlock(&parentp->idx->lock); 449 return rc; 450 } 444 451 for (j = 0; j < dps; j++) { 445 452 d = ((fat_dentry_t *)b->data) + j; … … 456 463 } 457 464 rc = block_put(b); 458 assert(rc == EOK); 465 if (rc != EOK) { 466 fibril_mutex_unlock(&parentp->idx->lock); 467 return rc; 468 } 459 469 } 460 470 j = 0; … … 474 484 } 475 485 rc = fat_zero_cluster(bs, parentp->idx->dev_handle, mcl); 476 assert(rc == EOK); 486 if (rc != EOK) { 487 fibril_mutex_unlock(&parentp->idx->lock); 488 return rc; 489 } 477 490 rc = fat_append_clusters(bs, parentp, mcl); 478 assert(rc == EOK); 491 if (rc != EOK) { 492 fibril_mutex_unlock(&parentp->idx->lock); 493 return rc; 494 } 479 495 parentp->size += bps * bs->spc; 480 496 parentp->dirty = true; /* need to sync node */ 481 497 rc = fat_block_get(&b, bs, parentp, i, BLOCK_FLAGS_NONE); 482 assert(rc == EOK); 498 if (rc != EOK) { 499 fibril_mutex_unlock(&parentp->idx->lock); 500 return rc; 501 } 483 502 d = (fat_dentry_t *)b->data; 484 503 … … 494 513 b->dirty = true; /* need to sync block */ 495 514 rc = block_put(b); 496 assert(rc == EOK);497 515 fibril_mutex_unlock(&parentp->idx->lock); 516 if (rc != EOK) 517 return rc; 498 518 499 519 fibril_mutex_lock(&childp->idx->lock); … … 506 526 */ 507 527 rc = fat_block_get(&b, bs, childp, 0, BLOCK_FLAGS_NONE); 508 assert(rc == EOK); 528 if (rc != EOK) { 529 /* 530 * Rather than returning an error, simply skip the creation of 531 * these two entries. 532 */ 533 goto skip_dots; 534 } 509 535 d = (fat_dentry_t *)b->data; 510 536 if (fat_classify_dentry(d) == FAT_DENTRY_LAST || … … 530 556 } 531 557 b->dirty = true; /* need to sync block */ 532 rc = block_put(b); 533 assert(rc == EOK); 558 /* 559 * Ignore the return value as we would have fallen through on error 560 * anyway. 561 */ 562 (void) block_put(b); 563 skip_dots: 534 564 535 565 childp->idx->pfc = parentp->firstc; … … 576 606 (childp->idx->pdi * sizeof(fat_dentry_t)) / bps, 577 607 BLOCK_FLAGS_NONE); 578 assert(rc == EOK); 608 if (rc != EOK) 609 goto error; 579 610 d = (fat_dentry_t *)b->data + 580 611 (childp->idx->pdi % (bps / sizeof(fat_dentry_t))); … … 583 614 b->dirty = true; /* need to sync block */ 584 615 rc = block_put(b); 585 assert(rc == EOK); 616 if (rc != EOK) 617 goto error; 586 618 587 619 /* remove the index structure from the position hash */ … … 597 629 598 630 return EOK; 631 632 error: 633 fibril_mutex_unlock(&parentp->idx->lock); 634 fibril_mutex_unlock(&childp->lock); 635 fibril_mutex_unlock(&childp->idx->lock); 636 return rc; 599 637 } 600 638
Note:
See TracChangeset
for help on using the changeset viewer.