Changeset 684b655 in mainline
- Timestamp:
- 2009-09-03T12:48:35Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e402382
- Parents:
- cffce57
- Location:
- uspace/srv/fs/fat
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_fat.c
rcffce57 r684b655 114 114 /** Read block from file located on a FAT file system. 115 115 * 116 * @param block Pointer to a block pointer for storing result. 116 117 * @param bs Buffer holding the boot sector of the file system. 117 118 * @param dev_handle Device handle of the file system. … … 121 122 * @param flags Flags passed to libblock. 122 123 * 123 * @return Block structure holding the requested block. 124 */ 125 block_t * 126 _fat_block_get(fat_bs_t *bs, dev_handle_t dev_handle, fat_cluster_t firstc, 127 bn_t bn, int flags) 128 { 129 block_t *b; 124 * @return EOK on success or a negative error code. 125 */ 126 int 127 _fat_block_get(block_t **block, fat_bs_t *bs, dev_handle_t dev_handle, 128 fat_cluster_t firstc, bn_t bn, int flags) 129 { 130 130 unsigned bps; 131 131 unsigned rscnt; /* block address of the first FAT */ … … 150 150 /* root directory special case */ 151 151 assert(bn < rds); 152 rc = block_get( &b, dev_handle, rscnt + bs->fatcnt * sf + bn,152 rc = block_get(block, dev_handle, rscnt + bs->fatcnt * sf + bn, 153 153 flags); 154 assert(rc == EOK); 155 return b; 154 return rc; 156 155 } 157 156 … … 161 160 assert(clusters == max_clusters); 162 161 163 rc = block_get(&b, dev_handle, ssa + 164 (lastc - FAT_CLST_FIRST) * bs->spc + bn % bs->spc, flags); 165 assert(rc == EOK); 166 167 return b; 162 rc = block_get(block, dev_handle, 163 ssa + (lastc - FAT_CLST_FIRST) * bs->spc + bn % bs->spc, flags); 164 165 return rc; 168 166 } 169 167 … … 196 194 int flags = (o % bps == 0) ? 197 195 BLOCK_FLAGS_NOREAD : BLOCK_FLAGS_NONE; 198 b = fat_block_get(bs, nodep, o / bps, flags); 196 rc = fat_block_get(&b, bs, nodep, o / bps, flags); 197 assert(rc == EOK); 199 198 memset(b->data + o % bps, 0, bps - o % bps); 200 199 b->dirty = true; /* need to sync node */ … … 208 207 /* zero out the initial part of the new cluster chain */ 209 208 for (o = boundary; o < pos; o += bps) { 210 b = _fat_block_get(bs, nodep->idx->dev_handle, mcl,209 rc = _fat_block_get(&b, bs, nodep->idx->dev_handle, mcl, 211 210 (o - boundary) / bps, BLOCK_FLAGS_NOREAD); 211 assert(rc == EOK); 212 212 memset(b->data, 0, min(bps, pos - o)); 213 213 b->dirty = true; /* need to sync node */ … … 481 481 482 482 for (i = 0; i < bs->spc; i++) { 483 b = _fat_block_get(bs, dev_handle, c, i, BLOCK_FLAGS_NOREAD); 483 rc = _fat_block_get(&b, bs, dev_handle, c, i, 484 BLOCK_FLAGS_NOREAD); 485 assert(rc == EOK); 484 486 memset(b->data, 0, bps); 485 487 b->dirty = true; -
uspace/srv/fs/fat/fat_fat.h
rcffce57 r684b655 64 64 fat_cluster_t *, uint16_t); 65 65 66 #define fat_block_get(bs, np, bn, flags) \ 67 _fat_block_get((bs), (np)->idx->dev_handle, (np)->firstc, (bn), (flags)) 66 #define fat_block_get(b, bs, np, bn, flags) \ 67 _fat_block_get((b), (bs), (np)->idx->dev_handle, (np)->firstc, (bn), \ 68 (flags)) 68 69 69 extern struct block *_fat_block_get(struct fat_bs *, dev_handle_t,70 extern int _fat_block_get(block_t **, struct fat_bs *, dev_handle_t, 70 71 fat_cluster_t, bn_t, int); 71 72 -
uspace/srv/fs/fat/fat_ops.c
rcffce57 r684b655 94 94 95 95 /* Read the block that contains the dentry of interest. */ 96 b = _fat_block_get(bs, node->idx->dev_handle, node->idx->pfc,96 rc = _fat_block_get(&b, bs, node->idx->dev_handle, node->idx->pfc, 97 97 (node->idx->pdi * sizeof(fat_dentry_t)) / bps, BLOCK_FLAGS_NONE); 98 assert(rc == EOK); 98 99 99 100 d = ((fat_dentry_t *)b->data) + (node->idx->pdi % dps); … … 202 203 203 204 /* Read the block that contains the dentry of interest. */ 204 b = _fat_block_get(bs, idxp->dev_handle, idxp->pfc,205 rc = _fat_block_get(&b, bs, idxp->dev_handle, idxp->pfc, 205 206 (idxp->pdi * sizeof(fat_dentry_t)) / bps, BLOCK_FLAGS_NONE); 206 assert( b);207 assert(rc == EOK); 207 208 208 209 d = ((fat_dentry_t *)b->data) + (idxp->pdi % dps); … … 433 434 434 435 for (i = 0; i < blocks; i++) { 435 b = fat_block_get(bs, parentp, i, BLOCK_FLAGS_NONE); 436 rc = fat_block_get(&b, bs, parentp, i, BLOCK_FLAGS_NONE); 437 assert(rc == EOK); 436 438 for (j = 0; j < dps; j++) { 437 439 d = ((fat_dentry_t *)b->data) + j; … … 469 471 parentp->size += bps * bs->spc; 470 472 parentp->dirty = true; /* need to sync node */ 471 b = fat_block_get(bs, parentp, i, BLOCK_FLAGS_NONE); 473 rc = fat_block_get(&b, bs, parentp, i, BLOCK_FLAGS_NONE); 474 assert(rc == EOK); 472 475 d = (fat_dentry_t *)b->data; 473 476 … … 494 497 * not use them anyway, so this is rather a sign of our good will. 495 498 */ 496 b = fat_block_get(bs, childp, 0, BLOCK_FLAGS_NONE); 499 rc = fat_block_get(&b, bs, childp, 0, BLOCK_FLAGS_NONE); 500 assert(rc == EOK); 497 501 d = (fat_dentry_t *)b->data; 498 502 if (fat_classify_dentry(d) == FAT_DENTRY_LAST || … … 561 565 bps = uint16_t_le2host(bs->bps); 562 566 563 b = _fat_block_get(bs, childp->idx->dev_handle, childp->idx->pfc,567 rc = _fat_block_get(&b, bs, childp->idx->dev_handle, childp->idx->pfc, 564 568 (childp->idx->pdi * sizeof(fat_dentry_t)) / bps, 565 569 BLOCK_FLAGS_NONE); 570 assert(rc == EOK); 566 571 d = (fat_dentry_t *)b->data + 567 572 (childp->idx->pdi % (bps / sizeof(fat_dentry_t))); … … 605 610 blocks = parentp->size / bps; 606 611 for (i = 0; i < blocks; i++) { 607 b = fat_block_get(bs, parentp, i, BLOCK_FLAGS_NONE); 612 rc = fat_block_get(&b, bs, parentp, i, BLOCK_FLAGS_NONE); 613 assert(rc == EOK); 608 614 for (j = 0; j < dps; j++) { 609 615 d = ((fat_dentry_t *)b->data) + j; … … 698 704 fat_dentry_t *d; 699 705 700 b = fat_block_get(bs, nodep, i, BLOCK_FLAGS_NONE); 706 rc = fat_block_get(&b, bs, nodep, i, BLOCK_FLAGS_NONE); 707 assert(rc == EOK); 701 708 for (j = 0; j < dps; j++) { 702 709 d = ((fat_dentry_t *)b->data) + j; … … 953 960 bytes = min(len, bps - pos % bps); 954 961 bytes = min(bytes, nodep->size - pos); 955 b = fat_block_get(bs, nodep, pos / bps,962 rc = fat_block_get(&b, bs, nodep, pos / bps, 956 963 BLOCK_FLAGS_NONE); 964 assert(rc == EOK); 957 965 (void) ipc_data_read_finalize(callid, b->data + pos % bps, 958 966 bytes); … … 980 988 off_t o; 981 989 982 b = fat_block_get(bs, nodep, bnum, BLOCK_FLAGS_NONE); 990 rc = fat_block_get(&b, bs, nodep, bnum, 991 BLOCK_FLAGS_NONE); 992 assert(rc == EOK); 983 993 for (o = pos % (bps / sizeof(fat_dentry_t)); 984 994 o < bps / sizeof(fat_dentry_t); … … 1076 1086 */ 1077 1087 fat_fill_gap(bs, nodep, FAT_CLST_RES0, pos); 1078 b = fat_block_get(bs, nodep, pos / bps, flags); 1088 rc = fat_block_get(&b, bs, nodep, pos / bps, flags); 1089 assert(rc == EOK); 1079 1090 (void) ipc_data_write_finalize(callid, b->data + pos % bps, 1080 1091 bytes); … … 1110 1121 /* zero fill any gaps */ 1111 1122 fat_fill_gap(bs, nodep, mcl, pos); 1112 b = _fat_block_get(bs, dev_handle, lcl, (pos / bps) % spc,1123 rc = _fat_block_get(&b, bs, dev_handle, lcl, (pos / bps) % spc, 1113 1124 flags); 1125 assert(rc == EOK); 1114 1126 (void) ipc_data_write_finalize(callid, b->data + pos % bps, 1115 1127 bytes);
Note:
See TracChangeset
for help on using the changeset viewer.