Changeset ea28272 in mainline for uspace/srv/fs/devfs/devfs_ops.c
- Timestamp:
- 2010-12-30T13:43:27Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d770deb
- Parents:
- d70d80ed (diff), f418e51 (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/devfs/devfs_ops.c
rd70d80ed rea28272 60 60 typedef struct { 61 61 devmap_handle_t handle; 62 int phone; 62 int phone; /**< When < 0, the structure is incomplete. */ 63 63 size_t refcount; 64 64 link_t link; 65 fibril_condvar_t cv; /**< Broadcast when completed. */ 65 66 } device_t; 66 67 … … 227 228 [DEVICES_KEY_HANDLE] = (unsigned long) node->handle 228 229 }; 229 230 link_t *lnk; 231 230 232 fibril_mutex_lock(&devices_mutex); 231 link_t *lnk = hash_table_find(&devices, key); 233 restart: 234 lnk = hash_table_find(&devices, key); 232 235 if (lnk == NULL) { 233 236 device_t *dev = (device_t *) malloc(sizeof(device_t)); … … 237 240 } 238 241 242 dev->handle = node->handle; 243 dev->phone = -1; /* mark as incomplete */ 244 dev->refcount = 1; 245 fibril_condvar_initialize(&dev->cv); 246 247 /* 248 * Insert the incomplete device structure so that other 249 * fibrils will not race with us when we drop the mutex 250 * below. 251 */ 252 hash_table_insert(&devices, key, &dev->link); 253 254 /* 255 * Drop the mutex to allow recursive devfs requests. 256 */ 257 fibril_mutex_unlock(&devices_mutex); 258 239 259 int phone = devmap_device_connect(node->handle, 0); 260 261 fibril_mutex_lock(&devices_mutex); 262 263 /* 264 * Notify possible waiters about this device structure 265 * being completed (or destroyed). 266 */ 267 fibril_condvar_broadcast(&dev->cv); 268 240 269 if (phone < 0) { 270 /* 271 * Connecting failed, need to remove the 272 * entry and free the device structure. 273 */ 274 hash_table_remove(&devices, key, DEVICES_KEYS); 241 275 fibril_mutex_unlock(&devices_mutex); 276 242 277 free(dev); 243 278 return ENOENT; 244 279 } 245 280 246 dev->handle = node->handle;281 /* Set the correct phone. */ 247 282 dev->phone = phone; 248 dev->refcount = 1;249 250 hash_table_insert(&devices, key, &dev->link);251 283 } else { 252 284 device_t *dev = hash_table_get_instance(lnk, device_t, link); 285 286 if (dev->phone < 0) { 287 /* 288 * Wait until the device structure is completed 289 * and start from the beginning as the device 290 * structure might have entirely disappeared 291 * while we were not holding the mutex in 292 * fibril_condvar_wait(). 293 */ 294 fibril_condvar_wait(&dev->cv, &devices_mutex); 295 goto restart; 296 } 297 253 298 dev->refcount++; 254 299 } … … 420 465 421 466 /* Accept the mount options */ 422 ipcarg_t retval = async_data_write_accept((void **) &opts, true, 0, 0,467 sysarg_t retval = async_data_write_accept((void **) &opts, true, 0, 0, 423 468 0, NULL); 424 469 if (retval != EOK) { … … 564 609 565 610 device_t *dev = hash_table_get_instance(lnk, device_t, link); 611 assert(dev->phone >= 0); 566 612 567 613 ipc_callid_t callid; … … 575 621 /* Make a request at the driver */ 576 622 ipc_call_t answer; 577 aid_t msg = async_send_3(dev->phone, IPC_GET_ METHOD(*request),623 aid_t msg = async_send_3(dev->phone, IPC_GET_IMETHOD(*request), 578 624 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), 579 625 IPC_GET_ARG3(*request), &answer); … … 584 630 585 631 /* Wait for reply from the driver. */ 586 ipcarg_t rc;632 sysarg_t rc; 587 633 async_wait_for(msg, &rc); 588 634 size_t bytes = IPC_GET_ARG1(answer); … … 627 673 628 674 device_t *dev = hash_table_get_instance(lnk, device_t, link); 675 assert(dev->phone >= 0); 629 676 630 677 ipc_callid_t callid; … … 638 685 /* Make a request at the driver */ 639 686 ipc_call_t answer; 640 aid_t msg = async_send_3(dev->phone, IPC_GET_ METHOD(*request),687 aid_t msg = async_send_3(dev->phone, IPC_GET_IMETHOD(*request), 641 688 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), 642 689 IPC_GET_ARG3(*request), &answer); … … 648 695 649 696 /* Wait for reply from the driver. */ 650 ipcarg_t rc;697 sysarg_t rc; 651 698 async_wait_for(msg, &rc); 652 699 size_t bytes = IPC_GET_ARG1(answer); … … 696 743 697 744 device_t *dev = hash_table_get_instance(lnk, device_t, link); 745 assert(dev->phone >= 0); 698 746 dev->refcount--; 699 747 … … 743 791 744 792 device_t *dev = hash_table_get_instance(lnk, device_t, link); 793 assert(dev->phone >= 0); 745 794 746 795 /* Make a request at the driver */ 747 796 ipc_call_t answer; 748 aid_t msg = async_send_2(dev->phone, IPC_GET_ METHOD(*request),797 aid_t msg = async_send_2(dev->phone, IPC_GET_IMETHOD(*request), 749 798 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), &answer); 750 799 … … 752 801 753 802 /* Wait for reply from the driver */ 754 ipcarg_t rc;803 sysarg_t rc; 755 804 async_wait_for(msg, &rc); 756 805
Note:
See TracChangeset
for help on using the changeset viewer.