Ignore:
File:
1 edited

Legend:

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

    rffa2c8ef r4979403  
    22 * Copyright (c) 2006 Martin Decky
    33 * Copyright (c) 2008 Jakub Jermar
     4 * Copyright (c) 2011 Oleg Romanenko
    45 * All rights reserved.
    56 *
     
    3940#include "fat.h"
    4041#include <ipc/services.h>
    41 #include <ipc/ns.h>
     42#include <ns.h>
    4243#include <async.h>
    4344#include <errno.h>
     
    5354        .name = NAME,
    5455        .concurrent_read_write = false,
    55         .write_retains_size = false,   
     56        .write_retains_size = false,
     57        .instance = 0,
    5658};
    57 
    58 fs_reg_t fat_reg;
    59 
    60 /**
    61  * This connection fibril processes VFS requests from VFS.
    62  *
    63  * In order to support simultaneous VFS requests, our design is as follows.
    64  * The connection fibril accepts VFS requests from VFS. If there is only one
    65  * instance of the fibril, VFS will need to serialize all VFS requests it sends
    66  * to FAT. To overcome this bottleneck, VFS can send FAT the IPC_M_CONNECT_ME_TO
    67  * call. In that case, a new connection fibril will be created, which in turn
    68  * will accept the call. Thus, a new phone will be opened for VFS.
    69  *
    70  * There are few issues with this arrangement. First, VFS can run out of
    71  * available phones. In that case, VFS can close some other phones or use one
    72  * phone for more serialized requests. Similarily, FAT can refuse to duplicate
    73  * the connection. VFS should then just make use of already existing phones and
    74  * route its requests through them. To avoid paying the fibril creation price
    75  * upon each request, FAT might want to keep the connections open after the
    76  * request has been completed.
    77  */
    78 static void fat_connection(ipc_callid_t iid, ipc_call_t *icall)
    79 {
    80         if (iid) {
    81                 /*
    82                  * This only happens for connections opened by
    83                  * IPC_M_CONNECT_ME_TO calls as opposed to callback connections
    84                  * created by IPC_M_CONNECT_TO_ME.
    85                  */
    86                 async_answer_0(iid, EOK);
    87         }
    88        
    89         dprintf(NAME ": connection opened\n");
    90         while (1) {
    91                 ipc_callid_t callid;
    92                 ipc_call_t call;
    93        
    94                 callid = async_get_call(&call);
    95                 switch  (IPC_GET_IMETHOD(call)) {
    96                 case IPC_M_PHONE_HUNGUP:
    97                         return;
    98                 case VFS_OUT_MOUNTED:
    99                         fat_mounted(callid, &call);
    100                         break;
    101                 case VFS_OUT_MOUNT:
    102                         fat_mount(callid, &call);
    103                         break;
    104                 case VFS_OUT_UNMOUNTED:
    105                         fat_unmounted(callid, &call);
    106                         break;
    107                 case VFS_OUT_UNMOUNT:
    108                         fat_unmount(callid, &call);
    109                         break;
    110                 case VFS_OUT_LOOKUP:
    111                         fat_lookup(callid, &call);
    112                         break;
    113                 case VFS_OUT_READ:
    114                         fat_read(callid, &call);
    115                         break;
    116                 case VFS_OUT_WRITE:
    117                         fat_write(callid, &call);
    118                         break;
    119                 case VFS_OUT_TRUNCATE:
    120                         fat_truncate(callid, &call);
    121                         break;
    122                 case VFS_OUT_STAT:
    123                         fat_stat(callid, &call);
    124                         break;
    125                 case VFS_OUT_CLOSE:
    126                         fat_close(callid, &call);
    127                         break;
    128                 case VFS_OUT_DESTROY:
    129                         fat_destroy(callid, &call);
    130                         break;
    131                 case VFS_OUT_OPEN_NODE:
    132                         fat_open_node(callid, &call);
    133                         break;
    134                 case VFS_OUT_SYNC:
    135                         fat_sync(callid, &call);
    136                         break;
    137                 default:
    138                         async_answer_0(callid, ENOTSUP);
    139                         break;
    140                 }
    141         }
    142 }
    14359
    14460int main(int argc, char **argv)
    14561{
    146         int vfs_phone;
    147         int rc;
     62        printf(NAME ": HelenOS FAT file system server\n");
     63       
     64        if (argc == 3) {
     65                if (!str_cmp(argv[1], "--instance"))
     66                        fat_vfs_info.instance = strtol(argv[2], NULL, 10);
     67                else {
     68                        printf(NAME " Unrecognized parameters");
     69                        return -1;
     70                }
     71        }
    14872
    149         printf(NAME ": HelenOS FAT file system server\n");
    150 
    151         rc = fat_idx_init();
     73        int rc = fat_idx_init();
    15274        if (rc != EOK)
    15375                goto err;
    154 
    155         vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0);
    156         if (vfs_phone < EOK) {
     76       
     77        async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
     78            SERVICE_VFS, 0, 0);
     79        if (!vfs_sess) {
    15780                printf(NAME ": failed to connect to VFS\n");
    15881                return -1;
    15982        }
    16083       
    161         rc = fs_register(vfs_phone, &fat_reg, &fat_vfs_info, fat_connection);
     84        rc = fs_register(vfs_sess, &fat_vfs_info, &fat_ops, &fat_libfs_ops);
    16285        if (rc != EOK) {
    16386                fat_idx_fini();
     
    16891        task_retval(0);
    16992        async_manager();
    170         /* not reached */
     93       
     94        /* Not reached */
    17195        return 0;
    172 
     96       
    17397err:
    17498        printf(NAME ": Failed to register file system (%d)\n", rc);
     
    178102/**
    179103 * @}
    180  */ 
     104 */
Note: See TracChangeset for help on using the changeset viewer.