Changeset 9c4cf0d in mainline for uspace/lib/c


Ignore:
Timestamp:
2017-04-02T11:24:06Z (8 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().

Location:
uspace/lib/c
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/elf/elf_mod.c

    rb19e892 r9c4cf0d  
    108108        rc = elf_load_module(&elf, so_bias);
    109109
    110         close(ofile);
     110        vfs_put(ofile);
    111111        return rc;
    112112}
     
    117117        int file = vfs_lookup(path, 0);
    118118        int rc = elf_load_file(file, so_bias, flags, info);
    119         close(file);
     119        vfs_put(file);
    120120        return rc;
    121121}
  • uspace/lib/c/generic/io/io.c

    rb19e892 r9c4cf0d  
    305305        if (rc != EOK) {
    306306                errno = rc;
    307                 close(file);
     307                vfs_put(file);
    308308                free(stream);
    309309                return NULL;
     
    314314                if (rc != EOK) {
    315315                        errno = rc;
    316                         close(file);
     316                        vfs_put(file);
    317317                        free(stream);
    318318                        return NULL;
     
    370370       
    371371        if (stream->fd >= 0)
    372                 rc = close(stream->fd);
     372                rc = vfs_put(stream->fd);
    373373       
    374374        list_remove(&stream->link);
  • uspace/lib/c/generic/loader.c

    rb19e892 r9c4cf0d  
    204204       
    205205        int rc = loader_set_program(ldr, name, fd);
    206         close(fd);
     206        vfs_put(fd);
    207207        return rc;
    208208}
  • uspace/lib/c/generic/task.c

    rb19e892 r9c4cf0d  
    181181        if (root >= 0) {
    182182                rc = loader_add_inbox(ldr, "root", root);
    183                 close(root);
     183                vfs_put(root);
    184184                if (rc != EOK)
    185185                        goto error;
  • uspace/lib/c/generic/vfs/inbox.c

    rb19e892 r9c4cf0d  
    11
    22#include <vfs/inbox.h>
     3#include <vfs/vfs.h>
    34
    45#include <adt/list.h>
     
    126127                int original = inbox_set(entries[i].name, entries[i].file);
    127128                if (original >= 0) {
    128                         close(original);
     129                        vfs_put(original);
    129130                }
    130131        }
  • 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;
  • uspace/lib/c/include/ipc/vfs.h

    rb19e892 r9c4cf0d  
    6767        VFS_IN_RESIZE,
    6868        VFS_IN_STAT,
    69         VFS_IN_CLOSE,
    7069        VFS_IN_MOUNT,
     70        VFS_IN_PUT,
    7171        VFS_IN_UNMOUNT,
    7272        VFS_IN_SYNC,
  • uspace/lib/c/include/unistd.h

    rb19e892 r9c4cf0d  
    6161extern ssize_t read(int, aoff64_t *, void *, size_t);
    6262
    63 extern int close(int);
    64 
    6563extern char *getcwd(char *, size_t);
    6664extern int chdir(const char *);
  • uspace/lib/c/include/vfs/vfs.h

    rb19e892 r9c4cf0d  
    9797    unsigned, int *);
    9898extern int vfs_open(int, int);
     99extern int vfs_put(int);
    99100extern int vfs_resize(int, aoff64_t);
    100101extern int vfs_root(void);
Note: See TracChangeset for help on using the changeset viewer.