Changeset 64bc4b6 in mainline for uspace/lib/libblock/libblock.c
- Timestamp:
- 2010-01-31T18:05:45Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 430de97
- Parents:
- 7efc517
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libblock/libblock.c
r7efc517 r64bc4b6 198 198 assert(devcon); 199 199 200 if (devcon->cache) 201 (void) block_cache_fini(dev_handle); 202 200 203 devcon_remove(devcon); 201 204 202 205 if (devcon->bb_buf) 203 206 free(devcon->bb_buf); 204 205 if (devcon->cache) {206 hash_table_destroy(&devcon->cache->block_hash);207 free(devcon->cache);208 }209 207 210 208 munmap(devcon->comm_area, devcon->comm_size); … … 302 300 303 301 devcon->cache = cache; 302 return EOK; 303 } 304 305 int block_cache_fini(dev_handle_t dev_handle) 306 { 307 devcon_t *devcon = devcon_search(dev_handle); 308 cache_t *cache; 309 int rc; 310 311 if (!devcon) 312 return ENOENT; 313 if (!devcon->cache) 314 return EOK; 315 cache = devcon->cache; 316 317 /* 318 * We are expecting to find all blocks for this device handle on the 319 * free list, i.e. the block reference count should be zero. Do not 320 * bother with the cache and block locks because we are single-threaded. 321 */ 322 while (!list_empty(&cache->free_head)) { 323 block_t *b = list_get_instance(cache->free_head.next, 324 block_t, free_link); 325 326 list_remove(&b->free_link); 327 if (b->dirty) { 328 memcpy(devcon->comm_area, b->data, b->size); 329 rc = write_blocks(devcon, b->boff, 1); 330 if (rc != EOK) 331 return rc; 332 } 333 334 long key = b->boff; 335 hash_table_remove(&cache->block_hash, &key, 1); 336 337 free(b->data); 338 free(b); 339 } 340 341 hash_table_destroy(&cache->block_hash); 342 devcon->cache = NULL; 343 free(cache); 344 304 345 return EOK; 305 346 }
Note:
See TracChangeset
for help on using the changeset viewer.