Ignore:
File:
1 edited

Legend:

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

    rb7fd2a0 r40feeac  
    5252
    5353/* Forward declarations of static functions. */
    54 static errno_t vfs_truncate_internal(fs_handle_t, service_id_t, fs_index_t,
     54static int vfs_truncate_internal(fs_handle_t, service_id_t, fs_index_t,
    5555    aoff64_t);
    5656
     
    8686}
    8787
    88 errno_t vfs_op_clone(int oldfd, int newfd, bool desc, int *out_fd)
    89 {
    90         errno_t rc;
     88int vfs_op_clone(int oldfd, int newfd, bool desc)
     89{
     90        int rc;
    9191
    9292        /* If the file descriptors are the same, do nothing. */
     
    104104                /* Assign the old file to newfd. */
    105105                rc = vfs_fd_assign(oldfile, newfd);
    106                 *out_fd = newfd;
    107106        } else {
    108107                vfs_file_t *newfile;
    109                 rc = vfs_fd_alloc(&newfile, desc, out_fd);
    110                 if (rc == EOK) {
     108                int newfd = vfs_fd_alloc(&newfile, desc);
     109                if (newfd >= 0) {
    111110                        newfile->node = oldfile->node;
    112111                        newfile->permissions = oldfile->permissions;
     
    115114                        vfs_file_put(newfile);
    116115                }
     116                rc = newfd;
    117117        }
    118118        vfs_file_put(oldfile);
     
    121121}
    122122
    123 errno_t vfs_op_put(int fd)
     123int vfs_op_put(int fd)
    124124{
    125125        return vfs_fd_free(fd);
    126126}
    127127
    128 static errno_t vfs_connect_internal(service_id_t service_id, unsigned flags,
     128static int vfs_connect_internal(service_id_t service_id, unsigned flags,
    129129    unsigned instance, const char *options, const char *fsname,
    130130    vfs_node_t **root)
     
    152152            &answer);
    153153        /* Send the mount options */
    154         errno_t rc = async_data_write_start(exch, options, str_size(options));
     154        sysarg_t rc = async_data_write_start(exch, options, str_size(options));
    155155        if (rc != EOK) {
    156156                async_forget(msg);
     
    188188}
    189189
    190 errno_t vfs_op_fsprobe(const char *fs_name, service_id_t sid,
     190int vfs_op_fsprobe(const char *fs_name, service_id_t sid,
    191191    vfs_fs_probe_info_t *info)
    192192{
    193193        fs_handle_t fs_handle = 0;
    194         errno_t rc;
    195         errno_t retval;
     194        sysarg_t rc;
     195        int retval;
    196196       
    197197        fibril_mutex_lock(&fs_list_lock);
     
    222222}
    223223
    224 errno_t vfs_op_mount(int mpfd, unsigned service_id, unsigned flags,
    225     unsigned instance, const char *opts, const char *fs_name, int *out_fd)
    226 {
    227         errno_t rc;
     224int vfs_op_mount(int mpfd, unsigned service_id, unsigned flags,
     225    unsigned instance, const char *opts, const char *fs_name, int *outfd)
     226{
     227        int rc;
    228228        vfs_file_t *mp = NULL;
    229229        vfs_file_t *file = NULL;
    230         *out_fd = -1;
     230        int fd = -1;
    231231       
    232232        if (!(flags & VFS_MOUNT_CONNECT_ONLY)) {
     
    254254       
    255255        if (!(flags & VFS_MOUNT_NO_REF)) {
    256                 rc = vfs_fd_alloc(&file, false, out_fd);
    257                 if (rc != EOK) {
     256                fd = vfs_fd_alloc(&file, false);
     257                if (fd < 0) {
     258                        rc = fd;
    258259                        goto out;
    259260                }
     
    294295                vfs_file_put(file);
    295296
    296         if (rc != EOK && *out_fd >= 0) {
    297                 vfs_fd_free(*out_fd);
    298                 *out_fd = -1;
    299         }
    300        
     297        if (rc != EOK && fd >= 0) {
     298                vfs_fd_free(fd);
     299                fd = 0;
     300        }
     301       
     302        *outfd = fd;
    301303        return rc;
    302304}
    303305
    304 errno_t vfs_op_open(int fd, int mode)
     306int vfs_op_open(int fd, int mode)
    305307{
    306308        if (mode == 0)
     
    336338        }
    337339       
    338         errno_t rc = vfs_open_node_remote(file->node);
     340        int rc = vfs_open_node_remote(file->node);
    339341        if (rc != EOK) {
    340342                file->open_read = file->open_write = false;
     
    347349}
    348350
    349 typedef errno_t (* rdwr_ipc_cb_t)(async_exch_t *, vfs_file_t *, aoff64_t,
     351typedef int (* rdwr_ipc_cb_t)(async_exch_t *, vfs_file_t *, aoff64_t,
    350352    ipc_call_t *, bool, void *);
    351353
    352 static errno_t rdwr_ipc_client(async_exch_t *exch, vfs_file_t *file, aoff64_t pos,
     354static int rdwr_ipc_client(async_exch_t *exch, vfs_file_t *file, aoff64_t pos,
    353355    ipc_call_t *answer, bool read, void *data)
    354356{
    355357        size_t *bytes = (size_t *) data;
    356         errno_t rc;
     358        int rc;
    357359
    358360        /*
     
    378380}
    379381
    380 static errno_t rdwr_ipc_internal(async_exch_t *exch, vfs_file_t *file, aoff64_t pos,
     382static int rdwr_ipc_internal(async_exch_t *exch, vfs_file_t *file, aoff64_t pos,
    381383    ipc_call_t *answer, bool read, void *data)
    382384{
     
    392394                return EINVAL;
    393395
    394         errno_t retval = async_data_read_start(exch, chunk->buffer, chunk->size);
     396        int retval = async_data_read_start(exch, chunk->buffer, chunk->size);
    395397        if (retval != EOK) {
    396398                async_forget(msg);
     
    398400        }
    399401       
    400         errno_t rc;
     402        sysarg_t rc;
    401403        async_wait_for(msg, &rc);
    402404       
    403405        chunk->size = IPC_GET_ARG1(*answer);
    404406
    405         return (errno_t) rc;
    406 }
    407 
    408 static errno_t vfs_rdwr(int fd, aoff64_t pos, bool read, rdwr_ipc_cb_t ipc_cb,
     407        return (int) rc;
     408}
     409
     410static int vfs_rdwr(int fd, aoff64_t pos, bool read, rdwr_ipc_cb_t ipc_cb,
    409411    void *ipc_cb_data)
    410412{
     
    475477         */
    476478        ipc_call_t answer;
    477         errno_t rc = ipc_cb(fs_exch, file, pos, &answer, read, ipc_cb_data);
     479        int rc = ipc_cb(fs_exch, file, pos, &answer, read, ipc_cb_data);
    478480       
    479481        vfs_exchange_release(fs_exch);
     
    499501}
    500502
    501 errno_t vfs_rdwr_internal(int fd, aoff64_t pos, bool read, rdwr_io_chunk_t *chunk)
     503int vfs_rdwr_internal(int fd, aoff64_t pos, bool read, rdwr_io_chunk_t *chunk)
    502504{
    503505        return vfs_rdwr(fd, pos, read, rdwr_ipc_internal, chunk);
    504506}
    505507
    506 errno_t vfs_op_read(int fd, aoff64_t pos, size_t *out_bytes)
     508int vfs_op_read(int fd, aoff64_t pos, size_t *out_bytes)
    507509{
    508510        return vfs_rdwr(fd, pos, true, rdwr_ipc_client, out_bytes);
    509511}
    510512
    511 errno_t vfs_op_rename(int basefd, char *old, char *new)
     513int vfs_op_rename(int basefd, char *old, char *new)
    512514{
    513515        vfs_file_t *base_file = vfs_file_get(basefd);
     
    524526        bool orig_unlinked = false;
    525527       
    526         errno_t rc;
     528        int rc;
    527529       
    528530        size_t shared = shared_path(old, new);
     
    610612}
    611613
    612 errno_t vfs_op_resize(int fd, int64_t size)
     614int vfs_op_resize(int fd, int64_t size)
    613615{
    614616        vfs_file_t *file = vfs_file_get(fd);
     
    618620        fibril_rwlock_write_lock(&file->node->contents_rwlock);
    619621       
    620         errno_t rc = vfs_truncate_internal(file->node->fs_handle,
     622        int rc = vfs_truncate_internal(file->node->fs_handle,
    621623            file->node->service_id, file->node->index, size);
    622624        if (rc == EOK)
     
    628630}
    629631
    630 errno_t vfs_op_stat(int fd)
     632int vfs_op_stat(int fd)
    631633{
    632634        vfs_file_t *file = vfs_file_get(fd);
     
    637639
    638640        async_exch_t *exch = vfs_exchange_grab(node->fs_handle);
    639         errno_t rc = async_data_read_forward_fast(exch, VFS_OUT_STAT,
     641        int rc = async_data_read_forward_fast(exch, VFS_OUT_STAT,
    640642            node->service_id, node->index, true, 0, NULL);
    641643        vfs_exchange_release(exch);
     
    645647}
    646648
    647 errno_t vfs_op_statfs(int fd)
     649int vfs_op_statfs(int fd)
    648650{
    649651        vfs_file_t *file = vfs_file_get(fd);
     
    654656
    655657        async_exch_t *exch = vfs_exchange_grab(node->fs_handle);
    656         errno_t rc = async_data_read_forward_fast(exch, VFS_OUT_STATFS,
     658        int rc = async_data_read_forward_fast(exch, VFS_OUT_STATFS,
    657659            node->service_id, node->index, false, 0, NULL);
    658660        vfs_exchange_release(exch);
     
    662664}
    663665
    664 errno_t vfs_op_sync(int fd)
     666int vfs_op_sync(int fd)
    665667{
    666668        vfs_file_t *file = vfs_file_get(fd);
     
    677679        vfs_exchange_release(fs_exch);
    678680       
    679         errno_t rc;
     681        sysarg_t rc;
    680682        async_wait_for(msg, &rc);
    681683       
     
    685687}
    686688
    687 static errno_t vfs_truncate_internal(fs_handle_t fs_handle, service_id_t service_id,
     689static int vfs_truncate_internal(fs_handle_t fs_handle, service_id_t service_id,
    688690    fs_index_t index, aoff64_t size)
    689691{
    690692        async_exch_t *exch = vfs_exchange_grab(fs_handle);
    691         errno_t rc = async_req_4_0(exch, VFS_OUT_TRUNCATE,
     693        sysarg_t rc = async_req_4_0(exch, VFS_OUT_TRUNCATE,
    692694            (sysarg_t) service_id, (sysarg_t) index, LOWER32(size),
    693695            UPPER32(size));
    694696        vfs_exchange_release(exch);
    695697       
    696         return (errno_t) rc;
    697 }
    698 
    699 errno_t vfs_op_unlink(int parentfd, int expectfd, char *path)
    700 {
    701         errno_t rc = EOK;
     698        return (int) rc;
     699}
     700
     701int vfs_op_unlink(int parentfd, int expectfd, char *path)
     702{
     703        int rc = EOK;
    702704        vfs_file_t *parent = NULL;
    703705        vfs_file_t *expect = NULL;
     
    778780}
    779781
    780 errno_t vfs_op_unmount(int mpfd)
     782int vfs_op_unmount(int mpfd)
    781783{
    782784        vfs_file_t *mp = vfs_file_get(mpfd);
     
    806808       
    807809        async_exch_t *exch = vfs_exchange_grab(mp->node->mount->fs_handle);
    808         errno_t rc = async_req_1_0(exch, VFS_OUT_UNMOUNTED,
     810        int rc = async_req_1_0(exch, VFS_OUT_UNMOUNTED,
    809811            mp->node->mount->service_id);
    810812        vfs_exchange_release(exch);
     
    826828}
    827829
    828 errno_t vfs_op_wait_handle(bool high_fd, int *out_fd)
    829 {
    830         return vfs_wait_handle_internal(high_fd, out_fd);
     830int vfs_op_wait_handle(bool high_fd)
     831{
     832        return vfs_wait_handle_internal(high_fd);
    831833}
    832834
     
    862864}
    863865
    864 errno_t vfs_op_walk(int parentfd, int flags, char *path, int *out_fd)
     866int vfs_op_walk(int parentfd, int flags, char *path, int *out_fd)
    865867{
    866868        if (!walk_flags_valid(flags))
     
    874876       
    875877        vfs_lookup_res_t lr;
    876         errno_t rc = vfs_lookup_internal(parent->node, path,
     878        int rc = vfs_lookup_internal(parent->node, path,
    877879            walk_lookup_flags(flags), &lr);
    878880        if (rc != EOK) {
     
    890892       
    891893        vfs_file_t *file;
    892         rc = vfs_fd_alloc(&file, false, out_fd);
    893         if (rc != EOK) {
     894        int fd = vfs_fd_alloc(&file, false);
     895        if (fd < 0) {
    894896                vfs_node_put(node);
    895897                vfs_file_put(parent);
    896                 return rc;
     898                return fd;
    897899        }
    898900        assert(file != NULL);
     
    908910        fibril_rwlock_read_unlock(&namespace_rwlock);
    909911
     912        *out_fd = fd;
    910913        return EOK;
    911914}
    912915
    913 errno_t vfs_op_write(int fd, aoff64_t pos, size_t *out_bytes)
     916int vfs_op_write(int fd, aoff64_t pos, size_t *out_bytes)
    914917{
    915918        return vfs_rdwr(fd, pos, false, rdwr_ipc_client, out_bytes);
Note: See TracChangeset for help on using the changeset viewer.