Changeset 6c8d267 in mainline
- Timestamp:
- 2008-11-09T14:12:20Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 913a821c
- Parents:
- 24d6efc
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libblock/libblock.c
r24d6efc r6c8d267 300 300 * @return Block structure. 301 301 */ 302 block_t *block_get(dev_handle_t dev_handle, off_t boff)302 block_t *block_get(dev_handle_t dev_handle, bn_t boff) 303 303 { 304 304 devcon_t *devcon; -
uspace/lib/libblock/libblock.h
r24d6efc r6c8d267 45 45 #include <libadt/list.h> 46 46 47 typedef unsigned bn_t; /**< Block number type. */ 48 47 49 typedef struct block { 48 50 /** Futex protecting the reference count. */ … … 57 59 dev_handle_t dev_handle; 58 60 /** Block offset on the block device. Counted in 'size'-byte blocks. */ 59 off_t boff;61 bn_t boff; 60 62 /** Size of the block. */ 61 63 size_t size; … … 76 78 extern int block_cache_init(dev_handle_t, size_t, unsigned); 77 79 78 extern block_t *block_get(dev_handle_t, off_t);80 extern block_t *block_get(dev_handle_t, bn_t); 79 81 extern void block_put(block_t *); 80 82 -
uspace/srv/fs/fat/fat_fat.c
r24d6efc r6c8d267 60 60 * @param dev_handle Device handle of the device with the file. 61 61 * @param firstc First cluster to start the walk with. 62 * @param penult If non-NULL, output argument hodling the 63 * the penultimate cluster visited. 64 * @param ult If non-NULL, output argument holding the 65 * ultimate cluster visited. 62 * @param lastc If non-NULL, output argument hodling the last cluster number visited. 66 63 * @param max_clusters Maximum number of clusters to visit. 67 64 * … … 70 67 uint16_t 71 68 fat_cluster_walk(fat_bs_t *bs, dev_handle_t dev_handle, fat_cluster_t firstc, 72 fat_cluster_t * penult, fat_cluster_t *ult, uint16_t max_clusters)69 fat_cluster_t *lastc, uint16_t max_clusters) 73 70 { 74 71 block_t *b; … … 83 80 if (firstc == FAT_CLST_RES0) { 84 81 /* No space allocated to the file. */ 85 if ( ult)86 * ult= firstc;82 if (lastc) 83 *lastc = firstc; 87 84 return 0; 88 85 } 89 86 90 /* At this point, the meaning of penult is not well-defined. */91 if (penult)92 *penult = FAT_CLST_RES0;93 94 87 while (clst < FAT_CLST_LAST1 && clusters < max_clusters) { 95 unsignedfsec; /* sector offset relative to FAT1 */88 bn_t fsec; /* sector offset relative to FAT1 */ 96 89 unsigned fidx; /* FAT1 entry index */ 97 90 98 91 assert(clst >= FAT_CLST_FIRST); 99 if ( penult)100 * penult = clst; /* remember the penultimate cluster */92 if (lastc) 93 *lastc = clst; /* remember the last cluster number */ 101 94 fsec = (clst * sizeof(fat_cluster_t)) / bps; 102 95 fidx = clst % (bps / sizeof(fat_cluster_t)); … … 109 102 } 110 103 111 if ( ult)112 * ult= clst;104 if (lastc && clst < FAT_CLST_LAST1) 105 *lastc = clst; 113 106 114 107 return clusters; … … 121 114 * @param firstc First cluster used by the file. Can be zero if the file 122 115 * is empty. 123 * @param offset Offset in blocks.116 * @param bn Block number. 124 117 * 125 118 * @return Block structure holding the requested block. … … 127 120 block_t * 128 121 _fat_block_get(fat_bs_t *bs, dev_handle_t dev_handle, fat_cluster_t firstc, 129 off_t offset)122 bn_t bn) 130 123 { 131 124 block_t *b; … … 150 143 if (firstc == FAT_CLST_ROOT) { 151 144 /* root directory special case */ 152 assert( offset< rds);153 b = block_get(dev_handle, rscnt + bs->fatcnt * sf + offset);145 assert(bn < rds); 146 b = block_get(dev_handle, rscnt + bs->fatcnt * sf + bn); 154 147 return b; 155 148 } 156 149 157 max_clusters = offset/ bs->spc;158 clusters = fat_cluster_walk(bs, dev_handle, firstc, NULL,&lastc,150 max_clusters = bn / bs->spc; 151 clusters = fat_cluster_walk(bs, dev_handle, firstc, &lastc, 159 152 max_clusters); 160 153 assert(clusters == max_clusters); 161 154 162 155 b = block_get(dev_handle, ssa + (lastc - FAT_CLST_FIRST) * bs->spc + 163 offset% bs->spc);156 bn % bs->spc); 164 157 165 158 return b; … … 362 355 363 356 if (fat_cluster_walk(bs, nodep->idx->dev_handle, nodep->firstc, &lcl, 364 NULL,(uint16_t) -1) == 0) {357 (uint16_t) -1) == 0) { 365 358 /* No clusters allocated to the node yet. */ 366 359 nodep->firstc = host2uint16_t_le(mcl); -
uspace/srv/fs/fat/fat_fat.h
r24d6efc r6c8d267 36 36 #include "../../vfs/vfs.h" 37 37 #include <stdint.h> 38 #include <libblock.h> 38 39 39 40 #define FAT1 0 … … 59 60 60 61 #define fat_clusters_get(bs, dh, fc) \ 61 fat_cluster_walk((bs), (dh), (fc), NULL, NULL, (uint16_t) -1) 62 #define fat_block_get(bs, np, off) \ 63 _fat_block_get((bs), (np)->idx->dev_handle, (np)->firstc, (off)) 62 fat_cluster_walk((bs), (dh), (fc), NULL, (uint16_t) -1) 63 extern uint16_t fat_cluster_walk(struct fat_bs *, dev_handle_t, fat_cluster_t, 64 fat_cluster_t *, uint16_t); 65 66 #define fat_block_get(bs, np, bn) \ 67 _fat_block_get((bs), (np)->idx->dev_handle, (np)->firstc, (bn)) 64 68 65 69 extern struct block *_fat_block_get(struct fat_bs *, dev_handle_t, 66 fat_cluster_t, off_t); 67 extern uint16_t fat_cluster_walk(struct fat_bs *, dev_handle_t, fat_cluster_t, 68 fat_cluster_t *, fat_cluster_t *, uint16_t); 70 fat_cluster_t, bn_t); 69 71 70 72 extern void fat_append_clusters(struct fat_bs *, struct fat_node *,
Note:
See TracChangeset
for help on using the changeset viewer.