Ignore:
File:
1 edited

Legend:

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

    rffa2c8ef r27b76ca  
    7676        vfs_node_t *mr_node;
    7777        fs_index_t rindex;
    78         size_t rsize;
     78        aoff64_t rsize;
    7979        unsigned rlnkcnt;
     80        async_exch_t *exch;
    8081        sysarg_t rc;
    81         int phone;
    8282        aid_t msg;
    8383        ipc_call_t answer;
     
    123123                       
    124124                        /* Tell the mountee that it is being mounted. */
    125                         phone = vfs_grab_phone(fs_handle);
    126                         msg = async_send_1(phone, VFS_OUT_MOUNTED,
     125                        exch = vfs_exchange_grab(fs_handle);
     126                        msg = async_send_1(exch, VFS_OUT_MOUNTED,
    127127                            (sysarg_t) devmap_handle, &answer);
    128                         /* send the mount options */
    129                         rc = async_data_write_start(phone, (void *)opts,
     128                        /* Send the mount options */
     129                        rc = async_data_write_start(exch, (void *)opts,
    130130                            str_size(opts));
     131                        vfs_exchange_release(exch);
     132                       
    131133                        if (rc != EOK) {
    132134                                async_wait_for(msg, NULL);
    133                                 vfs_release_phone(fs_handle, phone);
    134135                                fibril_rwlock_write_unlock(&namespace_rwlock);
    135136                                async_answer_0(rid, rc);
     
    137138                        }
    138139                        async_wait_for(msg, &rc);
    139                         vfs_release_phone(fs_handle, phone);
    140140                       
    141141                        if (rc != EOK) {
     
    146146
    147147                        rindex = (fs_index_t) IPC_GET_ARG1(answer);
    148                         rsize = (size_t) IPC_GET_ARG2(answer);
    149                         rlnkcnt = (unsigned) IPC_GET_ARG3(answer);
     148                        rsize = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(answer), IPC_GET_ARG3(answer));
     149                        rlnkcnt = (unsigned) IPC_GET_ARG4(answer);
    150150                       
    151151                        mr_res.triplet.fs_handle = fs_handle;
     
    182182         */
    183183       
    184         int mountee_phone = vfs_grab_phone(fs_handle);
    185         assert(mountee_phone >= 0);
    186 
    187         phone = vfs_grab_phone(mp_res.triplet.fs_handle);
    188         msg = async_send_4(phone, VFS_OUT_MOUNT,
     184        async_exch_t *mountee_exch = vfs_exchange_grab(fs_handle);
     185        assert(mountee_exch);
     186       
     187        exch = vfs_exchange_grab(mp_res.triplet.fs_handle);
     188        msg = async_send_4(exch, VFS_OUT_MOUNT,
    189189            (sysarg_t) mp_res.triplet.devmap_handle,
    190190            (sysarg_t) mp_res.triplet.index,
     
    192192            (sysarg_t) devmap_handle, &answer);
    193193       
    194         /* send connection */
    195         rc = async_req_1_0(phone, IPC_M_CONNECTION_CLONE, mountee_phone);
    196         if (rc != EOK) {
     194        /* Send connection */
     195        rc = async_exchange_clone(exch, mountee_exch);
     196        vfs_exchange_release(mountee_exch);
     197       
     198        if (rc != EOK) {
     199                vfs_exchange_release(exch);
    197200                async_wait_for(msg, NULL);
    198                 vfs_release_phone(fs_handle, mountee_phone);
    199                 vfs_release_phone(mp_res.triplet.fs_handle, phone);
     201               
    200202                /* Mount failed, drop reference to mp_node. */
    201203                if (mp_node)
    202204                        vfs_node_put(mp_node);
    203                 async_answer_0(rid, rc);
    204                 fibril_rwlock_write_unlock(&namespace_rwlock);
    205                 return;
    206         }
    207 
    208         vfs_release_phone(fs_handle, mountee_phone);
     205               
     206                async_answer_0(rid, rc);
     207                fibril_rwlock_write_unlock(&namespace_rwlock);
     208                return;
     209        }
    209210       
    210211        /* send the mount options */
    211         rc = async_data_write_start(phone, (void *)opts, str_size(opts));
    212         if (rc != EOK) {
     212        rc = async_data_write_start(exch, (void *) opts, str_size(opts));
     213        if (rc != EOK) {
     214                vfs_exchange_release(exch);
    213215                async_wait_for(msg, NULL);
    214                 vfs_release_phone(mp_res.triplet.fs_handle, phone);
     216               
    215217                /* Mount failed, drop reference to mp_node. */
    216218                if (mp_node)
    217219                        vfs_node_put(mp_node);
    218                 fibril_rwlock_write_unlock(&namespace_rwlock);
    219                 async_answer_0(rid, rc);
    220                 return;
    221         }
     220               
     221                fibril_rwlock_write_unlock(&namespace_rwlock);
     222                async_answer_0(rid, rc);
     223                return;
     224        }
     225       
     226        vfs_exchange_release(exch);
    222227        async_wait_for(msg, &rc);
    223         vfs_release_phone(mp_res.triplet.fs_handle, phone);
    224228       
    225229        if (rc == EOK) {
    226230                rindex = (fs_index_t) IPC_GET_ARG1(answer);
    227                 rsize = (size_t) IPC_GET_ARG2(answer);
    228                 rlnkcnt = (unsigned) IPC_GET_ARG3(answer);
    229        
     231                rsize = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(answer),
     232                    IPC_GET_ARG3(answer));
     233                rlnkcnt = (unsigned) IPC_GET_ARG4(answer);
     234               
    230235                mr_res.triplet.fs_handle = fs_handle;
    231236                mr_res.triplet.devmap_handle = devmap_handle;
     
    234239                mr_res.lnkcnt = rlnkcnt;
    235240                mr_res.type = VFS_NODE_DIRECTORY;
    236        
     241               
    237242                /* Add reference to the mounted root. */
    238243                mr_node = vfs_node_get(&mr_res);
     
    243248                        vfs_node_put(mp_node);
    244249        }
    245 
     250       
    246251        async_answer_0(rid, rc);
    247252        fibril_rwlock_write_unlock(&namespace_rwlock);
     
    303308       
    304309        /*
    305          * Wait for IPC_M_PING so that we can return an error if we don't know
     310         * Wait for VFS_IN_PING so that we can return an error if we don't know
    306311         * fs_name.
    307312         */
    308313        ipc_call_t data;
    309314        ipc_callid_t callid = async_get_call(&data);
    310         if (IPC_GET_IMETHOD(data) != IPC_M_PING) {
     315        if (IPC_GET_IMETHOD(data) != VFS_IN_PING) {
    311316                async_answer_0(callid, ENOTSUP);
    312317                async_answer_0(rid, ENOTSUP);
     
    321326         * This will also give us its file system handle.
    322327         */
    323         fibril_mutex_lock(&fs_head_lock);
     328        fibril_mutex_lock(&fs_list_lock);
    324329        fs_handle_t fs_handle;
    325330recheck:
     
    327332        if (!fs_handle) {
    328333                if (flags & IPC_FLAG_BLOCKING) {
    329                         fibril_condvar_wait(&fs_head_cv, &fs_head_lock);
     334                        fibril_condvar_wait(&fs_list_cv, &fs_list_lock);
    330335                        goto recheck;
    331336                }
    332337               
    333                 fibril_mutex_unlock(&fs_head_lock);
     338                fibril_mutex_unlock(&fs_list_lock);
    334339                async_answer_0(callid, ENOENT);
    335340                async_answer_0(rid, ENOENT);
     
    339344                return;
    340345        }
    341         fibril_mutex_unlock(&fs_head_lock);
     346        fibril_mutex_unlock(&fs_list_lock);
    342347       
    343348        /* Acknowledge that we know fs_name. */
     
    358363        vfs_lookup_res_t mr_res;
    359364        vfs_node_t *mr_node;
    360         int phone;
    361 
     365        async_exch_t *exch;
     366       
    362367        /*
    363368         * Receive the mount point path.
     
    367372        if (rc != EOK)
    368373                async_answer_0(rid, rc);
    369 
     374       
    370375        /*
    371376         * Taking the namespace lock will do two things for us. First, it will
     
    395400                return;
    396401        }
    397 
     402       
    398403        /*
    399404         * Count the total number of references for the mounted file system. We
     
    411416                return;
    412417        }
    413 
     418       
    414419        if (str_cmp(mp, "/") == 0) {
    415 
     420               
    416421                /*
    417422                 * Unmounting the root file system.
     
    420425                 * VFS_OUT_UNMOUNTED directly to the mounted file system.
    421426                 */
    422 
     427               
    423428                free(mp);
    424                 phone = vfs_grab_phone(mr_node->fs_handle);
    425                 rc = async_req_1_0(phone, VFS_OUT_UNMOUNTED,
     429               
     430                exch = vfs_exchange_grab(mr_node->fs_handle);
     431                rc = async_req_1_0(exch, VFS_OUT_UNMOUNTED,
    426432                    mr_node->devmap_handle);
    427                 vfs_release_phone(mr_node->fs_handle, phone);
     433                vfs_exchange_release(exch);
     434               
    428435                if (rc != EOK) {
    429436                        fibril_rwlock_write_unlock(&namespace_rwlock);
     
    432439                        return;
    433440                }
     441               
    434442                rootfs.fs_handle = 0;
    435443                rootfs.devmap_handle = 0;
    436444        } else {
    437 
     445               
    438446                /*
    439447                 * Unmounting a non-root file system.
     
    442450                 * file system, so we delegate the operation to it.
    443451                 */
    444 
     452               
    445453                rc = vfs_lookup_internal(mp, L_MP, &mp_res, NULL);
    446454                free(mp);
     
    451459                        return;
    452460                }
     461               
    453462                vfs_node_t *mp_node = vfs_node_get(&mp_res);
    454463                if (!mp_node) {
     
    458467                        return;
    459468                }
    460 
    461                 phone = vfs_grab_phone(mp_node->fs_handle);
    462                 rc = async_req_2_0(phone, VFS_OUT_UNMOUNT,
     469               
     470                exch = vfs_exchange_grab(mp_node->fs_handle);
     471                rc = async_req_2_0(exch, VFS_OUT_UNMOUNT,
    463472                    mp_node->devmap_handle, mp_node->index);
    464                 vfs_release_phone(mp_node->fs_handle, phone);
     473                vfs_exchange_release(exch);
     474               
    465475                if (rc != EOK) {
    466476                        fibril_rwlock_write_unlock(&namespace_rwlock);
     
    470480                        return;
    471481                }
    472 
     482               
    473483                /* Drop the reference we got above. */
    474484                vfs_node_put(mp_node);
     
    476486                vfs_node_put(mp_node);
    477487        }
    478 
    479 
     488       
    480489        /*
    481490         * All went well, the mounted file system was successfully unmounted.
     
    483492         */
    484493        vfs_node_forget(mr_node);
    485 
     494       
    486495        fibril_rwlock_write_unlock(&namespace_rwlock);
    487496        async_answer_0(rid, EOK);
     
    609618}
    610619
    611 void vfs_open_node(ipc_callid_t rid, ipc_call_t *request)
    612 {
    613         // FIXME: check for sanity of the supplied fs, dev and index
    614        
    615         /*
    616          * The interface is open_node(fs, dev, index, oflag).
    617          */
    618         vfs_lookup_res_t lr;
    619        
    620         lr.triplet.fs_handle = IPC_GET_ARG1(*request);
    621         lr.triplet.devmap_handle = IPC_GET_ARG2(*request);
    622         lr.triplet.index = IPC_GET_ARG3(*request);
    623         int oflag = IPC_GET_ARG4(*request);
    624        
    625         fibril_rwlock_read_lock(&namespace_rwlock);
    626        
    627         int rc = vfs_open_node_internal(&lr);
    628         if (rc != EOK) {
    629                 fibril_rwlock_read_unlock(&namespace_rwlock);
    630                 async_answer_0(rid, rc);
    631                 return;
    632         }
    633        
    634         vfs_node_t *node = vfs_node_get(&lr);
    635         fibril_rwlock_read_unlock(&namespace_rwlock);
    636        
    637         /* Truncate the file if requested and if necessary. */
    638         if (oflag & O_TRUNC) {
    639                 fibril_rwlock_write_lock(&node->contents_rwlock);
    640                 if (node->size) {
    641                         rc = vfs_truncate_internal(node->fs_handle,
    642                             node->devmap_handle, node->index, 0);
    643                         if (rc) {
    644                                 fibril_rwlock_write_unlock(&node->contents_rwlock);
    645                                 vfs_node_put(node);
    646                                 async_answer_0(rid, rc);
    647                                 return;
    648                         }
    649                         node->size = 0;
    650                 }
    651                 fibril_rwlock_write_unlock(&node->contents_rwlock);
    652         }
    653        
    654         /*
    655          * Get ourselves a file descriptor and the corresponding vfs_file_t
    656          * structure.
    657          */
    658         int fd = vfs_fd_alloc((oflag & O_DESC) != 0);
    659         if (fd < 0) {
    660                 vfs_node_put(node);
    661                 async_answer_0(rid, fd);
    662                 return;
    663         }
    664         vfs_file_t *file = vfs_file_get(fd);
    665         file->node = node;
    666         if (oflag & O_APPEND)
    667                 file->append = true;
    668        
    669         /*
    670          * The following increase in reference count is for the fact that the
    671          * file is being opened and that a file structure is pointing to it.
    672          * It is necessary so that the file will not disappear when
    673          * vfs_node_put() is called. The reference will be dropped by the
    674          * respective VFS_IN_CLOSE.
    675          */
    676         vfs_node_addref(node);
    677         vfs_node_put(node);
    678         vfs_file_put(file);
    679        
    680         /* Success! Return the new file descriptor to the client. */
    681         async_answer_1(rid, EOK, fd);
    682 }
    683 
    684620void vfs_sync(ipc_callid_t rid, ipc_call_t *request)
    685621{
     
    698634         */
    699635        fibril_mutex_lock(&file->lock);
    700         int fs_phone = vfs_grab_phone(file->node->fs_handle);
     636        async_exch_t *fs_exch = vfs_exchange_grab(file->node->fs_handle);
    701637       
    702638        /* Make a VFS_OUT_SYMC request at the destination FS server. */
    703639        aid_t msg;
    704640        ipc_call_t answer;
    705         msg = async_send_2(fs_phone, VFS_OUT_SYNC, file->node->devmap_handle,
     641        msg = async_send_2(fs_exch, VFS_OUT_SYNC, file->node->devmap_handle,
    706642            file->node->index, &answer);
    707 
     643       
     644        vfs_exchange_release(fs_exch);
     645       
    708646        /* Wait for reply from the FS server. */
    709647        sysarg_t rc;
    710648        async_wait_for(msg, &rc);
    711649       
    712         vfs_release_phone(file->node->fs_handle, fs_phone);
    713650        fibril_mutex_unlock(&file->lock);
    714 
     651       
    715652        vfs_file_put(file);
    716653        async_answer_0(rid, rc);
    717654}
    718655
    719 int vfs_close_internal(vfs_file_t *file)
    720 {
    721         /*
    722          * Lock the open file structure so that no other thread can manipulate
    723          * the same open file at a time.
    724          */
    725         fibril_mutex_lock(&file->lock);
    726        
    727         if (file->refcnt <= 1) {
    728                 /* Only close the file on the destination FS server
    729                    if there are no more file descriptors (except the
    730                    present one) pointing to this file. */
    731                
    732                 int fs_phone = vfs_grab_phone(file->node->fs_handle);
    733                
    734                 /* Make a VFS_OUT_CLOSE request at the destination FS server. */
    735                 aid_t msg;
    736                 ipc_call_t answer;
    737                 msg = async_send_2(fs_phone, VFS_OUT_CLOSE,
    738                     file->node->devmap_handle, file->node->index, &answer);
    739                
    740                 /* Wait for reply from the FS server. */
    741                 sysarg_t rc;
    742                 async_wait_for(msg, &rc);
    743                
    744                 vfs_release_phone(file->node->fs_handle, fs_phone);
    745                 fibril_mutex_unlock(&file->lock);
    746                
    747                 return IPC_GET_ARG1(answer);
    748         }
    749        
    750         fibril_mutex_unlock(&file->lock);
    751         return EOK;
    752 }
    753 
    754656void vfs_close(ipc_callid_t rid, ipc_call_t *request)
    755657{
    756658        int fd = IPC_GET_ARG1(*request);
    757        
    758         /* Lookup the file structure corresponding to the file descriptor. */
    759         vfs_file_t *file = vfs_file_get(fd);
    760         if (!file) {
    761                 async_answer_0(rid, ENOENT);
    762                 return;
    763         }
    764        
    765         int ret = vfs_close_internal(file);
    766         if (ret != EOK)
    767                 async_answer_0(rid, ret);
    768        
    769         vfs_file_put(file);
    770         ret = vfs_fd_free(fd);
     659        int ret = vfs_fd_free(fd);
    771660        async_answer_0(rid, ret);
    772661}
     
    774663static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read)
    775664{
    776         vfs_info_t *vi;
    777 
    778665        /*
    779666         * The following code strongly depends on the fact that the files data
     
    785672         * open files supports parallel access!
    786673         */
    787 
     674       
    788675        int fd = IPC_GET_ARG1(*request);
    789676       
     
    800687         */
    801688        fibril_mutex_lock(&file->lock);
    802 
    803         vi = fs_handle_to_info(file->node->fs_handle);
    804         assert(vi);
    805 
     689       
     690        vfs_info_t *fs_info = fs_handle_to_info(file->node->fs_handle);
     691        assert(fs_info);
     692       
    806693        /*
    807694         * Lock the file's node so that no other client can read/write to it at
     
    809696         * write implementation does not modify the file size.
    810697         */
    811         if (read || (vi->concurrent_read_write && vi->write_retains_size))
     698        if ((read) ||
     699            ((fs_info->concurrent_read_write) && (fs_info->write_retains_size)))
    812700                fibril_rwlock_read_lock(&file->node->contents_rwlock);
    813701        else
    814702                fibril_rwlock_write_lock(&file->node->contents_rwlock);
    815 
     703       
    816704        if (file->node->type == VFS_NODE_DIRECTORY) {
    817705                /*
     
    823711        }
    824712       
    825         int fs_phone = vfs_grab_phone(file->node->fs_handle);
     713        async_exch_t *fs_exch = vfs_exchange_grab(file->node->fs_handle);
    826714       
    827715        /*
     
    835723        ipc_call_t answer;
    836724        if (read) {
    837                 rc = async_data_read_forward_3_1(fs_phone, VFS_OUT_READ,
    838                     file->node->devmap_handle, file->node->index, file->pos,
    839                     &answer);
     725                rc = async_data_read_forward_4_1(fs_exch, VFS_OUT_READ,
     726                    file->node->devmap_handle, file->node->index,
     727                    LOWER32(file->pos), UPPER32(file->pos), &answer);
    840728        } else {
    841729                if (file->append)
    842730                        file->pos = file->node->size;
    843731               
    844                 rc = async_data_write_forward_3_1(fs_phone, VFS_OUT_WRITE,
    845                     file->node->devmap_handle, file->node->index, file->pos,
    846                     &answer);
    847         }
    848        
    849         vfs_release_phone(file->node->fs_handle, fs_phone);
     732                rc = async_data_write_forward_4_1(fs_exch, VFS_OUT_WRITE,
     733                    file->node->devmap_handle, file->node->index,
     734                    LOWER32(file->pos), UPPER32(file->pos), &answer);
     735        }
     736       
     737        vfs_exchange_release(fs_exch);
    850738       
    851739        size_t bytes = IPC_GET_ARG1(answer);
     
    855743       
    856744        /* Unlock the VFS node. */
    857         if (read || (vi->concurrent_read_write && vi->write_retains_size))
     745        if ((read) ||
     746            ((fs_info->concurrent_read_write) && (fs_info->write_retains_size)))
    858747                fibril_rwlock_read_unlock(&file->node->contents_rwlock);
    859748        else {
    860749                /* Update the cached version of node's size. */
    861750                if (rc == EOK)
    862                         file->node->size = IPC_GET_ARG2(answer);
     751                        file->node->size = MERGE_LOUP32(IPC_GET_ARG2(answer),
     752                            IPC_GET_ARG3(answer));
    863753                fibril_rwlock_write_unlock(&file->node->contents_rwlock);
    864754        }
     
    975865    fs_index_t index, aoff64_t size)
    976866{
    977         sysarg_t rc;
    978         int fs_phone;
    979        
    980         fs_phone = vfs_grab_phone(fs_handle);
    981         rc = async_req_4_0(fs_phone, VFS_OUT_TRUNCATE, (sysarg_t) devmap_handle,
    982             (sysarg_t) index, LOWER32(size), UPPER32(size));
    983         vfs_release_phone(fs_handle, fs_phone);
    984         return (int)rc;
     867        async_exch_t *exch = vfs_exchange_grab(fs_handle);
     868        sysarg_t rc = async_req_4_0(exch, VFS_OUT_TRUNCATE,
     869            (sysarg_t) devmap_handle, (sysarg_t) index, LOWER32(size),
     870            UPPER32(size));
     871        vfs_exchange_release(exch);
     872       
     873        return (int) rc;
    985874}
    986875
     
    1032921        fibril_mutex_lock(&file->lock);
    1033922
    1034         int fs_phone = vfs_grab_phone(file->node->fs_handle);
     923        async_exch_t *exch = vfs_exchange_grab(file->node->fs_handle);
    1035924       
    1036925        aid_t msg;
    1037         msg = async_send_3(fs_phone, VFS_OUT_STAT, file->node->devmap_handle,
     926        msg = async_send_3(exch, VFS_OUT_STAT, file->node->devmap_handle,
    1038927            file->node->index, true, NULL);
    1039         async_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     928        async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     929       
     930        vfs_exchange_release(exch);
     931       
    1040932        async_wait_for(msg, &rc);
    1041         vfs_release_phone(file->node->fs_handle, fs_phone);
    1042 
     933       
    1043934        fibril_mutex_unlock(&file->lock);
    1044935        vfs_file_put(file);
     
    1083974        fibril_rwlock_read_unlock(&namespace_rwlock);
    1084975
    1085         int fs_phone = vfs_grab_phone(node->fs_handle);
     976        async_exch_t *exch = vfs_exchange_grab(node->fs_handle);
     977       
    1086978        aid_t msg;
    1087         msg = async_send_3(fs_phone, VFS_OUT_STAT, node->devmap_handle,
     979        msg = async_send_3(exch, VFS_OUT_STAT, node->devmap_handle,
    1088980            node->index, false, NULL);
    1089         async_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     981        async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     982       
     983        vfs_exchange_release(exch);
    1090984       
    1091985        sysarg_t rv;
    1092986        async_wait_for(msg, &rv);
    1093         vfs_release_phone(node->fs_handle, fs_phone);
    1094987
    1095988        async_answer_0(rid, rv);
     
    12341127        if (!parentc) {
    12351128                fibril_rwlock_write_unlock(&namespace_rwlock);
     1129                vfs_node_put(old_node);
    12361130                async_answer_0(rid, rc);
    12371131                free(old);
     
    12511145        if (rc != EOK) {
    12521146                fibril_rwlock_write_unlock(&namespace_rwlock);
     1147                vfs_node_put(old_node);
    12531148                async_answer_0(rid, rc);
    12541149                free(old);
     
    12611156            (old_node->devmap_handle != new_par_lr.triplet.devmap_handle)) {
    12621157                fibril_rwlock_write_unlock(&namespace_rwlock);
     1158                vfs_node_put(old_node);
    12631159                async_answer_0(rid, EXDEV);     /* different file systems */
    12641160                free(old);
     
    12791175                if (!new_node) {
    12801176                        fibril_rwlock_write_unlock(&namespace_rwlock);
     1177                        vfs_node_put(old_node);
    12811178                        async_answer_0(rid, ENOMEM);
    12821179                        free(old);
     
    12901187        default:
    12911188                fibril_rwlock_write_unlock(&namespace_rwlock);
     1189                vfs_node_put(old_node);
    12921190                async_answer_0(rid, ENOTEMPTY);
    12931191                free(old);
     
    13001198        if (rc != EOK) {
    13011199                fibril_rwlock_write_unlock(&namespace_rwlock);
     1200                vfs_node_put(old_node);
    13021201                if (new_node)
    13031202                        vfs_node_put(new_node);
     
    13631262        fibril_mutex_lock(&oldfile->lock);
    13641263       
    1365         /* Lookup an open file structure possibly corresponding to newfd. */
    1366         vfs_file_t *newfile = vfs_file_get(newfd);
    1367         if (newfile) {
    1368                 /* Close the originally opened file. */
    1369                 int ret = vfs_close_internal(newfile);
    1370                 if (ret != EOK) {
    1371                         fibril_mutex_unlock(&oldfile->lock);
    1372                         vfs_file_put(oldfile);
    1373                         vfs_file_put(newfile);
    1374                         async_answer_0(rid, ret);
    1375                         return;
    1376                 }
    1377                
    1378                 ret = vfs_fd_free(newfd);
    1379                 if (ret != EOK) {
    1380                         fibril_mutex_unlock(&oldfile->lock);
    1381                         vfs_file_put(oldfile);
    1382                         vfs_file_put(newfile);
    1383                         async_answer_0(rid, ret);
    1384                         return;
    1385                 }
    1386                 vfs_file_put(newfile);
    1387         }
     1264        /* Make sure newfd is closed. */
     1265        (void) vfs_fd_free(newfd);
    13881266       
    13891267        /* Assign the old file to newfd. */
     
    13981276}
    13991277
     1278void vfs_wait_handle(ipc_callid_t rid, ipc_call_t *request)
     1279{
     1280        int fd = vfs_wait_handle_internal();
     1281        async_answer_1(rid, EOK, fd);
     1282}
     1283
    14001284/**
    14011285 * @}
Note: See TracChangeset for help on using the changeset viewer.