Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset ccfbf71 in mainline


Ignore:
Timestamp:
2011-08-03T18:58:50Z (10 years ago)
Author:
Oleg Romanenko <romanenko.oleg@…>
Branches:
lfn, master
Children:
e97b8c6
Parents:
f1119e5
Message:

Migrate mainline changes to exfat.c

File:
1 edited

Legend:

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

    rf1119e5 rccfbf71  
    4040#include "exfat.h"
    4141#include <ipc/services.h>
    42 #include <ipc/ns.h>
     42#include <ns.h>
    4343#include <async.h>
    4444#include <errno.h>
     
    5757};
    5858
    59 fs_reg_t exfat_reg;
    60 
    61 /**
    62  * This connection fibril processes VFS requests from VFS.
    63  *
    64  * In order to support simultaneous VFS requests, our design is as follows.
    65  * The connection fibril accepts VFS requests from VFS. If there is only one
    66  * instance of the fibril, VFS will need to serialize all VFS requests it sends
    67  * to FAT. To overcome this bottleneck, VFS can send exFAT the IPC_M_CONNECT_ME_TO
    68  * call. In that case, a new connection fibril will be created, which in turn
    69  * will accept the call. Thus, a new phone will be opened for VFS.
    70  *
    71  * There are few issues with this arrangement. First, VFS can run out of
    72  * available phones. In that case, VFS can close some other phones or use one
    73  * phone for more serialized requests. Similarily, exFAT can refuse to duplicate
    74  * the connection. VFS should then just make use of already existing phones and
    75  * route its requests through them. To avoid paying the fibril creation price
    76  * upon each request, exFAT might want to keep the connections open after the
    77  * request has been completed.
    78  */
    79 static void exfat_connection(ipc_callid_t iid, ipc_call_t *icall)
    80 {
    81         if (iid) {
    82                 /*
    83                  * This only happens for connections opened by
    84                  * IPC_M_CONNECT_ME_TO calls as opposed to callback connections
    85                  * created by IPC_M_CONNECT_TO_ME.
    86                  */
    87                 async_answer_0(iid, EOK);
    88         }
    89        
    90         dprintf(NAME ": connection opened\n");
    91         while (1) {
    92                 ipc_callid_t callid;
    93                 ipc_call_t call;
    94        
    95                 callid = async_get_call(&call);
    96                 switch  (IPC_GET_IMETHOD(call)) {
    97                 case IPC_M_PHONE_HUNGUP:
    98                         return;
    99                 case VFS_OUT_MOUNTED:
    100                         exfat_mounted(callid, &call);
    101                         break;
    102                 case VFS_OUT_MOUNT:
    103                         exfat_mount(callid, &call);
    104                         break;
    105                 case VFS_OUT_UNMOUNTED:
    106                         exfat_unmounted(callid, &call);
    107                         break;
    108                 case VFS_OUT_UNMOUNT:
    109                         exfat_unmount(callid, &call);
    110                         break;
    111                 case VFS_OUT_LOOKUP:
    112                         exfat_lookup(callid, &call);
    113                         break;
    114                 case VFS_OUT_READ:
    115                         exfat_read(callid, &call);
    116                         break;
    117                 case VFS_OUT_WRITE:
    118                         /* exfat_write(callid, &call); */
    119                         async_answer_0(callid, ENOTSUP);
    120                         break;
    121                 case VFS_OUT_TRUNCATE:
    122                         /* exfat_truncate(callid, &call); */
    123                         async_answer_0(callid, ENOTSUP);
    124                         break;
    125                 case VFS_OUT_STAT:
    126                         exfat_stat(callid, &call);
    127                         break;
    128                 case VFS_OUT_CLOSE:
    129                         exfat_close(callid, &call);
    130                         break;
    131                 case VFS_OUT_DESTROY:
    132                         /* exfat_destroy(callid, &call); */
    133                         async_answer_0(callid, ENOTSUP);
    134                         break;
    135                 case VFS_OUT_OPEN_NODE:
    136                         exfat_open_node(callid, &call);
    137                         break;
    138                 case VFS_OUT_SYNC:
    139                         exfat_sync(callid, &call);
    140                         break;
    141                 default:
    142                         async_answer_0(callid, ENOTSUP);
    143                         break;
    144                 }
    145         }
    146 }
    147 
    14859int main(int argc, char **argv)
    14960{
    150         int vfs_phone;
    151         int rc;
    152 
    15361        printf(NAME ": HelenOS exFAT file system server\n");
    15462
    155         rc = exfat_idx_init();
     63        int rc = exfat_idx_init();
    15664        if (rc != EOK)
    15765                goto err;
    15866
    159         vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0);
    160         if (vfs_phone < EOK) {
     67        async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
     68            SERVICE_VFS, 0, 0);
     69        if (!vfs_sess) {
    16170                printf(NAME ": failed to connect to VFS\n");
    16271                return -1;
    16372        }
    16473       
    165         rc = fs_register(vfs_phone, &exfat_reg, &exfat_vfs_info, exfat_connection);
     74        rc = fs_register(vfs_sess, &exfat_vfs_info, &exfat_ops, &exfat_libfs_ops);
    16675        if (rc != EOK) {
    16776                exfat_idx_fini();
     
    17281        task_retval(0);
    17382        async_manager();
     83
    17484        /* not reached */
    17585        return 0;
     
    18393/**
    18494 * @}
    185  */ 
     95 */
Note: See TracChangeset for help on using the changeset viewer.