Changeset 79ae36dd in mainline for uspace/srv/fs
- Timestamp:
- 2011-06-08T19:01:55Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0eff68e
- Parents:
- 764d71e
- Location:
- uspace/srv/fs
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/devfs/devfs.c
r764d71e r79ae36dd 41 41 #include <stdio.h> 42 42 #include <ipc/services.h> 43 #include < ipc/ns.h>43 #include <ns.h> 44 44 #include <async.h> 45 45 #include <errno.h> … … 68 68 ipc_callid_t callid = async_get_call(&call); 69 69 70 switch (IPC_GET_IMETHOD(call)) { 71 case IPC_M_PHONE_HUNGUP: 70 if (!IPC_GET_IMETHOD(call)) 72 71 return; 72 73 switch (IPC_GET_IMETHOD(call)) { 73 74 case VFS_OUT_MOUNTED: 74 75 devfs_mounted(callid, &call); … … 119 120 int main(int argc, char *argv[]) 120 121 { 121 printf( NAME ": HelenOS Device Filesystem\n");122 printf("%s: HelenOS Device Filesystem\n", NAME); 122 123 123 124 if (!devfs_init()) { 124 printf( NAME ": failed to initialize devfs\n");125 printf("%s: failed to initialize devfs\n", NAME); 125 126 return -1; 126 127 } 127 128 128 int vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0); 129 if (vfs_phone < EOK) { 130 printf(NAME ": Unable to connect to VFS\n"); 129 async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE, 130 SERVICE_VFS, 0, 0); 131 if (!vfs_sess) { 132 printf("%s: Unable to connect to VFS\n", NAME); 131 133 return -1; 132 134 } 133 135 134 int rc = fs_register(vfs_ phone, &devfs_reg, &devfs_vfs_info,136 int rc = fs_register(vfs_sess, &devfs_reg, &devfs_vfs_info, 135 137 devfs_connection); 136 138 if (rc != EOK) { 137 printf( NAME ": Failed to register file system (%d)\n", rc);139 printf("%s: Failed to register file system (%d)\n", NAME, rc); 138 140 return rc; 139 141 } 140 142 141 printf( NAME ": Accepting connections\n");143 printf("%s: Accepting connections\n", NAME); 142 144 task_retval(0); 143 145 async_manager(); -
uspace/srv/fs/devfs/devfs_ops.c
r764d71e r79ae36dd 59 59 typedef struct { 60 60 devmap_handle_t handle; 61 int phone; /**< When < 0, the structure is incomplete. */61 async_sess_t *sess; /**< If NULL, the structure is incomplete. */ 62 62 size_t refcount; 63 63 link_t link; 64 fibril_condvar_t cv; 64 fibril_condvar_t cv; /**< Broadcast when completed. */ 65 65 } device_t; 66 66 … … 232 232 }; 233 233 link_t *lnk; 234 234 235 235 fibril_mutex_lock(&devices_mutex); 236 236 restart: … … 244 244 245 245 dev->handle = node->handle; 246 dev->phone = -1; /* mark as incomplete */ 246 247 /* Mark as incomplete */ 248 dev->sess = NULL; 247 249 dev->refcount = 1; 248 250 fibril_condvar_initialize(&dev->cv); 249 251 250 252 /* 251 253 * Insert the incomplete device structure so that other … … 254 256 */ 255 257 hash_table_insert(&devices, key, &dev->link); 256 258 257 259 /* 258 260 * Drop the mutex to allow recursive devfs requests. 259 261 */ 260 262 fibril_mutex_unlock(&devices_mutex); 261 262 int phone = devmap_device_connect(node->handle, 0); 263 263 264 async_sess_t *sess = devmap_device_connect(EXCHANGE_SERIALIZE, 265 node->handle, 0); 266 264 267 fibril_mutex_lock(&devices_mutex); 265 268 266 269 /* 267 270 * Notify possible waiters about this device structure … … 269 272 */ 270 273 fibril_condvar_broadcast(&dev->cv); 271 272 if ( phone < 0) {274 275 if (!sess) { 273 276 /* 274 277 * Connecting failed, need to remove the … … 277 280 hash_table_remove(&devices, key, DEVICES_KEYS); 278 281 fibril_mutex_unlock(&devices_mutex); 279 282 280 283 return ENOENT; 281 284 } 282 285 283 /* Set the correct phone. */284 dev-> phone = phone;286 /* Set the correct session. */ 287 dev->sess = sess; 285 288 } else { 286 289 device_t *dev = hash_table_get_instance(lnk, device_t, link); 287 288 if ( dev->phone < 0) {290 291 if (!dev->sess) { 289 292 /* 290 293 * Wait until the device structure is completed … … 608 611 609 612 device_t *dev = hash_table_get_instance(lnk, device_t, link); 610 assert(dev-> phone >= 0);613 assert(dev->sess); 611 614 612 615 ipc_callid_t callid; … … 619 622 620 623 /* Make a request at the driver */ 624 async_exch_t *exch = async_exchange_begin(dev->sess); 625 621 626 ipc_call_t answer; 622 aid_t msg = async_send_3( dev->phone, IPC_GET_IMETHOD(*request),627 aid_t msg = async_send_3(exch, IPC_GET_IMETHOD(*request), 623 628 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), 624 629 IPC_GET_ARG3(*request), &answer); 625 630 626 631 /* Forward the IPC_M_DATA_READ request to the driver */ 627 async_forward_fast(callid, dev->phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 632 async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 633 634 async_exchange_end(exch); 635 628 636 fibril_mutex_unlock(&devices_mutex); 629 637 … … 672 680 673 681 device_t *dev = hash_table_get_instance(lnk, device_t, link); 674 assert(dev-> phone >= 0);682 assert(dev->sess); 675 683 676 684 ipc_callid_t callid; … … 683 691 684 692 /* Make a request at the driver */ 693 async_exch_t *exch = async_exchange_begin(dev->sess); 694 685 695 ipc_call_t answer; 686 aid_t msg = async_send_3( dev->phone, IPC_GET_IMETHOD(*request),696 aid_t msg = async_send_3(exch, IPC_GET_IMETHOD(*request), 687 697 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), 688 698 IPC_GET_ARG3(*request), &answer); 689 699 690 700 /* Forward the IPC_M_DATA_WRITE request to the driver */ 691 async_forward_fast(callid, dev->phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 701 async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 702 703 async_exchange_end(exch); 692 704 693 705 fibril_mutex_unlock(&devices_mutex); … … 742 754 743 755 device_t *dev = hash_table_get_instance(lnk, device_t, link); 744 assert(dev-> phone >= 0);756 assert(dev->sess); 745 757 dev->refcount--; 746 758 747 759 if (dev->refcount == 0) { 748 async_hangup(dev-> phone);760 async_hangup(dev->sess); 749 761 hash_table_remove(&devices, key, DEVICES_KEYS); 750 762 } … … 790 802 791 803 device_t *dev = hash_table_get_instance(lnk, device_t, link); 792 assert(dev-> phone >= 0);804 assert(dev->sess); 793 805 794 806 /* Make a request at the driver */ 807 async_exch_t *exch = async_exchange_begin(dev->sess); 808 795 809 ipc_call_t answer; 796 aid_t msg = async_send_2( dev->phone, IPC_GET_IMETHOD(*request),810 aid_t msg = async_send_2(exch, IPC_GET_IMETHOD(*request), 797 811 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), &answer); 812 813 async_exchange_end(exch); 798 814 799 815 fibril_mutex_unlock(&devices_mutex); -
uspace/srv/fs/ext2fs/ext2fs.c
r764d71e r79ae36dd 40 40 #include "ext2fs.h" 41 41 #include <ipc/services.h> 42 #include < ipc/ns.h>42 #include <ns.h> 43 43 #include <async.h> 44 44 #include <errno.h> … … 87 87 88 88 dprintf(NAME ": connection opened\n"); 89 while (1) { 90 ipc_callid_t callid; 89 while (true) { 91 90 ipc_call_t call; 92 93 callid = async_get_call(&call); 94 switch (IPC_GET_IMETHOD(call)) { 95 case IPC_M_PHONE_HUNGUP: 91 ipc_callid_t callid = async_get_call(&call); 92 93 if (!IPC_GET_IMETHOD(call)) 96 94 return; 95 96 switch (IPC_GET_IMETHOD(call)) { 97 97 case VFS_OUT_MOUNTED: 98 98 ext2fs_mounted(callid, &call); … … 143 143 int main(int argc, char **argv) 144 144 { 145 int vfs_phone;146 int rc;147 148 145 printf(NAME ": HelenOS EXT2 file system server\n"); 149 150 vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0); 151 if (vfs_phone < EOK) { 146 147 async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE, 148 SERVICE_VFS, 0, 0); 149 if (!vfs_sess) { 152 150 printf(NAME ": failed to connect to VFS\n"); 153 151 return -1; 154 152 } 155 153 156 rc = ext2fs_global_init();154 int rc = ext2fs_global_init(); 157 155 if (rc != EOK) { 158 156 printf(NAME ": Failed global initialization\n"); … … 160 158 } 161 159 162 rc = fs_register(vfs_ phone, &ext2fs_reg, &ext2fs_vfs_info, ext2fs_connection);160 rc = fs_register(vfs_sess, &ext2fs_reg, &ext2fs_vfs_info, ext2fs_connection); 163 161 if (rc != EOK) { 164 162 fprintf(stdout, NAME ": Failed to register fs (%d)\n", rc); -
uspace/srv/fs/fat/fat.c
r764d71e r79ae36dd 39 39 #include "fat.h" 40 40 #include <ipc/services.h> 41 #include < ipc/ns.h>41 #include <ns.h> 42 42 #include <async.h> 43 43 #include <errno.h> … … 88 88 89 89 dprintf(NAME ": connection opened\n"); 90 while (1) {91 ipc_callid_t callid;90 91 while (true) { 92 92 ipc_call_t call; 93 94 callid = async_get_call(&call); 95 switch (IPC_GET_IMETHOD(call)) { 96 case IPC_M_PHONE_HUNGUP: 93 ipc_callid_t callid = async_get_call(&call); 94 95 if (!IPC_GET_IMETHOD(call)) 97 96 return; 97 98 switch (IPC_GET_IMETHOD(call)) { 98 99 case VFS_OUT_MOUNTED: 99 100 fat_mounted(callid, &call); … … 144 145 int main(int argc, char **argv) 145 146 { 146 int vfs_phone;147 int rc;148 149 147 printf(NAME ": HelenOS FAT file system server\n"); 150 151 rc = fat_idx_init();148 149 int rc = fat_idx_init(); 152 150 if (rc != EOK) 153 151 goto err; 154 155 vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0); 156 if (vfs_phone < EOK) { 152 153 async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE, 154 SERVICE_VFS, 0, 0); 155 if (!vfs_sess) { 157 156 printf(NAME ": failed to connect to VFS\n"); 158 157 return -1; 159 158 } 160 159 161 rc = fs_register(vfs_ phone, &fat_reg, &fat_vfs_info, fat_connection);160 rc = fs_register(vfs_sess, &fat_reg, &fat_vfs_info, fat_connection); 162 161 if (rc != EOK) { 163 162 fat_idx_fini(); … … 168 167 task_retval(0); 169 168 async_manager(); 170 /* not reached */ 169 170 /* Not reached */ 171 171 return 0; 172 172 173 173 err: 174 174 printf(NAME ": Failed to register file system (%d)\n", rc); … … 178 178 /** 179 179 * @} 180 */ 180 */ -
uspace/srv/fs/fat/fat_ops.c
r764d71e r79ae36dd 970 970 971 971 /* initialize libblock */ 972 rc = block_init( devmap_handle, BS_SIZE);972 rc = block_init(EXCHANGE_SERIALIZE, devmap_handle, BS_SIZE); 973 973 if (rc != EOK) { 974 974 async_answer_0(rid, rc); -
uspace/srv/fs/tmpfs/tmpfs.c
r764d71e r79ae36dd 30 30 /** @addtogroup fs 31 31 * @{ 32 */ 32 */ 33 33 34 34 /** … … 43 43 #include "tmpfs.h" 44 44 #include <ipc/services.h> 45 #include < ipc/ns.h>45 #include <ns.h> 46 46 #include <async.h> 47 47 #include <errno.h> … … 94 94 95 95 dprintf(NAME ": connection opened\n"); 96 while (1) {97 ipc_callid_t callid;96 97 while (true) { 98 98 ipc_call_t call; 99 100 callid = async_get_call(&call); 101 switch (IPC_GET_IMETHOD(call)) { 102 case IPC_M_PHONE_HUNGUP: 99 ipc_callid_t callid = async_get_call(&call); 100 101 if (!IPC_GET_IMETHOD(call)) 103 102 return; 103 104 switch (IPC_GET_IMETHOD(call)) { 104 105 case VFS_OUT_MOUNTED: 105 106 tmpfs_mounted(callid, &call); … … 151 152 { 152 153 printf(NAME ": HelenOS TMPFS file system server\n"); 153 154 154 155 if (!tmpfs_init()) { 155 156 printf(NAME ": failed to initialize TMPFS\n"); 156 157 return -1; 157 158 } 158 159 int vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0); 160 if (vfs_phone < EOK) { 159 160 async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE, 161 SERVICE_VFS, 0, 0); 162 if (!vfs_sess) { 161 163 printf(NAME ": Unable to connect to VFS\n"); 162 164 return -1; 163 165 } 164 165 int rc = fs_register(vfs_ phone, &tmpfs_reg, &tmpfs_vfs_info,166 167 int rc = fs_register(vfs_sess, &tmpfs_reg, &tmpfs_vfs_info, 166 168 tmpfs_connection); 167 169 if (rc != EOK) { … … 169 171 return rc; 170 172 } 171 173 172 174 printf(NAME ": Accepting connections\n"); 173 175 task_retval(0); 174 176 async_manager(); 175 /* not reached */ 177 178 /* Not reached */ 176 179 return 0; 177 180 } … … 179 182 /** 180 183 * @} 181 */ 184 */ -
uspace/srv/fs/tmpfs/tmpfs_dump.c
r764d71e r79ae36dd 167 167 int rc; 168 168 169 rc = block_init( dev, TMPFS_COMM_SIZE);169 rc = block_init(EXCHANGE_SERIALIZE, dev, TMPFS_COMM_SIZE); 170 170 if (rc != EOK) 171 171 return false;
Note:
See TracChangeset
for help on using the changeset viewer.