Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/tmpfs/tmpfs.c

    refcebe1 r9934f7d  
    6161};
    6262
     63fs_reg_t tmpfs_reg;
     64
     65/**
     66 * This connection fibril processes VFS requests from VFS.
     67 *
     68 * In order to support simultaneous VFS requests, our design is as follows.
     69 * The connection fibril accepts VFS requests from VFS. If there is only one
     70 * instance of the fibril, VFS will need to serialize all VFS requests it sends
     71 * to FAT. To overcome this bottleneck, VFS can send TMPFS the
     72 * IPC_M_CONNECT_ME_TO call. In that case, a new connection fibril will be
     73 * created, which in turn will accept the call. Thus, a new phone will be
     74 * opened for VFS.
     75 *
     76 * There are few issues with this arrangement. First, VFS can run out of
     77 * available phones. In that case, VFS can close some other phones or use one
     78 * phone for more serialized requests. Similarily, TMPFS can refuse to duplicate
     79 * the connection. VFS should then just make use of already existing phones and
     80 * route its requests through them. To avoid paying the fibril creation price
     81 * upon each request, TMPFS might want to keep the connections open after the
     82 * request has been completed.
     83 */
     84static void tmpfs_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     85{
     86        if (iid) {
     87                /*
     88                 * This only happens for connections opened by
     89                 * IPC_M_CONNECT_ME_TO calls as opposed to callback connections
     90                 * created by IPC_M_CONNECT_TO_ME.
     91                 */
     92                async_answer_0(iid, EOK);
     93        }
     94       
     95        dprintf(NAME ": connection opened\n");
     96       
     97        while (true) {
     98                ipc_call_t call;
     99                ipc_callid_t callid = async_get_call(&call);
     100               
     101                if (!IPC_GET_IMETHOD(call))
     102                        return;
     103               
     104                switch (IPC_GET_IMETHOD(call)) {
     105                case VFS_OUT_MOUNTED:
     106                        tmpfs_mounted(callid, &call);
     107                        break;
     108                case VFS_OUT_MOUNT:
     109                        tmpfs_mount(callid, &call);
     110                        break;
     111                case VFS_OUT_UNMOUNTED:
     112                        tmpfs_unmounted(callid, &call);
     113                        break;
     114                case VFS_OUT_UNMOUNT:
     115                        tmpfs_unmount(callid, &call);
     116                        break;
     117                case VFS_OUT_LOOKUP:
     118                        tmpfs_lookup(callid, &call);
     119                        break;
     120                case VFS_OUT_READ:
     121                        tmpfs_read(callid, &call);
     122                        break;
     123                case VFS_OUT_WRITE:
     124                        tmpfs_write(callid, &call);
     125                        break;
     126                case VFS_OUT_TRUNCATE:
     127                        tmpfs_truncate(callid, &call);
     128                        break;
     129                case VFS_OUT_CLOSE:
     130                        tmpfs_close(callid, &call);
     131                        break;
     132                case VFS_OUT_DESTROY:
     133                        tmpfs_destroy(callid, &call);
     134                        break;
     135                case VFS_OUT_OPEN_NODE:
     136                        tmpfs_open_node(callid, &call);
     137                        break;
     138                case VFS_OUT_STAT:
     139                        tmpfs_stat(callid, &call);
     140                        break;
     141                case VFS_OUT_SYNC:
     142                        tmpfs_sync(callid, &call);
     143                        break;
     144                default:
     145                        async_answer_0(callid, ENOTSUP);
     146                        break;
     147                }
     148        }
     149}
     150
    63151int main(int argc, char **argv)
    64152{
     
    77165        }
    78166       
    79         int rc = fs_register(vfs_sess, &tmpfs_vfs_info, &tmpfs_ops,
    80             &tmpfs_libfs_ops);
     167        int rc = fs_register(vfs_sess, &tmpfs_reg, &tmpfs_vfs_info,
     168            tmpfs_connection);
    81169        if (rc != EOK) {
    82170                printf(NAME ": Failed to register file system (%d)\n", rc);
Note: See TracChangeset for help on using the changeset viewer.