Changeset cb682eb in mainline for uspace/srv/fs/fat/fat_ops.c
- Timestamp:
- 2008-10-27T12:45:08Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0ec862d
- Parents:
- e17d986
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_ops.c
re17d986 rcb682eb 126 126 static void *fat_node_get_core(fat_idx_t *idxp) 127 127 { 128 block_t *b ;128 block_t *bb, *b; 129 129 fat_dentry_t *d; 130 130 fat_node_t *nodep = NULL; … … 179 179 fat_node_initialize(nodep); 180 180 181 bps = fat_bps_get(idxp->dev_handle); 181 bb = block_get(idxp->dev_handle, BS_BLOCK, BS_SIZE); 182 bps = uint16_t_le2host(FAT_BS(bb)->bps); 182 183 dps = bps / sizeof(fat_dentry_t); 183 184 184 185 /* Read the block that contains the dentry of interest. */ 185 b = _fat_block_get( idxp->dev_handle, idxp->pfc,186 b = _fat_block_get(bb->data, idxp->dev_handle, idxp->pfc, 186 187 (idxp->pdi * sizeof(fat_dentry_t)) / bps); 187 188 assert(b); … … 200 201 * size of the directory by walking the FAT. 201 202 */ 202 nodep->size = bps * _fat_blcks_get( idxp->dev_handle,203 nodep->size = bps * _fat_blcks_get(bb->data, idxp->dev_handle, 203 204 uint16_t_le2host(d->firstc), NULL); 204 205 } else { … … 211 212 212 213 block_put(b); 214 block_put(bb); 213 215 214 216 /* Link the idx structure with the node structure. */ … … 276 278 unsigned blocks; 277 279 fat_dentry_t *d; 278 block_t *b ;280 block_t *bb, *b; 279 281 280 282 futex_down(&parentp->idx->lock); 281 bps = fat_bps_get(parentp->idx->dev_handle); 283 bb = block_get(parentp->idx->dev_handle, BS_BLOCK, BS_SIZE); 284 bps = uint16_t_le2host(FAT_BS(bb)->bps); 282 285 dps = bps / sizeof(fat_dentry_t); 283 286 blocks = parentp->size / bps + (parentp->size % bps != 0); … … 285 288 unsigned dentries; 286 289 287 b = fat_block_get( parentp, i);290 b = fat_block_get(bb->data, parentp, i); 288 291 dentries = (i == blocks - 1) ? 289 292 parentp->size % sizeof(fat_dentry_t) : … … 296 299 case FAT_DENTRY_LAST: 297 300 block_put(b); 301 block_put(bb); 298 302 futex_up(&parentp->idx->lock); 299 303 return NULL; … … 322 326 */ 323 327 block_put(b); 328 block_put(bb); 324 329 return NULL; 325 330 } … … 327 332 futex_up(&idx->lock); 328 333 block_put(b); 334 block_put(bb); 329 335 return node; 330 336 } … … 332 338 block_put(b); 333 339 } 340 block_put(bb); 341 334 342 futex_up(&parentp->idx->lock); 335 343 return NULL; … … 360 368 unsigned dps; 361 369 unsigned blocks; 362 block_t *b ;370 block_t *bb, *b; 363 371 unsigned i, j; 364 372 … … 367 375 368 376 futex_down(&nodep->idx->lock); 369 bps = fat_bps_get(nodep->idx->dev_handle); 377 bb = block_get(nodep->idx->dev_handle, BS_BLOCK, BS_SIZE); 378 bps = uint16_t_le2host(FAT_BS(bb)->bps); 370 379 dps = bps / sizeof(fat_dentry_t); 371 380 … … 376 385 fat_dentry_t *d; 377 386 378 b = fat_block_get( nodep, i);387 b = fat_block_get(bb->data, nodep, i); 379 388 dentries = (i == blocks - 1) ? 380 389 nodep->size % sizeof(fat_dentry_t) : … … 387 396 case FAT_DENTRY_LAST: 388 397 block_put(b); 398 block_put(bb); 389 399 futex_up(&nodep->idx->lock); 390 400 return false; … … 392 402 case FAT_DENTRY_VALID: 393 403 block_put(b); 404 block_put(bb); 394 405 futex_up(&nodep->idx->lock); 395 406 return true; 396 407 } 397 408 block_put(b); 409 block_put(bb); 398 410 futex_up(&nodep->idx->lock); 399 411 return true; … … 401 413 block_put(b); 402 414 } 415 block_put(bb); 403 416 404 417 futex_up(&nodep->idx->lock); … … 553 566 off_t pos = (off_t)IPC_GET_ARG3(*request); 554 567 fat_node_t *nodep = (fat_node_t *)fat_node_get(dev_handle, index); 555 uint16_t bps = fat_bps_get(dev_handle);568 uint16_t bps; 556 569 size_t bytes; 557 block_t *b ;570 block_t *bb, *b; 558 571 559 572 if (!nodep) { … … 570 583 return; 571 584 } 585 586 bb = block_get(dev_handle, BS_BLOCK, BS_SIZE); 587 bps = uint16_t_le2host(FAT_BS(bb)->bps); 572 588 573 589 if (nodep->type == FAT_FILE) { … … 578 594 */ 579 595 bytes = min(len, bps - pos % bps); 580 b = fat_block_get( nodep, pos / bps);596 b = fat_block_get(bb->data, nodep, pos / bps); 581 597 (void) ipc_data_read_finalize(callid, b->data + pos % bps, 582 598 bytes); … … 602 618 off_t o; 603 619 604 b = fat_block_get( nodep, bnum);620 b = fat_block_get(bb->data, nodep, bnum); 605 621 for (o = pos % (bps / sizeof(fat_dentry_t)); 606 622 o < bps / sizeof(fat_dentry_t); … … 625 641 miss: 626 642 fat_node_put(nodep); 643 block_put(bb); 627 644 ipc_answer_0(callid, ENOENT); 628 645 ipc_answer_1(rid, ENOENT, 0); … … 634 651 635 652 fat_node_put(nodep); 653 block_put(bb); 636 654 ipc_answer_1(rid, EOK, (ipcarg_t)bytes); 637 655 } … … 682 700 bps = uint16_t_le2host(FAT_BS(bb)->bps); 683 701 spc = FAT_BS(bb)->spc; 684 block_put(bb);685 702 686 703 boundary = ROUND_UP(nodep->size, bps * spc); … … 692 709 * next block size boundary. 693 710 */ 694 fat_fill_gap( nodep, FAT_CLST_RES0, pos);695 b = fat_block_get( nodep, pos / bps);711 fat_fill_gap(bb->data, nodep, FAT_CLST_RES0, pos); 712 b = fat_block_get(bb->data, nodep, pos / bps); 696 713 (void) ipc_data_write_finalize(callid, b->data + pos % bps, 697 714 bytes); … … 703 720 } 704 721 fat_node_put(nodep); 722 block_put(bb); 705 723 ipc_answer_1(rid, EOK, bytes); 706 724 return; … … 717 735 bps * spc; 718 736 /* create an independent chain of nclsts clusters in all FATs */ 719 status = fat_alloc_clusters(dev_handle, nclsts, &mcl, &lcl); 737 status = fat_alloc_clusters(bb->data, dev_handle, nclsts, &mcl, 738 &lcl); 720 739 if (status != EOK) { 721 740 /* could not allocate a chain of nclsts clusters */ 722 741 fat_node_put(nodep); 742 block_put(bb); 723 743 ipc_answer_0(callid, status); 724 744 ipc_answer_0(rid, status); … … 726 746 } 727 747 /* zero fill any gaps */ 728 fat_fill_gap(nodep, mcl, pos); 729 b = _fat_block_get(dev_handle, lcl, (pos / bps) % spc); 748 fat_fill_gap(bb->data, nodep, mcl, pos); 749 b = _fat_block_get(bb->data, dev_handle, lcl, 750 (pos / bps) % spc); 730 751 (void) ipc_data_write_finalize(callid, b->data + pos % bps, 731 752 bytes); … … 736 757 * node's cluster chain. 737 758 */ 738 fat_append_clusters( nodep, mcl);759 fat_append_clusters(bb->data, nodep, mcl); 739 760 nodep->size = pos + bytes; 740 761 nodep->dirty = true; /* need to sync node */ 741 762 fat_node_put(nodep); 763 block_put(bb); 742 764 ipc_answer_1(rid, EOK, bytes); 743 765 return;
Note:
See TracChangeset
for help on using the changeset viewer.