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