Changeset f092718 in mainline
- Timestamp:
- 2010-11-27T17:42:19Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a6ba0c9
- Parents:
- 45df59a
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/block/libblock.c
r45df59a rf092718 66 66 fibril_mutex_t lock; 67 67 size_t lblock_size; /**< Logical block size. */ 68 unsigned blocks_cluster; /**< Physical blocks per block_t */ 68 69 unsigned block_count; /**< Total number of blocks. */ 69 70 unsigned blocks_cached; /**< Number of cached blocks. */ … … 90 91 static int get_block_size(int dev_phone, size_t *bsize); 91 92 static int get_num_blocks(int dev_phone, aoff64_t *nblocks); 93 static aoff64_t ba_ltop(devcon_t *devcon, aoff64_t lba); 92 94 93 95 static devcon_t *devcon_search(devmap_handle_t devmap_handle) … … 292 294 cache->mode = mode; 293 295 294 /* No block size translation a.t.m. */ 295 assert(cache->lblock_size == devcon->pblock_size); 296 /* Allow 1:1 or small-to-large block size translation */ 297 if (cache->lblock_size % devcon->pblock_size != 0) 298 return ENOTSUP; 299 300 cache->blocks_cluster = cache->lblock_size / devcon->pblock_size; 296 301 297 302 if (!hash_table_create(&cache->block_hash, CACHE_BUCKETS, 1, … … 329 334 if (b->dirty) { 330 335 memcpy(devcon->comm_area, b->data, b->size); 331 rc = write_blocks(devcon, b-> boff, 1);336 rc = write_blocks(devcon, b->pba, cache->blocks_cluster); 332 337 if (rc != EOK) 333 338 return rc; … … 465 470 fibril_mutex_lock(&devcon->comm_area_lock); 466 471 memcpy(devcon->comm_area, b->data, b->size); 467 rc = write_blocks(devcon, b->boff, 1); 472 rc = write_blocks(devcon, b->pba, 473 cache->blocks_cluster); 468 474 fibril_mutex_unlock(&devcon->comm_area_lock); 469 475 if (rc != EOK) { … … 503 509 b->size = cache->lblock_size; 504 510 b->boff = boff; 511 b->pba = ba_ltop(devcon, b->boff); 505 512 hash_table_insert(&cache->block_hash, &key, &b->hash_link); 506 513 … … 519 526 */ 520 527 fibril_mutex_lock(&devcon->comm_area_lock); 521 rc = read_blocks(devcon, b-> boff, 1);528 rc = read_blocks(devcon, b->pba, cache->blocks_cluster); 522 529 memcpy(b->data, devcon->comm_area, cache->lblock_size); 523 530 fibril_mutex_unlock(&devcon->comm_area_lock); … … 580 587 fibril_mutex_lock(&devcon->comm_area_lock); 581 588 memcpy(devcon->comm_area, block->data, block->size); 582 rc = write_blocks(devcon, block-> boff, 1);589 rc = write_blocks(devcon, block->pba, cache->blocks_cluster); 583 590 fibril_mutex_unlock(&devcon->comm_area_lock); 584 591 block->dirty = false; … … 879 886 } 880 887 888 /** Convert logical block address to physical block address. */ 889 static aoff64_t ba_ltop(devcon_t *devcon, aoff64_t lba) 890 { 891 assert(devcon->cache != NULL); 892 return lba * devcon->cache->blocks_cluster; 893 } 894 881 895 /** @} 882 896 */ -
uspace/lib/block/libblock.h
r45df59a rf092718 73 73 /** Handle of the device where the block resides. */ 74 74 devmap_handle_t devmap_handle; 75 /** Block offset on the block device. Counted in 'size'-byte blocks.*/75 /** Logical block address */ 76 76 aoff64_t boff; 77 /** Physical block address */ 78 aoff64_t pba; 77 79 /** Size of the block. */ 78 80 size_t size; -
uspace/srv/fs/fat/fat_fat.c
r45df59a rf092718 671 671 int rc; 672 672 673 printf("fat_sanity_check() begin\n"); 674 673 675 /* Check number of FATs. */ 674 676 if (bs->fatcnt == 0) … … 677 679 /* Check total number of sectors. */ 678 680 681 printf("fat_sanity_check() totsec\n"); 682 679 683 if (bs->totsec16 == 0 && bs->totsec32 == 0) 680 684 return ENOTSUP; 685 686 printf("fat_sanity_check() totsec16 vs 32\n"); 681 687 682 688 if (bs->totsec16 != 0 && bs->totsec32 != 0 && … … 684 690 return ENOTSUP; 685 691 692 printf("fat_sanity_check() media descriptor\n"); 693 686 694 /* Check media descriptor. Must be between 0xf0 and 0xff. */ 687 695 if ((bs->mdesc & 0xf0) != 0xf0) 688 696 return ENOTSUP; 689 697 698 printf("fat_sanity_check() sec_pre_fat\n"); 699 690 700 /* Check number of sectors per FAT. */ 691 701 if (bs->sec_per_fat == 0) 692 702 return ENOTSUP; 703 704 printf("fat_sanity_check() root dir size\n"); 693 705 694 706 /* … … 705 717 /* Check signature of each FAT. */ 706 718 719 printf("fat_sanity_check() FAT signatures\n"); 720 707 721 for (fat_no = 0; fat_no < bs->fatcnt; fat_no++) { 722 printf("fat_sanity_check() read cluster 0\n"); 708 723 rc = fat_get_cluster(bs, devmap_handle, fat_no, 0, &e0); 709 724 if (rc != EOK) 710 725 return EIO; 711 726 727 printf("fat_sanity_check() read cluster 1\n"); 712 728 rc = fat_get_cluster(bs, devmap_handle, fat_no, 1, &e1); 713 729 if (rc != EOK) 714 730 return EIO; 715 731 732 printf("fat_sanity_check() check FAT mdesc\n"); 716 733 /* Check that first byte of FAT contains the media descriptor. */ 717 734 if ((e0 & 0xff) != bs->mdesc) 718 735 return ENOTSUP; 736 737 printf("fat_sanity_check() e0/e1\n"); 719 738 720 739 /* … … 725 744 return ENOTSUP; 726 745 } 746 printf("fat_sanity_check() succeeded\n"); 727 747 728 748 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.