Changeset 9a3d5f0 in mainline
- Timestamp:
- 2008-11-09T21:13:30Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- adb5fe3
- Parents:
- ac49f5d1
- Location:
- uspace/srv/fs/fat
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_idx.c
rac49f5d1 r9a3d5f0 339 339 } 340 340 341 static fat_idx_t *fat_idx_get_new_core(dev_handle_t dev_handle) 342 { 343 fat_idx_t *fidx; 344 345 fidx = (fat_idx_t *) malloc(sizeof(fat_idx_t)); 346 if (!fidx) 347 return NULL; 348 if (!fat_idx_alloc(dev_handle, &fidx->index)) { 349 free(fidx); 350 return NULL; 351 } 352 353 link_initialize(&fidx->uph_link); 354 link_initialize(&fidx->uih_link); 355 futex_initialize(&fidx->lock, 1); 356 fidx->dev_handle = dev_handle; 357 fidx->pfc = FAT_CLST_RES0; /* no parent yet */ 358 fidx->pdi = 0; 359 fidx->nodep = NULL; 360 361 return fidx; 362 } 363 364 fat_idx_t *fat_idx_get_new(dev_handle_t dev_handle) 365 { 366 fat_idx_t *fidx; 367 368 futex_down(&used_futex); 369 fidx = fat_idx_get_new_core(dev_handle); 370 if (!fidx) { 371 futex_up(&used_futex); 372 return NULL; 373 } 374 375 unsigned long ikey[] = { 376 [UIH_DH_KEY] = dev_handle, 377 [UIH_INDEX_KEY] = fidx->index, 378 }; 379 380 hash_table_insert(&ui_hash, ikey, &fidx->uih_link); 381 futex_down(&fidx->lock); 382 futex_up(&used_futex); 383 384 return fidx; 385 } 386 341 387 fat_idx_t * 342 388 fat_idx_get_by_pos(dev_handle_t dev_handle, fat_cluster_t pfc, unsigned pdi) … … 355 401 fidx = hash_table_get_instance(l, fat_idx_t, uph_link); 356 402 } else { 357 fidx = (fat_idx_t *) malloc(sizeof(fat_idx_t));403 fidx = fat_idx_get_new_core(dev_handle); 358 404 if (!fidx) { 359 futex_up(&used_futex);360 return NULL;361 }362 if (!fat_idx_alloc(dev_handle, &fidx->index)) {363 free(fidx);364 405 futex_up(&used_futex); 365 406 return NULL; … … 371 412 }; 372 413 373 link_initialize(&fidx->uph_link);374 link_initialize(&fidx->uih_link);375 futex_initialize(&fidx->lock, 1);376 fidx->dev_handle = dev_handle;377 414 fidx->pfc = pfc; 378 415 fidx->pdi = pdi; 379 fidx->nodep = NULL;380 416 381 417 hash_table_insert(&up_hash, pkey, &fidx->uph_link); -
uspace/srv/fs/fat/fat_ops.c
rac49f5d1 r9a3d5f0 103 103 } 104 104 105 /** Internal version of fat_node_get(). 106 * 107 * @param idxp Locked index structure. 108 */ 109 static void *fat_node_get_core(fat_idx_t *idxp) 110 { 111 block_t *b; 112 fat_bs_t *bs; 113 fat_dentry_t *d; 114 fat_node_t *nodep = NULL; 115 unsigned bps; 116 unsigned spc; 117 unsigned dps; 118 119 if (idxp->nodep) { 120 /* 121 * We are lucky. 122 * The node is already instantiated in memory. 123 */ 124 futex_down(&idxp->nodep->lock); 125 if (!idxp->nodep->refcnt++) 126 list_remove(&idxp->nodep->ffn_link); 127 futex_up(&idxp->nodep->lock); 128 return idxp->nodep; 129 } 130 131 /* 132 * We must instantiate the node from the file system. 133 */ 134 135 assert(idxp->pfc); 105 static fat_node_t *fat_node_get_new(void) 106 { 107 fat_node_t *nodep; 136 108 137 109 futex_down(&ffn_futex); … … 163 135 } 164 136 fat_node_initialize(nodep); 137 138 return nodep; 139 } 140 141 /** Internal version of fat_node_get(). 142 * 143 * @param idxp Locked index structure. 144 */ 145 static void *fat_node_get_core(fat_idx_t *idxp) 146 { 147 block_t *b; 148 fat_bs_t *bs; 149 fat_dentry_t *d; 150 fat_node_t *nodep = NULL; 151 unsigned bps; 152 unsigned spc; 153 unsigned dps; 154 155 if (idxp->nodep) { 156 /* 157 * We are lucky. 158 * The node is already instantiated in memory. 159 */ 160 futex_down(&idxp->nodep->lock); 161 if (!idxp->nodep->refcnt++) 162 list_remove(&idxp->nodep->ffn_link); 163 futex_up(&idxp->nodep->lock); 164 return idxp->nodep; 165 } 166 167 /* 168 * We must instantiate the node from the file system. 169 */ 170 171 assert(idxp->pfc); 172 173 nodep = fat_node_get_new(); 174 if (!nodep) 175 return NULL; 165 176 166 177 bs = block_bb_get(idxp->dev_handle);
Note:
See TracChangeset
for help on using the changeset viewer.