Changeset 4573a79 in mainline
- Timestamp:
- 2008-05-08T21:29:24Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2c4bbcde
- Parents:
- 4797132
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_ops.c
r4797132 r4573a79 122 122 #define FAT_CLST_LAST8 0xffff 123 123 124 static block_t *fat_block_get(fat_node_t *nodep, off_t offset) 124 #define fat_block_get(np, off) \ 125 _fat_block_get((np)->idx->dev_handle, (np)->firstc, (off)) 126 127 static block_t * 128 _fat_block_get(dev_handle_t dev_handle, fat_cluster_t fc, off_t offset) 125 129 { 126 130 block_t *bb; … … 135 139 unsigned ssa; /* size of the system area */ 136 140 unsigned clusters; 137 fat_cluster_t clst = nodep->firstc;141 fat_cluster_t clst = fc; 138 142 unsigned i; 139 143 140 bb = block_get( nodep->idx->dev_handle, BS_BLOCK);144 bb = block_get(dev_handle, BS_BLOCK); 141 145 bps = uint16_t_le2host(FAT_BS(bb)->bps); 142 146 spc = FAT_BS(bb)->spc; … … 151 155 ssa = rscnt + fatcnt * sf + rds; 152 156 153 if ( nodep->idx->index== FAT_CLST_RES1) {157 if (fc == FAT_CLST_RES1) { 154 158 /* root directory special case */ 155 159 assert(offset < rds); 156 b = block_get(nodep->idx->dev_handle, 157 rscnt + fatcnt * sf + offset); 160 b = block_get(dev_handle, rscnt + fatcnt * sf + offset); 158 161 return b; 159 162 } … … 168 171 fidx = clst % (bps / sizeof(fat_cluster_t)); 169 172 /* read FAT1 */ 170 b = block_get( nodep->idx->dev_handle, rscnt + fsec);173 b = block_get(dev_handle, rscnt + fsec); 171 174 clst = uint16_t_le2host(((fat_cluster_t *)b->data)[fidx]); 172 175 assert(clst != FAT_CLST_BAD); … … 175 178 } 176 179 177 b = block_get( nodep->idx->dev_handle, ssa+178 (clst - FAT_CLST_FIRST) * spc +offset % spc);180 b = block_get(dev_handle, ssa + (clst - FAT_CLST_FIRST) * spc + 181 offset % spc); 179 182 180 183 return b; … … 242 245 243 246 /** Instantiate a FAT in-core node. */ 244 static void * 245 fat_node_get(dev_handle_t dev_handle, fs_index_t index) 246 { 247 return NULL; /* TODO */ 247 static void *fat_node_get(dev_handle_t dev_handle, fs_index_t index) 248 { 249 fat_idx_t *idx; 250 block_t *b; 251 fat_dentry_t *d; 252 fat_node_t *nodep; 253 unsigned bps; 254 unsigned dps; 255 256 idx = fat_idx_get_by_index(dev_handle, index); 257 if (!idx) 258 return NULL; 259 260 if (idx->nodep) { 261 /* 262 * We are lucky. 263 * The node is already instantiated in memory. 264 */ 265 idx->nodep->refcnt++; 266 return idx->nodep; 267 } 268 269 /* 270 * We must instantiate the node from the file system. 271 */ 272 273 assert(idx->pfc); 274 275 nodep = (fat_node_t *)malloc(sizeof(fat_node_t)); 276 if (!nodep) 277 return NULL; 278 fat_node_initialize(nodep); 279 280 bps = fat_bps_get(dev_handle); 281 dps = bps / sizeof(fat_dentry_t); 282 283 b = _fat_block_get(dev_handle, idx->pfc, 284 (idx->pdi * sizeof(fat_dentry_t)) / bps); 285 286 assert(b); 287 288 d = ((fat_dentry_t *)b->data) + (idx->pdi % dps); 289 /* XXX */ 248 290 } 249 291 … … 399 441 static void *fat_root_get(dev_handle_t dev_handle) 400 442 { 401 return fat_node_get(dev_handle, FAT_CLST_RES1);443 return fat_node_get(dev_handle, 0); /* TODO */ 402 444 } 403 445
Note:
See TracChangeset
for help on using the changeset viewer.