Changeset 6ad454f in mainline for uspace/srv/vfs/vfs_ops.c


Ignore:
Timestamp:
2017-12-08T21:03:35Z (8 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a8c7a6d
Parents:
9246016
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-08 06:01:16)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-08 21:03:35)
Message:

Pass file handles separately from error codes.

File:
1 edited

Legend:

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

    r9246016 r6ad454f  
    104104                /* Assign the old file to newfd. */
    105105                rc = vfs_fd_assign(oldfile, newfd);
     106                *out_fd = newfd;
    106107        } else {
    107108                vfs_file_t *newfile;
    108                 int newfd = vfs_fd_alloc(&newfile, desc);
    109                 if (newfd >= 0) {
     109                rc = vfs_fd_alloc(&newfile, desc, out_fd);
     110                if (rc == EOK) {
    110111                        newfile->node = oldfile->node;
    111112                        newfile->permissions = oldfile->permissions;
     
    114115                        vfs_file_put(newfile);
    115116                }
    116                 rc = newfd;
    117117        }
    118118        vfs_file_put(oldfile);
    119119       
    120         if (rc < 0) {
    121                 return rc;
    122         }
    123        
    124         *out_fd = rc;
    125         return EOK;
     120        return rc;
    126121}
    127122
     
    228223
    229224int vfs_op_mount(int mpfd, unsigned service_id, unsigned flags,
    230     unsigned instance, const char *opts, const char *fs_name, int *outfd)
     225    unsigned instance, const char *opts, const char *fs_name, int *out_fd)
    231226{
    232227        int rc;
    233228        vfs_file_t *mp = NULL;
    234229        vfs_file_t *file = NULL;
    235         int fd = -1;
     230        *out_fd = -1;
    236231       
    237232        if (!(flags & VFS_MOUNT_CONNECT_ONLY)) {
     
    259254       
    260255        if (!(flags & VFS_MOUNT_NO_REF)) {
    261                 fd = vfs_fd_alloc(&file, false);
    262                 if (fd < 0) {
    263                         rc = fd;
     256                rc = vfs_fd_alloc(&file, false, out_fd);
     257                if (rc != EOK) {
    264258                        goto out;
    265259                }
     
    300294                vfs_file_put(file);
    301295
    302         if (rc != EOK && fd >= 0) {
    303                 vfs_fd_free(fd);
    304                 fd = 0;
    305         }
    306        
    307         *outfd = fd;
     296        if (rc != EOK && *out_fd >= 0) {
     297                vfs_fd_free(*out_fd);
     298                *out_fd = -1;
     299        }
     300       
    308301        return rc;
    309302}
     
    833826}
    834827
    835 int vfs_op_wait_handle(bool high_fd)
    836 {
    837         return vfs_wait_handle_internal(high_fd);
     828int vfs_op_wait_handle(bool high_fd, int *out_fd)
     829{
     830        return vfs_wait_handle_internal(high_fd, out_fd);
    838831}
    839832
     
    897890       
    898891        vfs_file_t *file;
    899         int fd = vfs_fd_alloc(&file, false);
    900         if (fd < 0) {
     892        rc = vfs_fd_alloc(&file, false, out_fd);
     893        if (rc != EOK) {
    901894                vfs_node_put(node);
    902895                vfs_file_put(parent);
    903                 return fd;
     896                return rc;
    904897        }
    905898        assert(file != NULL);
     
    915908        fibril_rwlock_read_unlock(&namespace_rwlock);
    916909
    917         *out_fd = fd;
    918910        return EOK;
    919911}
Note: See TracChangeset for help on using the changeset viewer.