Changeset f061de75 in mainline
- Timestamp:
- 2011-08-14T17:24:52Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cd860fc
- Parents:
- 25c60f4
- Location:
- uspace/srv/fs/exfat
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/exfat/exfat_directory.c
r25c60f4 rf061de75 54 54 di->bnum = 0; 55 55 di->last = false; 56 di->fragmented = false; 57 di->firstc = 0; 56 58 } 57 59 … … 62 64 if (di->nodep->type != EXFAT_DIRECTORY) 63 65 return EINVAL; 64 65 di->bs = block_bb_get(di->nodep->idx->devmap_handle); 66 di->blocks = di->nodep->size / BPS(di->bs); 66 di->devmap_handle = nodep->idx->devmap_handle; 67 di->fragmented = nodep->fragmented; 68 di->firstc = nodep->firstc; 69 70 di->bs = block_bb_get(di->devmap_handle); 71 di->blocks = nodep->size / BPS(di->bs); 72 return EOK; 73 } 74 75 int exfat_directory_open_parent(exfat_directory_t *di, 76 devmap_handle_t devmap_handle, exfat_cluster_t firstc, bool fragmented) 77 { 78 exfat_directory_init(di); 79 di->devmap_handle = devmap_handle; 80 di->fragmented = fragmented; 81 di->firstc = firstc; 82 di->bs = block_bb_get(devmap_handle); 83 di->blocks = 0; 67 84 return EOK; 68 85 } … … 84 101 85 102 i = (di->pos * sizeof(exfat_dentry_t)) / BPS(di->bs); 86 if (i < di->blocks) { 87 if (di->b && di->bnum != i) { 88 block_put(di->b); 103 if (di->nodep && (i >= di->blocks)) 104 return ENOENT; 105 106 if (di->b && di->bnum != i) { 107 block_put(di->b); 108 di->b = NULL; 109 } 110 if (!di->b) { 111 if (di->nodep) { 112 rc = exfat_block_get(&di->b, di->bs, di->nodep, i, BLOCK_FLAGS_NONE); 113 } else { 114 rc = exfat_block_get_by_clst(&di->b, di->bs, di->devmap_handle, 115 di->fragmented, di->firstc, NULL, i, BLOCK_FLAGS_NONE); 116 } 117 if (rc != EOK) { 89 118 di->b = NULL; 119 return rc; 90 120 } 91 if (!di->b) { 92 rc = exfat_block_get(&di->b, di->bs, di->nodep, i, BLOCK_FLAGS_NONE); 93 if (rc != EOK) { 94 di->b = NULL; 95 return rc; 96 } 97 di->bnum = i; 98 } 99 return EOK; 100 } 101 return ENOENT; 121 di->bnum = i; 122 } 123 return EOK; 102 124 } 103 125 -
uspace/srv/fs/exfat/exfat_directory.h
r25c60f4 rf061de75 36 36 #include <stdint.h> 37 37 #include "exfat.h" 38 #include "exfat_fat.h" 38 39 #include "exfat_dentry.h" 39 40 … … 42 43 exfat_bs_t *bs; 43 44 exfat_node_t *nodep; 45 devmap_handle_t devmap_handle; 44 46 uint32_t blocks; 45 47 uint32_t bnum; … … 47 49 block_t *b; 48 50 bool last; 51 bool fragmented; 52 exfat_cluster_t firstc; 49 53 } __attribute__ ((packed)) exfat_directory_t; 50 54 … … 52 56 extern void exfat_directory_init(exfat_directory_t *di); 53 57 extern int exfat_directory_open(exfat_node_t *nodep, exfat_directory_t *di); 58 extern int exfat_directory_open_parent(exfat_directory_t *di, 59 devmap_handle_t devmap_handle, exfat_cluster_t firstc, bool fragmented); 54 60 extern int exfat_directory_close(exfat_directory_t *di); 55 61 -
uspace/srv/fs/exfat/exfat_ops.c
r25c60f4 rf061de75 112 112 static int exfat_node_sync(exfat_node_t *node) 113 113 { 114 /* TODO */ 114 // block_t *b; 115 // exfat_bs_t *bs; 116 // fat_dentry_t *d; 117 // int rc; 118 119 // assert(node->dirty); 120 121 // bs = block_bb_get(node->idx->devmap_handle); 122 123 /* Read the block that contains the dentry of interest. */ 124 /* 125 rc = _fat_block_get(&b, bs, node->idx->devmap_handle, node->idx->pfc, 126 NULL, (node->idx->pdi * sizeof(fat_dentry_t)) / BPS(bs), 127 BLOCK_FLAGS_NONE); 128 if (rc != EOK) 129 return rc; 130 131 d = ((fat_dentry_t *)b->data) + (node->idx->pdi % DPS(bs)); 132 133 d->firstc = host2uint16_t_le(node->firstc); 134 if (node->type == FAT_FILE) { 135 d->size = host2uint32_t_le(node->size); 136 } else if (node->type == FAT_DIRECTORY) { 137 d->attr = FAT_ATTR_SUBDIR; 138 } 139 */ 140 /* TODO: update other fields? (e.g time fields) */ 141 142 // b->dirty = true; /* need to sync block */ 143 // rc = block_put(b); 144 // return rc; 115 145 return EOK; 116 146 } … … 366 396 367 397 if (nodep->fragmented) { 368 /* TODO */369 398 rc = bitmap_append_clusters(bs, nodep, clusters); 370 399 if (rc != ENOSPC) … … 406 435 407 436 if (nodep->fragmented) { 408 /* TODO */409 437 exfat_cluster_t clsts, prev_clsts, new_clsts; 410 438 prev_clsts = ROUND_UP(nodep->size, BPC(bs)) / BPC(bs); … … 414 442 415 443 clsts = prev_clsts - new_clsts; 416 417 444 rc = bitmap_free_clusters(bs, nodep, clsts); 418 445 if (rc != EOK) … … 688 715 * dentry data is kept in the child node structure. 689 716 */ 690 691 /* TODO */692 717 rc = exfat_directory_write_file(&di, name); 693 718 if (rc!=EOK) … … 897 922 printf("Sectors per cluster: %d\n", SPC(bs)); 898 923 printf("KBytes per cluster: %d\n", SPC(bs)*BPS(bs)/1024); 899 924 925 /* bitmap_set_cluster(bs, devmap_handle, 9); */ 926 /* bitmap_clear_cluster(bs, devmap_handle, 9); */ 927 900 928 int i, rc; 901 929 exfat_cluster_t clst; 902 for (i=0; i< 6; i++) {930 for (i=0; i<=10; i++) { 903 931 rc = exfat_get_cluster(bs, devmap_handle, i, &clst); 904 932 if (rc != EOK) 905 933 return; 906 printf("Clst %d: %x\n", i, clst); 934 printf("Clst %d: %x", i, clst); 935 if (i>=2) 936 printf(", Bitmap: %d\n", bitmap_is_free(bs, devmap_handle, i)!=EOK); 937 else 938 printf("\n"); 907 939 } 908 940 }
Note:
See TracChangeset
for help on using the changeset viewer.