Ignore:
File:
1 edited

Legend:

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

    r27b76ca r286286c  
    5454
    5555/* Forward declarations of static functions. */
    56 static int vfs_truncate_internal(fs_handle_t, devmap_handle_t, fs_index_t,
     56static int vfs_truncate_internal(fs_handle_t, service_id_t, fs_index_t,
    5757    aoff64_t);
    5858
     
    6565vfs_pair_t rootfs = {
    6666        .fs_handle = 0,
    67         .devmap_handle = 0
     67        .service_id = 0
    6868};
    6969
    70 static void vfs_mount_internal(ipc_callid_t rid, devmap_handle_t devmap_handle,
     70static void vfs_mount_internal(ipc_callid_t rid, service_id_t service_id,
    7171    fs_handle_t fs_handle, char *mp, char *opts)
    7272{
     
    125125                        exch = vfs_exchange_grab(fs_handle);
    126126                        msg = async_send_1(exch, VFS_OUT_MOUNTED,
    127                             (sysarg_t) devmap_handle, &answer);
     127                            (sysarg_t) service_id, &answer);
    128128                        /* Send the mount options */
    129129                        rc = async_data_write_start(exch, (void *)opts,
     
    146146
    147147                        rindex = (fs_index_t) IPC_GET_ARG1(answer);
    148                         rsize = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(answer), IPC_GET_ARG3(answer));
     148                        rsize = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(answer),
     149                            IPC_GET_ARG3(answer));
    149150                        rlnkcnt = (unsigned) IPC_GET_ARG4(answer);
    150151                       
    151152                        mr_res.triplet.fs_handle = fs_handle;
    152                         mr_res.triplet.devmap_handle = devmap_handle;
     153                        mr_res.triplet.service_id = service_id;
    153154                        mr_res.triplet.index = rindex;
    154155                        mr_res.size = rsize;
     
    157158                       
    158159                        rootfs.fs_handle = fs_handle;
    159                         rootfs.devmap_handle = devmap_handle;
     160                        rootfs.service_id = service_id;
    160161                       
    161162                        /* Add reference to the mounted root. */
     
    178179       
    179180        /*
    180          * At this point, we have all necessary pieces: file system and device
    181          * handles, and we know the mount point VFS node.
     181         * At this point, we have all necessary pieces: file system handle
     182         * and service ID, and we know the mount point VFS node.
    182183         */
    183184       
     
    187188        exch = vfs_exchange_grab(mp_res.triplet.fs_handle);
    188189        msg = async_send_4(exch, VFS_OUT_MOUNT,
    189             (sysarg_t) mp_res.triplet.devmap_handle,
     190            (sysarg_t) mp_res.triplet.service_id,
    190191            (sysarg_t) mp_res.triplet.index,
    191192            (sysarg_t) fs_handle,
    192             (sysarg_t) devmap_handle, &answer);
     193            (sysarg_t) service_id, &answer);
    193194       
    194195        /* Send connection */
     
    224225        }
    225226       
     227        /*
     228         * Wait for the answer before releasing the exchange to avoid deadlock
     229         * in case the answer depends on further calls to the same file system.
     230         * Think of a case when mounting a FS on a file_bd backed by a file on
     231         * the same FS.
     232         */
     233        async_wait_for(msg, &rc);
    226234        vfs_exchange_release(exch);
    227         async_wait_for(msg, &rc);
    228235       
    229236        if (rc == EOK) {
     
    234241               
    235242                mr_res.triplet.fs_handle = fs_handle;
    236                 mr_res.triplet.devmap_handle = devmap_handle;
     243                mr_res.triplet.service_id = service_id;
    237244                mr_res.triplet.index = rindex;
    238245                mr_res.size = rsize;
     
    255262void vfs_mount(ipc_callid_t rid, ipc_call_t *request)
    256263{
    257         devmap_handle_t devmap_handle;
     264        service_id_t service_id;
    258265
    259266        /*
     
    262269         * in the request.
    263270         */
    264         devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
     271        service_id = (service_id_t) IPC_GET_ARG1(*request);
    265272       
    266273        /*
     
    270277       
    271278        /*
    272          * For now, don't make use of ARG3, but it can be used to
    273          * carry mount options in the future.
    274          */
    275        
     279         * Instance number is passed as ARG3.
     280         */
     281        unsigned int instance = IPC_GET_ARG3(*request);
     282
    276283        /* We want the client to send us the mount point. */
    277284        char *mp;
     
    329336        fs_handle_t fs_handle;
    330337recheck:
    331         fs_handle = fs_name_to_handle(fs_name, false);
     338        fs_handle = fs_name_to_handle(instance, fs_name, false);
    332339        if (!fs_handle) {
    333340                if (flags & IPC_FLAG_BLOCKING) {
     
    350357       
    351358        /* Do the mount */
    352         vfs_mount_internal(rid, devmap_handle, fs_handle, mp, opts);
     359        vfs_mount_internal(rid, service_id, fs_handle, mp, opts);
    353360        free(mp);
    354361        free(fs_name);
     
    409416         */
    410417        if (vfs_nodes_refcount_sum_get(mr_node->fs_handle,
    411             mr_node->devmap_handle) != 2) {
     418            mr_node->service_id) != 2) {
    412419                fibril_rwlock_write_unlock(&namespace_rwlock);
    413420                vfs_node_put(mr_node);
     
    430437                exch = vfs_exchange_grab(mr_node->fs_handle);
    431438                rc = async_req_1_0(exch, VFS_OUT_UNMOUNTED,
    432                     mr_node->devmap_handle);
     439                    mr_node->service_id);
    433440                vfs_exchange_release(exch);
    434441               
     
    441448               
    442449                rootfs.fs_handle = 0;
    443                 rootfs.devmap_handle = 0;
     450                rootfs.service_id = 0;
    444451        } else {
    445452               
     
    470477                exch = vfs_exchange_grab(mp_node->fs_handle);
    471478                rc = async_req_2_0(exch, VFS_OUT_UNMOUNT,
    472                     mp_node->devmap_handle, mp_node->index);
     479                    mp_node->service_id, mp_node->index);
    473480                vfs_exchange_release(exch);
    474481               
     
    575582                if (node->size) {
    576583                        rc = vfs_truncate_internal(node->fs_handle,
    577                             node->devmap_handle, node->index, 0);
     584                            node->service_id, node->index, 0);
    578585                        if (rc) {
    579586                                fibril_rwlock_write_unlock(&node->contents_rwlock);
     
    639646        aid_t msg;
    640647        ipc_call_t answer;
    641         msg = async_send_2(fs_exch, VFS_OUT_SYNC, file->node->devmap_handle,
     648        msg = async_send_2(fs_exch, VFS_OUT_SYNC, file->node->service_id,
    642649            file->node->index, &answer);
    643650       
     
    724731        if (read) {
    725732                rc = async_data_read_forward_4_1(fs_exch, VFS_OUT_READ,
    726                     file->node->devmap_handle, file->node->index,
     733                    file->node->service_id, file->node->index,
    727734                    LOWER32(file->pos), UPPER32(file->pos), &answer);
    728735        } else {
     
    731738               
    732739                rc = async_data_write_forward_4_1(fs_exch, VFS_OUT_WRITE,
    733                     file->node->devmap_handle, file->node->index,
     740                    file->node->service_id, file->node->index,
    734741                    LOWER32(file->pos), UPPER32(file->pos), &answer);
    735742        }
     
    862869}
    863870
    864 int vfs_truncate_internal(fs_handle_t fs_handle, devmap_handle_t devmap_handle,
     871int vfs_truncate_internal(fs_handle_t fs_handle, service_id_t service_id,
    865872    fs_index_t index, aoff64_t size)
    866873{
    867874        async_exch_t *exch = vfs_exchange_grab(fs_handle);
    868875        sysarg_t rc = async_req_4_0(exch, VFS_OUT_TRUNCATE,
    869             (sysarg_t) devmap_handle, (sysarg_t) index, LOWER32(size),
     876            (sysarg_t) service_id, (sysarg_t) index, LOWER32(size),
    870877            UPPER32(size));
    871878        vfs_exchange_release(exch);
     
    890897        fibril_rwlock_write_lock(&file->node->contents_rwlock);
    891898        rc = vfs_truncate_internal(file->node->fs_handle,
    892             file->node->devmap_handle, file->node->index, size);
     899            file->node->service_id, file->node->index, size);
    893900        if (rc == EOK)
    894901                file->node->size = size;
     
    924931       
    925932        aid_t msg;
    926         msg = async_send_3(exch, VFS_OUT_STAT, file->node->devmap_handle,
     933        msg = async_send_3(exch, VFS_OUT_STAT, file->node->service_id,
    927934            file->node->index, true, NULL);
    928935        async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     
    977984       
    978985        aid_t msg;
    979         msg = async_send_3(exch, VFS_OUT_STAT, node->devmap_handle,
     986        msg = async_send_3(exch, VFS_OUT_STAT, node->service_id,
    980987            node->index, false, NULL);
    981988        async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     
    11541161        /* Check whether linking to the same file system instance. */
    11551162        if ((old_node->fs_handle != new_par_lr.triplet.fs_handle) ||
    1156             (old_node->devmap_handle != new_par_lr.triplet.devmap_handle)) {
     1163            (old_node->service_id != new_par_lr.triplet.service_id)) {
    11571164                fibril_rwlock_write_unlock(&namespace_rwlock);
    11581165                vfs_node_put(old_node);
Note: See TracChangeset for help on using the changeset viewer.