Changeset 2c4bbcde in mainline
- Timestamp:
- 2008-05-11T11:16:41Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5d12283
- Parents:
- 4573a79
- Location:
- uspace/srv/fs/fat
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat.h
r4573a79 r2c4bbcde 206 206 */ 207 207 fat_cluster_t firstc; 208 /** FAT in-core node hash table link. */209 link_t fin_link;210 208 /** FAT in-core node free list link. */ 211 209 link_t ffn_link; -
uspace/srv/fs/fat/fat_ops.c
r4573a79 r2c4bbcde 51 51 #define BS_BLOCK 0 52 52 53 #define FIN_KEY_DEV_HANDLE 0 54 #define FIN_KEY_INDEX 1 55 56 /** Hash table of FAT in-core nodes. */ 57 hash_table_t fin_hash; 58 59 /** List of free FAT in-core nodes. */ 60 link_t ffn_head; 53 /** List of free FAT nodes that still contain valid data. */ 54 LIST_INITIALIZE(ffn_head); 61 55 62 56 #define FAT_NAME_LEN 8 … … 126 120 127 121 static block_t * 128 _fat_block_get(dev_handle_t dev_handle, fat_cluster_t f c, off_t offset)122 _fat_block_get(dev_handle_t dev_handle, fat_cluster_t firstc, off_t offset) 129 123 { 130 124 block_t *bb; … … 139 133 unsigned ssa; /* size of the system area */ 140 134 unsigned clusters; 141 fat_cluster_t clst = f c;135 fat_cluster_t clst = firstc; 142 136 unsigned i; 143 137 … … 155 149 ssa = rscnt + fatcnt * sf + rds; 156 150 157 if (f c == FAT_CLST_RES1) {151 if (firstc == FAT_CLST_RES1) { 158 152 /* root directory special case */ 159 153 assert(offset < rds); … … 188 182 node->idx = NULL; 189 183 node->type = 0; 190 link_initialize(&node->fin_link);191 184 link_initialize(&node->ffn_link); 192 185 node->size = 0; … … 239 232 } 240 233 241 static void fat_ sync_node(fat_node_t *node)234 static void fat_node_sync(fat_node_t *node) 242 235 { 243 236 /* TODO */ … … 273 266 assert(idx->pfc); 274 267 275 nodep = (fat_node_t *)malloc(sizeof(fat_node_t)); 276 if (!nodep) 277 return NULL; 268 if (!list_empty(&ffn_head)) { 269 /* Try to use a cached unused node structure. */ 270 nodep = list_get_instance(ffn_head.next, fat_node_t, ffn_link); 271 if (nodep->dirty) 272 fat_node_sync(nodep); 273 list_remove(&nodep->ffn_link); 274 nodep->idx->nodep = NULL; 275 } else { 276 /* Try to allocate a new node structure. */ 277 nodep = (fat_node_t *)malloc(sizeof(fat_node_t)); 278 if (!nodep) 279 return NULL; 280 } 278 281 fat_node_initialize(nodep); 279 282 … … 281 284 dps = bps / sizeof(fat_dentry_t); 282 285 286 /* Read the block that contains the dentry of interest. */ 283 287 b = _fat_block_get(dev_handle, idx->pfc, 284 288 (idx->pdi * sizeof(fat_dentry_t)) / bps); 285 286 289 assert(b); 287 290 288 291 d = ((fat_dentry_t *)b->data) + (idx->pdi % dps); 289 /* XXX */ 292 if (d->attr & FAT_ATTR_SUBDIR) { 293 /* 294 * The only directory which does not have this bit set is the 295 * root directory itself. The root directory node is handled 296 * and initialized elsewhere. 297 */ 298 nodep->type = FAT_DIRECTORY; 299 } else { 300 nodep->type = FAT_FILE; 301 } 302 nodep->firstc = uint16_t_le2host(d->firstc); 303 nodep->size = uint32_t_le2host(d->size); 304 nodep->lnkcnt = 1; 305 nodep->refcnt = 1; 306 307 block_put(b); 308 309 /* Link the idx structure with the node structure. */ 310 nodep->idx = idx; 311 idx->nodep = nodep; 312 313 return nodep; 290 314 } 291 315 … … 441 465 static void *fat_root_get(dev_handle_t dev_handle) 442 466 { 443 return fat_node_get(dev_handle, 0); /* TODO */467 return NULL; /* TODO */ 444 468 } 445 469
Note:
See TracChangeset
for help on using the changeset viewer.