Changeset bb0d3d24 in mainline for uspace/srv/fs/tmpfs/tmpfs_ops.c
- Timestamp:
- 2010-01-26T19:18:21Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2314381
- Parents:
- ce8c848 (diff), e056e820 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/tmpfs/tmpfs_ops.c
rce8c848 rbb0d3d24 147 147 hash_table_t nodes; 148 148 149 #define NODES_KEY_ INDEX 0150 #define NODES_KEY_ DEV1149 #define NODES_KEY_DEV 0 150 #define NODES_KEY_INDEX 1 151 151 152 152 /* Implementation of hash table interface for the nodes hash table. */ … … 166 166 static void nodes_remove_callback(link_t *item) 167 167 { 168 tmpfs_node_t *nodep = hash_table_get_instance(item, tmpfs_node_t, 169 nh_link); 170 171 while (!list_empty(&nodep->cs_head)) { 172 tmpfs_dentry_t *dentryp = list_get_instance(nodep->cs_head.next, 173 tmpfs_dentry_t, link); 174 175 assert(nodep->type == TMPFS_DIRECTORY); 176 list_remove(&dentryp->link); 177 free(dentryp); 178 } 179 180 if (nodep->data) { 181 assert(nodep->type == TMPFS_FILE); 182 free(nodep->data); 183 } 184 free(nodep->bp); 185 free(nodep); 168 186 } 169 187 … … 215 233 } 216 234 235 static void tmpfs_instance_done(dev_handle_t dev_handle) 236 { 237 unsigned long key[] = { 238 [NODES_KEY_DEV] = dev_handle 239 }; 240 /* 241 * Here we are making use of one special feature of our hash table 242 * implementation, which allows to remove more items based on a partial 243 * key match. In the following, we are going to remove all nodes 244 * matching our device handle. The nodes_remove_callback() function will 245 * take care of resource deallocation. 246 */ 247 hash_table_remove(&nodes, key, 1); 248 } 249 217 250 int tmpfs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component) 218 251 { … … 237 270 { 238 271 unsigned long key[] = { 239 [NODES_KEY_ INDEX] = index,240 [NODES_KEY_ DEV] = dev_handle272 [NODES_KEY_DEV] = dev_handle, 273 [NODES_KEY_INDEX] = index 241 274 }; 242 275 link_t *lnk = hash_table_find(&nodes, key); … … 296 329 /* Insert the new node into the nodes hash table. */ 297 330 unsigned long key[] = { 298 [NODES_KEY_ INDEX] = nodep->index,299 [NODES_KEY_ DEV] = nodep->dev_handle331 [NODES_KEY_DEV] = nodep->dev_handle, 332 [NODES_KEY_INDEX] = nodep->index 300 333 }; 301 334 hash_table_insert(&nodes, key, &nodep->nh_link); … … 312 345 313 346 unsigned long key[] = { 314 [NODES_KEY_ INDEX] = nodep->index,315 [NODES_KEY_ DEV] = nodep->dev_handle347 [NODES_KEY_DEV] = nodep->dev_handle, 348 [NODES_KEY_INDEX] = nodep->index 316 349 }; 317 350 hash_table_remove(&nodes, key, 2); 318 351 319 if (nodep->type == TMPFS_FILE)320 free(nodep->data);321 free(nodep->bp);322 free(nodep);352 /* 353 * The nodes_remove_callback() function takes care of the actual 354 * resource deallocation. 355 */ 323 356 return EOK; 324 357 } … … 424 457 /* Initialize TMPFS instance. */ 425 458 if (!tmpfs_instance_init(dev_handle)) { 459 free(opts); 426 460 ipc_answer_0(rid, ENOMEM); 427 461 return; … … 442 476 rootp->lnkcnt); 443 477 } 478 free(opts); 444 479 } 445 480 … … 451 486 void tmpfs_unmounted(ipc_callid_t rid, ipc_call_t *request) 452 487 { 453 ipc_answer_0(rid, ENOTSUP); 488 dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 489 490 tmpfs_instance_done(dev_handle); 491 ipc_answer_0(rid, EOK); 454 492 } 455 493 … … 475 513 link_t *hlp; 476 514 unsigned long key[] = { 477 [NODES_KEY_INDEX] = index,478 515 [NODES_KEY_DEV] = dev_handle, 516 [NODES_KEY_INDEX] = index 479 517 }; 480 518 hlp = hash_table_find(&nodes, key); … … 549 587 link_t *hlp; 550 588 unsigned long key[] = { 551 [NODES_KEY_ INDEX] = index,552 [NODES_KEY_ DEV] = dev_handle589 [NODES_KEY_DEV] = dev_handle, 590 [NODES_KEY_INDEX] = index 553 591 }; 554 592 hlp = hash_table_find(&nodes, key); … … 613 651 link_t *hlp; 614 652 unsigned long key[] = { 615 [NODES_KEY_ INDEX] = index,616 [NODES_KEY_ DEV] = dev_handle653 [NODES_KEY_DEV] = dev_handle, 654 [NODES_KEY_INDEX] = index 617 655 }; 618 656 hlp = hash_table_find(&nodes, key); … … 656 694 link_t *hlp; 657 695 unsigned long key[] = { 658 [NODES_KEY_ INDEX] = index,659 [NODES_KEY_ DEV] = dev_handle696 [NODES_KEY_DEV] = dev_handle, 697 [NODES_KEY_INDEX] = index 660 698 }; 661 699 hlp = hash_table_find(&nodes, key);
Note:
See TracChangeset
for help on using the changeset viewer.