Changeset 357b5f5 in mainline for uspace/srv/fs/devfs/devfs_ops.c
- Timestamp:
- 2011-01-23T20:09:13Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fdb9982c
- Parents:
- cead2aa (diff), 7e36c8d (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
rcead2aa r357b5f5 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 } … … 409 454 return false; 410 455 411 if (devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING) < 0)412 return false;413 414 456 return true; 415 457 } … … 420 462 421 463 /* Accept the mount options */ 422 ipcarg_t retval = async_data_write_accept((void **) &opts, true, 0, 0,464 sysarg_t retval = async_data_write_accept((void **) &opts, true, 0, 0, 423 465 0, NULL); 424 466 if (retval != EOK) { … … 564 606 565 607 device_t *dev = hash_table_get_instance(lnk, device_t, link); 608 assert(dev->phone >= 0); 566 609 567 610 ipc_callid_t callid; … … 575 618 /* Make a request at the driver */ 576 619 ipc_call_t answer; 577 aid_t msg = async_send_3(dev->phone, IPC_GET_ METHOD(*request),620 aid_t msg = async_send_3(dev->phone, IPC_GET_IMETHOD(*request), 578 621 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), 579 622 IPC_GET_ARG3(*request), &answer); … … 584 627 585 628 /* Wait for reply from the driver. */ 586 ipcarg_t rc;629 sysarg_t rc; 587 630 async_wait_for(msg, &rc); 588 631 size_t bytes = IPC_GET_ARG1(answer); … … 627 670 628 671 device_t *dev = hash_table_get_instance(lnk, device_t, link); 672 assert(dev->phone >= 0); 629 673 630 674 ipc_callid_t callid; … … 638 682 /* Make a request at the driver */ 639 683 ipc_call_t answer; 640 aid_t msg = async_send_3(dev->phone, IPC_GET_ METHOD(*request),684 aid_t msg = async_send_3(dev->phone, IPC_GET_IMETHOD(*request), 641 685 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), 642 686 IPC_GET_ARG3(*request), &answer); … … 648 692 649 693 /* Wait for reply from the driver. */ 650 ipcarg_t rc;694 sysarg_t rc; 651 695 async_wait_for(msg, &rc); 652 696 size_t bytes = IPC_GET_ARG1(answer); … … 696 740 697 741 device_t *dev = hash_table_get_instance(lnk, device_t, link); 742 assert(dev->phone >= 0); 698 743 dev->refcount--; 699 744 … … 743 788 744 789 device_t *dev = hash_table_get_instance(lnk, device_t, link); 790 assert(dev->phone >= 0); 745 791 746 792 /* Make a request at the driver */ 747 793 ipc_call_t answer; 748 aid_t msg = async_send_2(dev->phone, IPC_GET_ METHOD(*request),794 aid_t msg = async_send_2(dev->phone, IPC_GET_IMETHOD(*request), 749 795 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), &answer); 750 796 … … 752 798 753 799 /* Wait for reply from the driver */ 754 ipcarg_t rc;800 sysarg_t rc; 755 801 async_wait_for(msg, &rc); 756 802
Note:
See TracChangeset
for help on using the changeset viewer.