Changes in uspace/srv/fs/fat/fat_fat.c [c7bbf029:db4ec8d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_fat.c
rc7bbf029 rdb4ec8d 47 47 #include <assert.h> 48 48 #include <fibril_synch.h> 49 #include <malloc.h>50 49 #include <mem.h> 51 50 … … 71 70 * 72 71 * @param bs Buffer holding the boot sector for the file. 73 * @param dev map_handle Device handle of the device with the file.72 * @param dev_handle Device handle of the device with the file. 74 73 * @param firstc First cluster to start the walk with. 75 74 * @param lastc If non-NULL, output argument hodling the last cluster … … 82 81 */ 83 82 int 84 fat_cluster_walk(fat_bs_t *bs, dev map_handle_t devmap_handle, fat_cluster_t firstc,83 fat_cluster_walk(fat_bs_t *bs, dev_handle_t dev_handle, fat_cluster_t firstc, 85 84 fat_cluster_t *lastc, uint16_t *numc, uint16_t max_clusters) 86 85 { … … 109 108 fidx = clst % (BPS(bs) / sizeof(fat_cluster_t)); 110 109 /* read FAT1 */ 111 rc = block_get(&b, dev map_handle, RSCNT(bs) + fsec,110 rc = block_get(&b, dev_handle, RSCNT(bs) + fsec, 112 111 BLOCK_FLAGS_NONE); 113 112 if (rc != EOK) … … 160 159 * when fortunately we have the last cluster number cached. 161 160 */ 162 return block_get(block, nodep->idx->dev map_handle,161 return block_get(block, nodep->idx->dev_handle, 163 162 CLBN2PBN(bs, nodep->lastc_cached_value, bn), flags); 164 163 } … … 174 173 175 174 fall_through: 176 rc = _fat_block_get(block, bs, nodep->idx->dev map_handle, firstc,175 rc = _fat_block_get(block, bs, nodep->idx->dev_handle, firstc, 177 176 &currc, relbn, flags); 178 177 if (rc != EOK) … … 193 192 * @param block Pointer to a block pointer for storing result. 194 193 * @param bs Buffer holding the boot sector of the file system. 195 * @param dev map_handle Device handle of the file system.194 * @param dev_handle Device handle of the file system. 196 195 * @param fcl First cluster used by the file. Can be zero if the file 197 196 * is empty. … … 205 204 */ 206 205 int 207 _fat_block_get(block_t **block, fat_bs_t *bs, dev map_handle_t devmap_handle,206 _fat_block_get(block_t **block, fat_bs_t *bs, dev_handle_t dev_handle, 208 207 fat_cluster_t fcl, fat_cluster_t *clp, aoff64_t bn, int flags) 209 208 { … … 222 221 /* root directory special case */ 223 222 assert(bn < RDS(bs)); 224 rc = block_get(block, dev map_handle,223 rc = block_get(block, dev_handle, 225 224 RSCNT(bs) + FATCNT(bs) * SF(bs) + bn, flags); 226 225 return rc; … … 228 227 229 228 max_clusters = bn / SPC(bs); 230 rc = fat_cluster_walk(bs, dev map_handle, fcl, &c, &clusters, max_clusters);229 rc = fat_cluster_walk(bs, dev_handle, fcl, &c, &clusters, max_clusters); 231 230 if (rc != EOK) 232 231 return rc; 233 232 assert(clusters == max_clusters); 234 233 235 rc = block_get(block, dev map_handle, CLBN2PBN(bs, c, bn), flags);234 rc = block_get(block, dev_handle, CLBN2PBN(bs, c, bn), flags); 236 235 237 236 if (clp) … … 281 280 /* zero out the initial part of the new cluster chain */ 282 281 for (o = boundary; o < pos; o += BPS(bs)) { 283 rc = _fat_block_get(&b, bs, nodep->idx->dev map_handle, mcl,282 rc = _fat_block_get(&b, bs, nodep->idx->dev_handle, mcl, 284 283 NULL, (o - boundary) / BPS(bs), BLOCK_FLAGS_NOREAD); 285 284 if (rc != EOK) … … 298 297 * 299 298 * @param bs Buffer holding the boot sector for the file system. 300 * @param dev map_handle Device handle for the file system.299 * @param dev_handle Device handle for the file system. 301 300 * @param clst Cluster which to get. 302 301 * @param value Output argument holding the value of the cluster. … … 305 304 */ 306 305 int 307 fat_get_cluster(fat_bs_t *bs, dev map_handle_t devmap_handle, unsigned fatno,306 fat_get_cluster(fat_bs_t *bs, dev_handle_t dev_handle, unsigned fatno, 308 307 fat_cluster_t clst, fat_cluster_t *value) 309 308 { … … 312 311 int rc; 313 312 314 rc = block_get(&b, dev map_handle, RSCNT(bs) + SF(bs) * fatno +313 rc = block_get(&b, dev_handle, RSCNT(bs) + SF(bs) * fatno + 315 314 (clst * sizeof(fat_cluster_t)) / BPS(bs), BLOCK_FLAGS_NONE); 316 315 if (rc != EOK) … … 327 326 * 328 327 * @param bs Buffer holding the boot sector for the file system. 329 * @param dev map_handle Device handle for the file system.328 * @param dev_handle Device handle for the file system. 330 329 * @param fatno Number of the FAT instance where to make the change. 331 330 * @param clst Cluster which is to be set. … … 335 334 */ 336 335 int 337 fat_set_cluster(fat_bs_t *bs, dev map_handle_t devmap_handle, unsigned fatno,336 fat_set_cluster(fat_bs_t *bs, dev_handle_t dev_handle, unsigned fatno, 338 337 fat_cluster_t clst, fat_cluster_t value) 339 338 { … … 343 342 344 343 assert(fatno < FATCNT(bs)); 345 rc = block_get(&b, dev map_handle, RSCNT(bs) + SF(bs) * fatno +344 rc = block_get(&b, dev_handle, RSCNT(bs) + SF(bs) * fatno + 346 345 (clst * sizeof(fat_cluster_t)) / BPS(bs), BLOCK_FLAGS_NONE); 347 346 if (rc != EOK) … … 358 357 * 359 358 * @param bs Buffer holding the boot sector of the file system. 360 * @param dev map_handle Device handle of the file system.359 * @param dev_handle Device handle of the file system. 361 360 * @param lifo Chain of allocated clusters. 362 361 * @param nclsts Number of clusters in the lifo chain. … … 364 363 * @return EOK on success or a negative error code. 365 364 */ 366 int fat_alloc_shadow_clusters(fat_bs_t *bs, dev map_handle_t devmap_handle,365 int fat_alloc_shadow_clusters(fat_bs_t *bs, dev_handle_t dev_handle, 367 366 fat_cluster_t *lifo, unsigned nclsts) 368 367 { … … 373 372 for (fatno = FAT1 + 1; fatno < bs->fatcnt; fatno++) { 374 373 for (c = 0; c < nclsts; c++) { 375 rc = fat_set_cluster(bs, dev map_handle, fatno, lifo[c],374 rc = fat_set_cluster(bs, dev_handle, fatno, lifo[c], 376 375 c == 0 ? FAT_CLST_LAST1 : lifo[c - 1]); 377 376 if (rc != EOK) … … 391 390 * 392 391 * @param bs Buffer holding the boot sector of the file system. 393 * @param dev map_handle Device handle of the file system.392 * @param dev_handle Device handle of the file system. 394 393 * @param nclsts Number of clusters to allocate. 395 394 * @param mcl Output parameter where the first cluster in the chain … … 401 400 */ 402 401 int 403 fat_alloc_clusters(fat_bs_t *bs, dev map_handle_t devmap_handle, unsigned nclsts,402 fat_alloc_clusters(fat_bs_t *bs, dev_handle_t dev_handle, unsigned nclsts, 404 403 fat_cluster_t *mcl, fat_cluster_t *lcl) 405 404 { … … 419 418 fibril_mutex_lock(&fat_alloc_lock); 420 419 for (b = 0, cl = 0; b < SF(bs); b++) { 421 rc = block_get(&blk, dev map_handle, RSCNT(bs) + b,420 rc = block_get(&blk, dev_handle, RSCNT(bs) + b, 422 421 BLOCK_FLAGS_NONE); 423 422 if (rc != EOK) … … 458 457 /* update the shadow copies of FAT */ 459 458 rc = fat_alloc_shadow_clusters(bs, 460 dev map_handle, lifo, nclsts);459 dev_handle, lifo, nclsts); 461 460 if (rc != EOK) 462 461 goto error; … … 485 484 */ 486 485 while (found--) { 487 rc = fat_set_cluster(bs, dev map_handle, FAT1, lifo[found],486 rc = fat_set_cluster(bs, dev_handle, FAT1, lifo[found], 488 487 FAT_CLST_RES0); 489 488 if (rc != EOK) { … … 500 499 * 501 500 * @param bs Buffer hodling the boot sector of the file system. 502 * @param dev map_handle Device handle of the file system.501 * @param dev_handle Device handle of the file system. 503 502 * @param firstc First cluster in the chain which is to be freed. 504 503 * … … 506 505 */ 507 506 int 508 fat_free_clusters(fat_bs_t *bs, dev map_handle_t devmap_handle, fat_cluster_t firstc)507 fat_free_clusters(fat_bs_t *bs, dev_handle_t dev_handle, fat_cluster_t firstc) 509 508 { 510 509 unsigned fatno; … … 515 514 while (firstc < FAT_CLST_LAST1) { 516 515 assert(firstc >= FAT_CLST_FIRST && firstc < FAT_CLST_BAD); 517 rc = fat_get_cluster(bs, dev map_handle, FAT1, firstc, &nextc);516 rc = fat_get_cluster(bs, dev_handle, FAT1, firstc, &nextc); 518 517 if (rc != EOK) 519 518 return rc; 520 519 for (fatno = FAT1; fatno < bs->fatcnt; fatno++) { 521 rc = fat_set_cluster(bs, dev map_handle, fatno, firstc,520 rc = fat_set_cluster(bs, dev_handle, fatno, firstc, 522 521 FAT_CLST_RES0); 523 522 if (rc != EOK) … … 544 543 fat_cluster_t lcl) 545 544 { 546 dev map_handle_t devmap_handle = nodep->idx->devmap_handle;545 dev_handle_t dev_handle = nodep->idx->dev_handle; 547 546 fat_cluster_t lastc; 548 547 uint8_t fatno; … … 558 557 nodep->lastc_cached_valid = false; 559 558 } else { 560 rc = fat_cluster_walk(bs, dev map_handle, nodep->firstc,559 rc = fat_cluster_walk(bs, dev_handle, nodep->firstc, 561 560 &lastc, NULL, (uint16_t) -1); 562 561 if (rc != EOK) … … 565 564 566 565 for (fatno = FAT1; fatno < bs->fatcnt; fatno++) { 567 rc = fat_set_cluster(bs, nodep->idx->dev map_handle, fatno,566 rc = fat_set_cluster(bs, nodep->idx->dev_handle, fatno, 568 567 lastc, mcl); 569 568 if (rc != EOK) … … 591 590 { 592 591 int rc; 593 dev map_handle_t devmap_handle = nodep->idx->devmap_handle;592 dev_handle_t dev_handle = nodep->idx->dev_handle; 594 593 595 594 /* … … 602 601 if (lcl == FAT_CLST_RES0) { 603 602 /* The node will have zero size and no clusters allocated. */ 604 rc = fat_free_clusters(bs, dev map_handle, nodep->firstc);603 rc = fat_free_clusters(bs, dev_handle, nodep->firstc); 605 604 if (rc != EOK) 606 605 return rc; … … 611 610 unsigned fatno; 612 611 613 rc = fat_get_cluster(bs, dev map_handle, FAT1, lcl, &nextc);612 rc = fat_get_cluster(bs, dev_handle, FAT1, lcl, &nextc); 614 613 if (rc != EOK) 615 614 return rc; … … 617 616 /* Terminate the cluster chain in all copies of FAT. */ 618 617 for (fatno = FAT1; fatno < bs->fatcnt; fatno++) { 619 rc = fat_set_cluster(bs, dev map_handle, fatno, lcl,618 rc = fat_set_cluster(bs, dev_handle, fatno, lcl, 620 619 FAT_CLST_LAST1); 621 620 if (rc != EOK) … … 624 623 625 624 /* Free all following clusters. */ 626 rc = fat_free_clusters(bs, dev map_handle, nextc);625 rc = fat_free_clusters(bs, dev_handle, nextc); 627 626 if (rc != EOK) 628 627 return rc; … … 639 638 640 639 int 641 fat_zero_cluster(struct fat_bs *bs, dev map_handle_t devmap_handle, fat_cluster_t c)640 fat_zero_cluster(struct fat_bs *bs, dev_handle_t dev_handle, fat_cluster_t c) 642 641 { 643 642 int i; … … 646 645 647 646 for (i = 0; i < SPC(bs); i++) { 648 rc = _fat_block_get(&b, bs, dev map_handle, c, NULL, i,647 rc = _fat_block_get(&b, bs, dev_handle, c, NULL, i, 649 648 BLOCK_FLAGS_NOREAD); 650 649 if (rc != EOK) … … 666 665 * does not contain a fat file system. 667 666 */ 668 int fat_sanity_check(fat_bs_t *bs, dev map_handle_t devmap_handle)667 int fat_sanity_check(fat_bs_t *bs, dev_handle_t dev_handle) 669 668 { 670 669 fat_cluster_t e0, e1; … … 707 706 708 707 for (fat_no = 0; fat_no < bs->fatcnt; fat_no++) { 709 rc = fat_get_cluster(bs, dev map_handle, fat_no, 0, &e0);708 rc = fat_get_cluster(bs, dev_handle, fat_no, 0, &e0); 710 709 if (rc != EOK) 711 710 return EIO; 712 711 713 rc = fat_get_cluster(bs, dev map_handle, fat_no, 1, &e1);712 rc = fat_get_cluster(bs, dev_handle, fat_no, 1, &e1); 714 713 if (rc != EOK) 715 714 return EIO;
Note:
See TracChangeset
for help on using the changeset viewer.