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

Changeset 827d73f in mainline for uspace/srv/vfs/vfs_register.c


Ignore:
Timestamp:
2010-02-12T14:09:22Z (12 years ago)
Author:
Lukas Mejdrech <lukasmejdrech@…>
Branches:
lfn, master
Children:
a70bda4
Parents:
918e9910 (diff), e70edd1 (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.
Message:

Merged the actual head

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs_register.c

    r918e9910 r827d73f  
    110110void vfs_register(ipc_callid_t rid, ipc_call_t *request)
    111111{
    112         ipc_callid_t callid;
    113         ipc_call_t call;
    114         int rc;
    115         size_t size;
    116 
    117112        dprintf("Processing VFS_REGISTER request received from %p.\n",
    118113            request->in_phone_hash);
    119 
    120         /*
    121          * The first call has to be IPC_M_DATA_SEND in which we receive the
    122          * VFS info structure from the client FS.
    123          */
    124         if (!async_data_write_receive(&callid, &size)) {
    125                 /*
    126                  * The client doesn't obey the same protocol as we do.
    127                  */
    128                 dprintf("Receiving of VFS info failed.\n");
    129                 ipc_answer_0(callid, EINVAL);
    130                 ipc_answer_0(rid, EINVAL);
    131                 return;
    132         }
    133        
    134         dprintf("VFS info received, size = %d\n", size);
    135        
    136         /*
    137          * We know the size of the VFS info structure. See if the client
    138          * understands this easy concept too.
    139          */
    140         if (size != sizeof(vfs_info_t)) {
    141                 /*
    142                  * The client is sending us something, which cannot be
    143                  * the info structure.
    144                  */
    145                 dprintf("Received VFS info has bad size.\n");
    146                 ipc_answer_0(callid, EINVAL);
    147                 ipc_answer_0(rid, EINVAL);
    148                 return;
    149         }
    150 
    151         /*
    152          * Allocate and initialize a buffer for the fs_info structure.
    153          */
    154         fs_info_t *fs_info;
    155         fs_info = (fs_info_t *) malloc(sizeof(fs_info_t));
    156         if (!fs_info) {
    157                 dprintf("Could not allocate memory for FS info.\n");
    158                 ipc_answer_0(callid, ENOMEM);
    159                 ipc_answer_0(rid, ENOMEM);
    160                 return;
    161         }
    162         link_initialize(&fs_info->fs_link);
    163         fibril_mutex_initialize(&fs_info->phone_lock);
    164                
    165         rc = async_data_write_finalize(callid, &fs_info->vfs_info, size);
     114       
     115        vfs_info_t *vfs_info;
     116        int rc = async_data_write_accept((void **) &vfs_info, false,
     117            sizeof(vfs_info_t), sizeof(vfs_info_t), 0, NULL);
     118       
    166119        if (rc != EOK) {
    167120                dprintf("Failed to deliver the VFS info into our AS, rc=%d.\n",
    168121                    rc);
    169                 free(fs_info);
    170                 ipc_answer_0(callid, rc);
    171122                ipc_answer_0(rid, rc);
    172123                return;
    173124        }
    174 
     125       
     126        /*
     127         * Allocate and initialize a buffer for the fs_info structure.
     128         */
     129        fs_info_t *fs_info = (fs_info_t *) malloc(sizeof(fs_info_t));
     130        if (!fs_info) {
     131                dprintf("Could not allocate memory for FS info.\n");
     132                ipc_answer_0(rid, ENOMEM);
     133                return;
     134        }
     135       
     136        link_initialize(&fs_info->fs_link);
     137        fibril_mutex_initialize(&fs_info->phone_lock);
     138        fs_info->vfs_info = *vfs_info;
     139        free(vfs_info);
     140       
    175141        dprintf("VFS info delivered.\n");
    176                
     142       
    177143        if (!vfs_info_sane(&fs_info->vfs_info)) {
    178144                free(fs_info);
    179                 ipc_answer_0(callid, EINVAL);
    180145                ipc_answer_0(rid, EINVAL);
    181146                return;
    182147        }
    183                
     148       
    184149        fibril_mutex_lock(&fs_head_lock);
    185 
     150       
    186151        /*
    187152         * Check for duplicit registrations.
     
    194159                fibril_mutex_unlock(&fs_head_lock);
    195160                free(fs_info);
    196                 ipc_answer_0(callid, EEXISTS);
    197161                ipc_answer_0(rid, EEXISTS);
    198162                return;
    199163        }
    200 
     164       
    201165        /*
    202166         * Add fs_info to the list of registered FS's.
     
    210174         * which to forward VFS requests to it.
    211175         */
    212         callid = async_get_call(&call);
     176        ipc_call_t call;
     177        ipc_callid_t callid = async_get_call(&call);
    213178        if (IPC_GET_METHOD(call) != IPC_M_CONNECT_TO_ME) {
    214179                dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call));
     
    222187        fs_info->phone = IPC_GET_ARG5(call);
    223188        ipc_answer_0(callid, EOK);
    224 
     189       
    225190        dprintf("Callback connection to FS created.\n");
    226 
     191       
    227192        /*
    228193         * The client will want us to send him the address space area with PLB.
    229194         */
    230 
     195       
     196        size_t size;
    231197        if (!async_share_in_receive(&callid, &size)) {
    232198                dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call));
     
    253219                return;
    254220        }
    255 
     221       
    256222        /*
    257223         * Commit to read-only sharing the PLB with the client.
     
    259225        (void) async_share_in_finalize(callid, plb,
    260226            AS_AREA_READ | AS_AREA_CACHEABLE);
    261 
     227       
    262228        dprintf("Sharing PLB.\n");
    263 
     229       
    264230        /*
    265231         * That was it. The FS has been registered.
Note: See TracChangeset for help on using the changeset viewer.