Changes in uspace/srv/fs/fat/fat_ops.c [cca29e3c:1ee00b7] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_ops.c
rcca29e3c r1ee00b7 94 94 95 95 /* Read the block that contains the dentry of interest. */ 96 rc = _fat_block_get(&b,bs, node->idx->dev_handle, node->idx->pfc,96 b = _fat_block_get(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);99 98 100 99 d = ((fat_dentry_t *)b->data) + (node->idx->pdi % dps); … … 203 202 204 203 /* Read the block that contains the dentry of interest. */ 205 rc = _fat_block_get(&b,bs, idxp->dev_handle, idxp->pfc,204 b = _fat_block_get(bs, idxp->dev_handle, idxp->pfc, 206 205 (idxp->pdi * sizeof(fat_dentry_t)) / bps, BLOCK_FLAGS_NONE); 207 assert( rc == EOK);206 assert(b); 208 207 209 208 d = ((fat_dentry_t *)b->data) + (idxp->pdi % dps); … … 220 219 * size of the directory by walking the FAT. 221 220 */ 222 uint16_t clusters; 223 rc = fat_clusters_get(&clusters, bs, idxp->dev_handle, 221 nodep->size = bps * spc * fat_clusters_get(bs, idxp->dev_handle, 224 222 uint16_t_le2host(d->firstc)); 225 assert(rc == EOK);226 nodep->size = bps * spc * clusters;227 223 } else { 228 224 nodep->type = FAT_FILE; … … 329 325 nodep = fat_node_get_new(); 330 326 if (!nodep) { 331 (void) fat_free_clusters(bs, dev_handle, mcl);327 fat_free_clusters(bs, dev_handle, mcl); 332 328 return NULL; 333 329 } 334 330 idxp = fat_idx_get_new(dev_handle); 335 331 if (!idxp) { 336 (void)fat_free_clusters(bs, dev_handle, mcl);332 fat_free_clusters(bs, dev_handle, mcl); 337 333 fat_node_put(FS_NODE(nodep)); 338 334 return NULL; … … 341 337 if (flags & L_DIRECTORY) { 342 338 /* Populate the new cluster with unused dentries. */ 343 rc = fat_zero_cluster(bs, dev_handle, mcl); 344 assert(rc == EOK); 339 fat_zero_cluster(bs, dev_handle, mcl); 345 340 nodep->type = FAT_DIRECTORY; 346 341 nodep->firstc = mcl; … … 366 361 fat_node_t *nodep = FAT_NODE(fn); 367 362 fat_bs_t *bs; 368 int rc = EOK;369 363 370 364 /* … … 385 379 assert(nodep->size); 386 380 /* Free all clusters allocated to the node. */ 387 rc = fat_free_clusters(bs, nodep->idx->dev_handle, 388 nodep->firstc); 381 fat_free_clusters(bs, nodep->idx->dev_handle, nodep->firstc); 389 382 } 390 383 … … 392 385 free(nodep->bp); 393 386 free(nodep); 394 return rc;387 return EOK; 395 388 } 396 389 … … 440 433 441 434 for (i = 0; i < blocks; i++) { 442 rc = fat_block_get(&b, bs, parentp, i, BLOCK_FLAGS_NONE); 443 assert(rc == EOK); 435 b = fat_block_get(bs, parentp, i, BLOCK_FLAGS_NONE); 444 436 for (j = 0; j < dps; j++) { 445 437 d = ((fat_dentry_t *)b->data) + j; … … 473 465 return rc; 474 466 } 475 rc = fat_zero_cluster(bs, parentp->idx->dev_handle, mcl); 476 assert(rc == EOK); 477 rc = fat_append_clusters(bs, parentp, mcl); 478 assert(rc == EOK); 467 fat_zero_cluster(bs, parentp->idx->dev_handle, mcl); 468 fat_append_clusters(bs, parentp, mcl); 479 469 parentp->size += bps * bs->spc; 480 470 parentp->dirty = true; /* need to sync node */ 481 rc = fat_block_get(&b, bs, parentp, i, BLOCK_FLAGS_NONE); 482 assert(rc == EOK); 471 b = fat_block_get(bs, parentp, i, BLOCK_FLAGS_NONE); 483 472 d = (fat_dentry_t *)b->data; 484 473 … … 505 494 * not use them anyway, so this is rather a sign of our good will. 506 495 */ 507 rc = fat_block_get(&b, bs, childp, 0, BLOCK_FLAGS_NONE); 508 assert(rc == EOK); 496 b = fat_block_get(bs, childp, 0, BLOCK_FLAGS_NONE); 509 497 d = (fat_dentry_t *)b->data; 510 498 if (fat_classify_dentry(d) == FAT_DENTRY_LAST || … … 573 561 bps = uint16_t_le2host(bs->bps); 574 562 575 rc = _fat_block_get(&b,bs, childp->idx->dev_handle, childp->idx->pfc,563 b = _fat_block_get(bs, childp->idx->dev_handle, childp->idx->pfc, 576 564 (childp->idx->pdi * sizeof(fat_dentry_t)) / bps, 577 565 BLOCK_FLAGS_NONE); 578 assert(rc == EOK);579 566 d = (fat_dentry_t *)b->data + 580 567 (childp->idx->pdi % (bps / sizeof(fat_dentry_t))); … … 618 605 blocks = parentp->size / bps; 619 606 for (i = 0; i < blocks; i++) { 620 rc = fat_block_get(&b, bs, parentp, i, BLOCK_FLAGS_NONE); 621 assert(rc == EOK); 607 b = fat_block_get(bs, parentp, i, BLOCK_FLAGS_NONE); 622 608 for (j = 0; j < dps; j++) { 623 609 d = ((fat_dentry_t *)b->data) + j; … … 712 698 fat_dentry_t *d; 713 699 714 rc = fat_block_get(&b, bs, nodep, i, BLOCK_FLAGS_NONE); 715 assert(rc == EOK); 700 b = fat_block_get(bs, nodep, i, BLOCK_FLAGS_NONE); 716 701 for (j = 0; j < dps; j++) { 717 702 d = ((fat_dentry_t *)b->data) + j; … … 833 818 834 819 /* prepare the boot block */ 835 rc = block_bb_read(dev_handle, BS_BLOCK * BS_SIZE, BS_SIZE);820 rc = block_bb_read(dev_handle, BS_BLOCK); 836 821 if (rc != EOK) { 837 822 block_fini(dev_handle); … … 968 953 bytes = min(len, bps - pos % bps); 969 954 bytes = min(bytes, nodep->size - pos); 970 rc = fat_block_get(&b,bs, nodep, pos / bps,955 b = fat_block_get(bs, nodep, pos / bps, 971 956 BLOCK_FLAGS_NONE); 972 assert(rc == EOK);973 957 (void) ipc_data_read_finalize(callid, b->data + pos % bps, 974 958 bytes); … … 996 980 off_t o; 997 981 998 rc = fat_block_get(&b, bs, nodep, bnum, 999 BLOCK_FLAGS_NONE); 1000 assert(rc == EOK); 982 b = fat_block_get(bs, nodep, bnum, BLOCK_FLAGS_NONE); 1001 983 for (o = pos % (bps / sizeof(fat_dentry_t)); 1002 984 o < bps / sizeof(fat_dentry_t); … … 1093 1075 * next block size boundary. 1094 1076 */ 1095 rc = fat_fill_gap(bs, nodep, FAT_CLST_RES0, pos); 1096 assert(rc == EOK); 1097 rc = fat_block_get(&b, bs, nodep, pos / bps, flags); 1098 assert(rc == EOK); 1077 fat_fill_gap(bs, nodep, FAT_CLST_RES0, pos); 1078 b = fat_block_get(bs, nodep, pos / bps, flags); 1099 1079 (void) ipc_data_write_finalize(callid, b->data + pos % bps, 1100 1080 bytes); … … 1129 1109 } 1130 1110 /* zero fill any gaps */ 1131 rc = fat_fill_gap(bs, nodep, mcl, pos); 1132 assert(rc == EOK); 1133 rc = _fat_block_get(&b, bs, dev_handle, lcl, (pos / bps) % spc, 1111 fat_fill_gap(bs, nodep, mcl, pos); 1112 b = _fat_block_get(bs, dev_handle, lcl, (pos / bps) % spc, 1134 1113 flags); 1135 assert(rc == EOK);1136 1114 (void) ipc_data_write_finalize(callid, b->data + pos % bps, 1137 1115 bytes); … … 1143 1121 * node's cluster chain. 1144 1122 */ 1145 rc = fat_append_clusters(bs, nodep, mcl); 1146 assert(rc == EOK); 1123 fat_append_clusters(bs, nodep, mcl); 1147 1124 nodep->size = pos + bytes; 1148 1125 nodep->dirty = true; /* need to sync node */ … … 1197 1174 */ 1198 1175 if (size == 0) { 1199 rc = fat_chop_clusters(bs, nodep, FAT_CLST_RES0); 1200 if (rc != EOK) 1201 goto out; 1176 fat_chop_clusters(bs, nodep, FAT_CLST_RES0); 1202 1177 } else { 1203 1178 fat_cluster_t lastc; 1204 rc = fat_cluster_walk(bs, dev_handle, nodep->firstc, 1205 &lastc, NULL, (size - 1) / bpc); 1206 if (rc != EOK) 1207 goto out; 1208 rc = fat_chop_clusters(bs, nodep, lastc); 1209 if (rc != EOK) 1210 goto out; 1179 (void) fat_cluster_walk(bs, dev_handle, nodep->firstc, 1180 &lastc, (size - 1) / bpc); 1181 fat_chop_clusters(bs, nodep, lastc); 1211 1182 } 1212 1183 nodep->size = size; … … 1214 1185 rc = EOK; 1215 1186 } 1216 out:1217 1187 fat_node_put(fn); 1218 1188 ipc_answer_0(rid, rc);
Note:
See TracChangeset
for help on using the changeset viewer.