Changeset 45f04f8 in mainline for uspace/srv/fs/fat/fat_fat.c
- Timestamp:
- 2010-11-18T18:23:43Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3f0a7971, a7811f17, cb569e6
- Parents:
- 51a268f (diff), c63e70c (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_fat.c
r51a268f r45f04f8 70 70 * 71 71 * @param bs Buffer holding the boot sector for the file. 72 * @param dev _handle Device handle of the device with the file.72 * @param devmap_handle Device handle of the device with the file. 73 73 * @param firstc First cluster to start the walk with. 74 74 * @param lastc If non-NULL, output argument hodling the last cluster … … 81 81 */ 82 82 int 83 fat_cluster_walk(fat_bs_t *bs, dev _handle_t dev_handle, fat_cluster_t firstc,83 fat_cluster_walk(fat_bs_t *bs, devmap_handle_t devmap_handle, fat_cluster_t firstc, 84 84 fat_cluster_t *lastc, uint16_t *numc, uint16_t max_clusters) 85 85 { … … 108 108 fidx = clst % (BPS(bs) / sizeof(fat_cluster_t)); 109 109 /* read FAT1 */ 110 rc = block_get(&b, dev _handle, RSCNT(bs) + fsec,110 rc = block_get(&b, devmap_handle, RSCNT(bs) + fsec, 111 111 BLOCK_FLAGS_NONE); 112 112 if (rc != EOK) … … 159 159 * when fortunately we have the last cluster number cached. 160 160 */ 161 return block_get(block, nodep->idx->dev _handle,161 return block_get(block, nodep->idx->devmap_handle, 162 162 CLBN2PBN(bs, nodep->lastc_cached_value, bn), flags); 163 163 } … … 173 173 174 174 fall_through: 175 rc = _fat_block_get(block, bs, nodep->idx->dev _handle, firstc,175 rc = _fat_block_get(block, bs, nodep->idx->devmap_handle, firstc, 176 176 &currc, relbn, flags); 177 177 if (rc != EOK) … … 192 192 * @param block Pointer to a block pointer for storing result. 193 193 * @param bs Buffer holding the boot sector of the file system. 194 * @param dev _handle Device handle of the file system.194 * @param devmap_handle Device handle of the file system. 195 195 * @param fcl First cluster used by the file. Can be zero if the file 196 196 * is empty. … … 204 204 */ 205 205 int 206 _fat_block_get(block_t **block, fat_bs_t *bs, dev _handle_t dev_handle,206 _fat_block_get(block_t **block, fat_bs_t *bs, devmap_handle_t devmap_handle, 207 207 fat_cluster_t fcl, fat_cluster_t *clp, aoff64_t bn, int flags) 208 208 { … … 221 221 /* root directory special case */ 222 222 assert(bn < RDS(bs)); 223 rc = block_get(block, dev _handle,223 rc = block_get(block, devmap_handle, 224 224 RSCNT(bs) + FATCNT(bs) * SF(bs) + bn, flags); 225 225 return rc; … … 227 227 228 228 max_clusters = bn / SPC(bs); 229 rc = fat_cluster_walk(bs, dev _handle, fcl, &c, &clusters, max_clusters);229 rc = fat_cluster_walk(bs, devmap_handle, fcl, &c, &clusters, max_clusters); 230 230 if (rc != EOK) 231 231 return rc; 232 232 assert(clusters == max_clusters); 233 233 234 rc = block_get(block, dev _handle, CLBN2PBN(bs, c, bn), flags);234 rc = block_get(block, devmap_handle, CLBN2PBN(bs, c, bn), flags); 235 235 236 236 if (clp) … … 280 280 /* zero out the initial part of the new cluster chain */ 281 281 for (o = boundary; o < pos; o += BPS(bs)) { 282 rc = _fat_block_get(&b, bs, nodep->idx->dev _handle, mcl,282 rc = _fat_block_get(&b, bs, nodep->idx->devmap_handle, mcl, 283 283 NULL, (o - boundary) / BPS(bs), BLOCK_FLAGS_NOREAD); 284 284 if (rc != EOK) … … 297 297 * 298 298 * @param bs Buffer holding the boot sector for the file system. 299 * @param dev _handle Device handle for the file system.299 * @param devmap_handle Device handle for the file system. 300 300 * @param clst Cluster which to get. 301 301 * @param value Output argument holding the value of the cluster. … … 304 304 */ 305 305 int 306 fat_get_cluster(fat_bs_t *bs, dev _handle_t dev_handle, unsigned fatno,306 fat_get_cluster(fat_bs_t *bs, devmap_handle_t devmap_handle, unsigned fatno, 307 307 fat_cluster_t clst, fat_cluster_t *value) 308 308 { … … 311 311 int rc; 312 312 313 rc = block_get(&b, dev _handle, RSCNT(bs) + SF(bs) * fatno +313 rc = block_get(&b, devmap_handle, RSCNT(bs) + SF(bs) * fatno + 314 314 (clst * sizeof(fat_cluster_t)) / BPS(bs), BLOCK_FLAGS_NONE); 315 315 if (rc != EOK) … … 326 326 * 327 327 * @param bs Buffer holding the boot sector for the file system. 328 * @param dev _handle Device handle for the file system.328 * @param devmap_handle Device handle for the file system. 329 329 * @param fatno Number of the FAT instance where to make the change. 330 330 * @param clst Cluster which is to be set. … … 334 334 */ 335 335 int 336 fat_set_cluster(fat_bs_t *bs, dev _handle_t dev_handle, unsigned fatno,336 fat_set_cluster(fat_bs_t *bs, devmap_handle_t devmap_handle, unsigned fatno, 337 337 fat_cluster_t clst, fat_cluster_t value) 338 338 { … … 342 342 343 343 assert(fatno < FATCNT(bs)); 344 rc = block_get(&b, dev _handle, RSCNT(bs) + SF(bs) * fatno +344 rc = block_get(&b, devmap_handle, RSCNT(bs) + SF(bs) * fatno + 345 345 (clst * sizeof(fat_cluster_t)) / BPS(bs), BLOCK_FLAGS_NONE); 346 346 if (rc != EOK) … … 357 357 * 358 358 * @param bs Buffer holding the boot sector of the file system. 359 * @param dev _handle Device handle of the file system.359 * @param devmap_handle Device handle of the file system. 360 360 * @param lifo Chain of allocated clusters. 361 361 * @param nclsts Number of clusters in the lifo chain. … … 363 363 * @return EOK on success or a negative error code. 364 364 */ 365 int fat_alloc_shadow_clusters(fat_bs_t *bs, dev _handle_t dev_handle,365 int fat_alloc_shadow_clusters(fat_bs_t *bs, devmap_handle_t devmap_handle, 366 366 fat_cluster_t *lifo, unsigned nclsts) 367 367 { … … 372 372 for (fatno = FAT1 + 1; fatno < bs->fatcnt; fatno++) { 373 373 for (c = 0; c < nclsts; c++) { 374 rc = fat_set_cluster(bs, dev _handle, fatno, lifo[c],374 rc = fat_set_cluster(bs, devmap_handle, fatno, lifo[c], 375 375 c == 0 ? FAT_CLST_LAST1 : lifo[c - 1]); 376 376 if (rc != EOK) … … 390 390 * 391 391 * @param bs Buffer holding the boot sector of the file system. 392 * @param dev _handle Device handle of the file system.392 * @param devmap_handle Device handle of the file system. 393 393 * @param nclsts Number of clusters to allocate. 394 394 * @param mcl Output parameter where the first cluster in the chain … … 400 400 */ 401 401 int 402 fat_alloc_clusters(fat_bs_t *bs, dev _handle_t dev_handle, unsigned nclsts,402 fat_alloc_clusters(fat_bs_t *bs, devmap_handle_t devmap_handle, unsigned nclsts, 403 403 fat_cluster_t *mcl, fat_cluster_t *lcl) 404 404 { … … 418 418 fibril_mutex_lock(&fat_alloc_lock); 419 419 for (b = 0, cl = 0; b < SF(bs); b++) { 420 rc = block_get(&blk, dev _handle, RSCNT(bs) + b,420 rc = block_get(&blk, devmap_handle, RSCNT(bs) + b, 421 421 BLOCK_FLAGS_NONE); 422 422 if (rc != EOK) … … 457 457 /* update the shadow copies of FAT */ 458 458 rc = fat_alloc_shadow_clusters(bs, 459 dev _handle, lifo, nclsts);459 devmap_handle, lifo, nclsts); 460 460 if (rc != EOK) 461 461 goto error; … … 484 484 */ 485 485 while (found--) { 486 rc = fat_set_cluster(bs, dev _handle, FAT1, lifo[found],486 rc = fat_set_cluster(bs, devmap_handle, FAT1, lifo[found], 487 487 FAT_CLST_RES0); 488 488 if (rc != EOK) { … … 499 499 * 500 500 * @param bs Buffer hodling the boot sector of the file system. 501 * @param dev _handle Device handle of the file system.501 * @param devmap_handle Device handle of the file system. 502 502 * @param firstc First cluster in the chain which is to be freed. 503 503 * … … 505 505 */ 506 506 int 507 fat_free_clusters(fat_bs_t *bs, dev _handle_t dev_handle, fat_cluster_t firstc)507 fat_free_clusters(fat_bs_t *bs, devmap_handle_t devmap_handle, fat_cluster_t firstc) 508 508 { 509 509 unsigned fatno; … … 514 514 while (firstc < FAT_CLST_LAST1) { 515 515 assert(firstc >= FAT_CLST_FIRST && firstc < FAT_CLST_BAD); 516 rc = fat_get_cluster(bs, dev _handle, FAT1, firstc, &nextc);516 rc = fat_get_cluster(bs, devmap_handle, FAT1, firstc, &nextc); 517 517 if (rc != EOK) 518 518 return rc; 519 519 for (fatno = FAT1; fatno < bs->fatcnt; fatno++) { 520 rc = fat_set_cluster(bs, dev _handle, fatno, firstc,520 rc = fat_set_cluster(bs, devmap_handle, fatno, firstc, 521 521 FAT_CLST_RES0); 522 522 if (rc != EOK) … … 543 543 fat_cluster_t lcl) 544 544 { 545 dev _handle_t dev_handle = nodep->idx->dev_handle;545 devmap_handle_t devmap_handle = nodep->idx->devmap_handle; 546 546 fat_cluster_t lastc; 547 547 uint8_t fatno; … … 557 557 nodep->lastc_cached_valid = false; 558 558 } else { 559 rc = fat_cluster_walk(bs, dev _handle, nodep->firstc,559 rc = fat_cluster_walk(bs, devmap_handle, nodep->firstc, 560 560 &lastc, NULL, (uint16_t) -1); 561 561 if (rc != EOK) … … 564 564 565 565 for (fatno = FAT1; fatno < bs->fatcnt; fatno++) { 566 rc = fat_set_cluster(bs, nodep->idx->dev _handle, fatno,566 rc = fat_set_cluster(bs, nodep->idx->devmap_handle, fatno, 567 567 lastc, mcl); 568 568 if (rc != EOK) … … 590 590 { 591 591 int rc; 592 dev _handle_t dev_handle = nodep->idx->dev_handle;592 devmap_handle_t devmap_handle = nodep->idx->devmap_handle; 593 593 594 594 /* … … 601 601 if (lcl == FAT_CLST_RES0) { 602 602 /* The node will have zero size and no clusters allocated. */ 603 rc = fat_free_clusters(bs, dev _handle, nodep->firstc);603 rc = fat_free_clusters(bs, devmap_handle, nodep->firstc); 604 604 if (rc != EOK) 605 605 return rc; … … 610 610 unsigned fatno; 611 611 612 rc = fat_get_cluster(bs, dev _handle, FAT1, lcl, &nextc);612 rc = fat_get_cluster(bs, devmap_handle, FAT1, lcl, &nextc); 613 613 if (rc != EOK) 614 614 return rc; … … 616 616 /* Terminate the cluster chain in all copies of FAT. */ 617 617 for (fatno = FAT1; fatno < bs->fatcnt; fatno++) { 618 rc = fat_set_cluster(bs, dev _handle, fatno, lcl,618 rc = fat_set_cluster(bs, devmap_handle, fatno, lcl, 619 619 FAT_CLST_LAST1); 620 620 if (rc != EOK) … … 623 623 624 624 /* Free all following clusters. */ 625 rc = fat_free_clusters(bs, dev _handle, nextc);625 rc = fat_free_clusters(bs, devmap_handle, nextc); 626 626 if (rc != EOK) 627 627 return rc; … … 638 638 639 639 int 640 fat_zero_cluster(struct fat_bs *bs, dev _handle_t dev_handle, fat_cluster_t c)640 fat_zero_cluster(struct fat_bs *bs, devmap_handle_t devmap_handle, fat_cluster_t c) 641 641 { 642 642 int i; … … 645 645 646 646 for (i = 0; i < SPC(bs); i++) { 647 rc = _fat_block_get(&b, bs, dev _handle, c, NULL, i,647 rc = _fat_block_get(&b, bs, devmap_handle, c, NULL, i, 648 648 BLOCK_FLAGS_NOREAD); 649 649 if (rc != EOK) … … 665 665 * does not contain a fat file system. 666 666 */ 667 int fat_sanity_check(fat_bs_t *bs, dev _handle_t dev_handle)667 int fat_sanity_check(fat_bs_t *bs, devmap_handle_t devmap_handle) 668 668 { 669 669 fat_cluster_t e0, e1; … … 706 706 707 707 for (fat_no = 0; fat_no < bs->fatcnt; fat_no++) { 708 rc = fat_get_cluster(bs, dev _handle, fat_no, 0, &e0);708 rc = fat_get_cluster(bs, devmap_handle, fat_no, 0, &e0); 709 709 if (rc != EOK) 710 710 return EIO; 711 711 712 rc = fat_get_cluster(bs, dev _handle, fat_no, 1, &e1);712 rc = fat_get_cluster(bs, devmap_handle, fat_no, 1, &e1); 713 713 if (rc != EOK) 714 714 return EIO;
Note:
See TracChangeset
for help on using the changeset viewer.