Ignore:
File:
1 edited

Legend:

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

    r40feeac rb7fd2a0  
    5252
    5353/* Forward declarations of static functions. */
    54 static int vfs_truncate_internal(fs_handle_t, service_id_t, fs_index_t,
     54static errno_t vfs_truncate_internal(fs_handle_t, service_id_t, fs_index_t,
    5555    aoff64_t);
    5656
     
    8686}
    8787
    88 int vfs_op_clone(int oldfd, int newfd, bool desc)
    89 {
    90         int rc;
     88errno_t vfs_op_clone(int oldfd, int newfd, bool desc, int *out_fd)
     89{
     90        errno_t 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;
    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);
     
    121121}
    122122
    123 int vfs_op_put(int fd)
     123errno_t vfs_op_put(int fd)
    124124{
    125125        return vfs_fd_free(fd);
    126126}
    127127
    128 static int vfs_connect_internal(service_id_t service_id, unsigned flags,
     128static errno_t 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         sysarg_t rc = async_data_write_start(exch, options, str_size(options));
     154        errno_t rc = async_data_write_start(exch, options, str_size(options));
    155155        if (rc != EOK) {
    156156                async_forget(msg);
     
    188188}
    189189
    190 int vfs_op_fsprobe(const char *fs_name, service_id_t sid,
     190errno_t 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         sysarg_t rc;
    195         int retval;
     194        errno_t rc;
     195        errno_t retval;
    196196       
    197197        fibril_mutex_lock(&fs_list_lock);
     
    222222}
    223223
    224 int 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;
     224errno_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;
    228228        vfs_file_t *mp = NULL;
    229229        vfs_file_t *file = NULL;
    230         int fd = -1;
     230        *out_fd = -1;
    231231       
    232232        if (!(flags & VFS_MOUNT_CONNECT_ONLY)) {
     
    254254       
    255255        if (!(flags & VFS_MOUNT_NO_REF)) {
    256                 fd = vfs_fd_alloc(&file, false);
    257                 if (fd < 0) {
    258                         rc = fd;
     256                rc = vfs_fd_alloc(&file, false, out_fd);
     257                if (rc != EOK) {
    259258                        goto out;
    260259                }
     
    295294                vfs_file_put(file);
    296295
    297         if (rc != EOK && fd >= 0) {
    298                 vfs_fd_free(fd);
    299                 fd = 0;
    300         }
    301        
    302         *outfd = fd;
     296        if (rc != EOK && *out_fd >= 0) {
     297                vfs_fd_free(*out_fd);
     298                *out_fd = -1;
     299        }
     300       
    303301        return rc;
    304302}
    305303
    306 int vfs_op_open(int fd, int mode)
     304errno_t vfs_op_open(int fd, int mode)
    307305{
    308306        if (mode == 0)
     
    338336        }
    339337       
    340         int rc = vfs_open_node_remote(file->node);
     338        errno_t rc = vfs_open_node_remote(file->node);
    341339        if (rc != EOK) {
    342340                file->open_read = file->open_write = false;
     
    349347}
    350348
    351 typedef int (* rdwr_ipc_cb_t)(async_exch_t *, vfs_file_t *, aoff64_t,
     349typedef errno_t (* rdwr_ipc_cb_t)(async_exch_t *, vfs_file_t *, aoff64_t,
    352350    ipc_call_t *, bool, void *);
    353351
    354 static int rdwr_ipc_client(async_exch_t *exch, vfs_file_t *file, aoff64_t pos,
     352static errno_t rdwr_ipc_client(async_exch_t *exch, vfs_file_t *file, aoff64_t pos,
    355353    ipc_call_t *answer, bool read, void *data)
    356354{
    357355        size_t *bytes = (size_t *) data;
    358         int rc;
     356        errno_t rc;
    359357
    360358        /*
     
    380378}
    381379
    382 static int rdwr_ipc_internal(async_exch_t *exch, vfs_file_t *file, aoff64_t pos,
     380static errno_t rdwr_ipc_internal(async_exch_t *exch, vfs_file_t *file, aoff64_t pos,
    383381    ipc_call_t *answer, bool read, void *data)
    384382{
     
    394392                return EINVAL;
    395393
    396         int retval = async_data_read_start(exch, chunk->buffer, chunk->size);
     394        errno_t retval = async_data_read_start(exch, chunk->buffer, chunk->size);
    397395        if (retval != EOK) {
    398396                async_forget(msg);
     
    400398        }
    401399       
    402         sysarg_t rc;
     400        errno_t rc;
    403401        async_wait_for(msg, &rc);
    404402       
    405403        chunk->size = IPC_GET_ARG1(*answer);
    406404
    407         return (int) rc;
    408 }
    409 
    410 static int vfs_rdwr(int fd, aoff64_t pos, bool read, rdwr_ipc_cb_t ipc_cb,
     405        return (errno_t) rc;
     406}
     407
     408static errno_t vfs_rdwr(int fd, aoff64_t pos, bool read, rdwr_ipc_cb_t ipc_cb,
    411409    void *ipc_cb_data)
    412410{
     
    477475         */
    478476        ipc_call_t answer;
    479         int rc = ipc_cb(fs_exch, file, pos, &answer, read, ipc_cb_data);
     477        errno_t rc = ipc_cb(fs_exch, file, pos, &answer, read, ipc_cb_data);
    480478       
    481479        vfs_exchange_release(fs_exch);
     
    501499}
    502500
    503 int vfs_rdwr_internal(int fd, aoff64_t pos, bool read, rdwr_io_chunk_t *chunk)
     501errno_t vfs_rdwr_internal(int fd, aoff64_t pos, bool read, rdwr_io_chunk_t *chunk)
    504502{
    505503        return vfs_rdwr(fd, pos, read, rdwr_ipc_internal, chunk);
    506504}
    507505
    508 int vfs_op_read(int fd, aoff64_t pos, size_t *out_bytes)
     506errno_t vfs_op_read(int fd, aoff64_t pos, size_t *out_bytes)
    509507{
    510508        return vfs_rdwr(fd, pos, true, rdwr_ipc_client, out_bytes);
    511509}
    512510
    513 int vfs_op_rename(int basefd, char *old, char *new)
     511errno_t vfs_op_rename(int basefd, char *old, char *new)
    514512{
    515513        vfs_file_t *base_file = vfs_file_get(basefd);
     
    526524        bool orig_unlinked = false;
    527525       
    528         int rc;
     526        errno_t rc;
    529527       
    530528        size_t shared = shared_path(old, new);
     
    612610}
    613611
    614 int vfs_op_resize(int fd, int64_t size)
     612errno_t vfs_op_resize(int fd, int64_t size)
    615613{
    616614        vfs_file_t *file = vfs_file_get(fd);
     
    620618        fibril_rwlock_write_lock(&file->node->contents_rwlock);
    621619       
    622         int rc = vfs_truncate_internal(file->node->fs_handle,
     620        errno_t rc = vfs_truncate_internal(file->node->fs_handle,
    623621            file->node->service_id, file->node->index, size);
    624622        if (rc == EOK)
     
    630628}
    631629
    632 int vfs_op_stat(int fd)
     630errno_t vfs_op_stat(int fd)
    633631{
    634632        vfs_file_t *file = vfs_file_get(fd);
     
    639637
    640638        async_exch_t *exch = vfs_exchange_grab(node->fs_handle);
    641         int rc = async_data_read_forward_fast(exch, VFS_OUT_STAT,
     639        errno_t rc = async_data_read_forward_fast(exch, VFS_OUT_STAT,
    642640            node->service_id, node->index, true, 0, NULL);
    643641        vfs_exchange_release(exch);
     
    647645}
    648646
    649 int vfs_op_statfs(int fd)
     647errno_t vfs_op_statfs(int fd)
    650648{
    651649        vfs_file_t *file = vfs_file_get(fd);
     
    656654
    657655        async_exch_t *exch = vfs_exchange_grab(node->fs_handle);
    658         int rc = async_data_read_forward_fast(exch, VFS_OUT_STATFS,
     656        errno_t rc = async_data_read_forward_fast(exch, VFS_OUT_STATFS,
    659657            node->service_id, node->index, false, 0, NULL);
    660658        vfs_exchange_release(exch);
     
    664662}
    665663
    666 int vfs_op_sync(int fd)
     664errno_t vfs_op_sync(int fd)
    667665{
    668666        vfs_file_t *file = vfs_file_get(fd);
     
    679677        vfs_exchange_release(fs_exch);
    680678       
    681         sysarg_t rc;
     679        errno_t rc;
    682680        async_wait_for(msg, &rc);
    683681       
     
    687685}
    688686
    689 static int vfs_truncate_internal(fs_handle_t fs_handle, service_id_t service_id,
     687static errno_t vfs_truncate_internal(fs_handle_t fs_handle, service_id_t service_id,
    690688    fs_index_t index, aoff64_t size)
    691689{
    692690        async_exch_t *exch = vfs_exchange_grab(fs_handle);
    693         sysarg_t rc = async_req_4_0(exch, VFS_OUT_TRUNCATE,
     691        errno_t rc = async_req_4_0(exch, VFS_OUT_TRUNCATE,
    694692            (sysarg_t) service_id, (sysarg_t) index, LOWER32(size),
    695693            UPPER32(size));
    696694        vfs_exchange_release(exch);
    697695       
    698         return (int) rc;
    699 }
    700 
    701 int vfs_op_unlink(int parentfd, int expectfd, char *path)
    702 {
    703         int rc = EOK;
     696        return (errno_t) rc;
     697}
     698
     699errno_t vfs_op_unlink(int parentfd, int expectfd, char *path)
     700{
     701        errno_t rc = EOK;
    704702        vfs_file_t *parent = NULL;
    705703        vfs_file_t *expect = NULL;
     
    780778}
    781779
    782 int vfs_op_unmount(int mpfd)
     780errno_t vfs_op_unmount(int mpfd)
    783781{
    784782        vfs_file_t *mp = vfs_file_get(mpfd);
     
    808806       
    809807        async_exch_t *exch = vfs_exchange_grab(mp->node->mount->fs_handle);
    810         int rc = async_req_1_0(exch, VFS_OUT_UNMOUNTED,
     808        errno_t rc = async_req_1_0(exch, VFS_OUT_UNMOUNTED,
    811809            mp->node->mount->service_id);
    812810        vfs_exchange_release(exch);
     
    828826}
    829827
    830 int vfs_op_wait_handle(bool high_fd)
    831 {
    832         return vfs_wait_handle_internal(high_fd);
     828errno_t vfs_op_wait_handle(bool high_fd, int *out_fd)
     829{
     830        return vfs_wait_handle_internal(high_fd, out_fd);
    833831}
    834832
     
    864862}
    865863
    866 int vfs_op_walk(int parentfd, int flags, char *path, int *out_fd)
     864errno_t vfs_op_walk(int parentfd, int flags, char *path, int *out_fd)
    867865{
    868866        if (!walk_flags_valid(flags))
     
    876874       
    877875        vfs_lookup_res_t lr;
    878         int rc = vfs_lookup_internal(parent->node, path,
     876        errno_t rc = vfs_lookup_internal(parent->node, path,
    879877            walk_lookup_flags(flags), &lr);
    880878        if (rc != EOK) {
     
    892890       
    893891        vfs_file_t *file;
    894         int fd = vfs_fd_alloc(&file, false);
    895         if (fd < 0) {
     892        rc = vfs_fd_alloc(&file, false, out_fd);
     893        if (rc != EOK) {
    896894                vfs_node_put(node);
    897895                vfs_file_put(parent);
    898                 return fd;
     896                return rc;
    899897        }
    900898        assert(file != NULL);
     
    910908        fibril_rwlock_read_unlock(&namespace_rwlock);
    911909
    912         *out_fd = fd;
    913910        return EOK;
    914911}
    915912
    916 int vfs_op_write(int fd, aoff64_t pos, size_t *out_bytes)
     913errno_t vfs_op_write(int fd, aoff64_t pos, size_t *out_bytes)
    917914{
    918915        return vfs_rdwr(fd, pos, false, rdwr_ipc_client, out_bytes);
Note: See TracChangeset for help on using the changeset viewer.