Changeset 9c4cf0d in mainline for uspace/lib/c/generic/vfs/vfs.c


Ignore:
Timestamp:
2017-04-02T11:24:06Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
151f1cc
Parents:
b19e892
Message:

Rename close() to vfs_put()

This is motivated mainly by the fact that a file handle does not
necessarily correspond to an open file and close() was no longer the
the opposite operation to open().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/vfs/vfs.c

    rb19e892 r9c4cf0d  
    8282        fibril_mutex_lock(&root_mutex);
    8383        if (root_fd >= 0)
    84                 close(root_fd);
     84                vfs_put(root_fd);
    8585        root_fd = vfs_clone(nroot, -1, true);
    8686        fibril_mutex_unlock(&root_mutex);
     
    149149        }
    150150        int rc = _vfs_walk(root, p, flags);
    151         close(root);
     151        vfs_put(root);
    152152        free(p);
    153153        return rc;
     
    171171        int rc = vfs_open(file, mode);
    172172        if (rc != EOK) {
    173                 close(file);
     173                vfs_put(file);
    174174                return rc;
    175175        }
     
    342342                        rc = vfs_mount(mpfd, fs_name, service_id, opts, flags,
    343343                            instance, NULL);
    344                         close(mpfd);
     344                        vfs_put(mpfd);
    345345                } else {
    346346                        rc = mpfd;
     
    363363       
    364364        int rc = vfs_unmount(mp);
    365         close(mp);
     365        vfs_put(mp);
    366366        return rc;
    367367}
     
    370370 *
    371371 * @param fildes File descriptor
    372  * @return Zero on success. On error -1 is returned and errno is set.
    373  */
    374 int close(int fildes)
     372 * @return EOK on success or a negative error code otherwise.
     373 */
     374int vfs_put(int fildes)
    375375{
    376376        sysarg_t rc;
    377377       
    378378        async_exch_t *exch = vfs_exchange_begin();
    379         rc = async_req_1_0(exch, VFS_IN_CLOSE, fildes);
     379        rc = async_req_1_0(exch, VFS_IN_PUT, fildes);
    380380        vfs_exchange_end(exch);
    381381       
     
    631631        int rc = vfs_stat(file, stat);
    632632
    633         close(file);
     633        vfs_put(file);
    634634
    635635        return rc;
     
    660660        if (rc < 0) {
    661661                free(dirp);
    662                 close(fd);
     662                vfs_put(fd);
    663663                errno = rc;
    664664                return NULL;
     
    711711        int rc;
    712712       
    713         rc = close(dirp->fd);
     713        rc = vfs_put(dirp->fd);
    714714        free(dirp);
    715715
     
    726726                return file;
    727727
    728         close(file);
     728        vfs_put(file);
    729729
    730730        return EOK;
     
    762762
    763763        free(pa);
    764         close(parent);
     764        vfs_put(parent);
    765765        return rc;
    766766}       
     
    816816        if (parent < 0) {
    817817                free(pa);
    818                 close(expect);
     818                vfs_put(expect);
    819819                return parent;
    820820        }
     
    823823       
    824824        free(pa);
    825         close(parent);
    826         close(expect);
     825        vfs_put(parent);
     826        vfs_put(expect);
    827827        return rc;
    828828}
     
    871871                free(olda);
    872872                free(newa);
    873                 close(root);
     873                vfs_put(root);
    874874                async_wait_for(req, &rc_orig);
    875875                if (rc_orig != EOK)
     
    886886                free(olda);
    887887                free(newa);
    888                 close(root);
     888                vfs_put(root);
    889889                async_wait_for(req, &rc_orig);
    890890                if (rc_orig != EOK)
     
    899899        free(olda);
    900900        free(newa);
    901         close(root);
     901        vfs_put(root);
    902902        async_wait_for(req, &rc);
    903903
     
    934934       
    935935        if (cwd_fd >= 0)
    936                 close(cwd_fd);
     936                vfs_put(cwd_fd);
    937937       
    938938        if (cwd_path)
     
    11241124        int rc = vfs_statfs(file, st);
    11251125
    1126         close(file);
     1126        vfs_put(file);
    11271127
    11281128        return rc;
Note: See TracChangeset for help on using the changeset viewer.