Changes in uspace/srv/vfs/vfs_ops.c [40feeac:b7fd2a0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_ops.c
r40feeac rb7fd2a0 52 52 53 53 /* Forward declarations of static functions. */ 54 static int vfs_truncate_internal(fs_handle_t, service_id_t, fs_index_t,54 static errno_t vfs_truncate_internal(fs_handle_t, service_id_t, fs_index_t, 55 55 aoff64_t); 56 56 … … 86 86 } 87 87 88 int vfs_op_clone(int oldfd, int newfd, bool desc)89 { 90 int rc;88 errno_t vfs_op_clone(int oldfd, int newfd, bool desc, int *out_fd) 89 { 90 errno_t rc; 91 91 92 92 /* If the file descriptors are the same, do nothing. */ … … 104 104 /* Assign the old file to newfd. */ 105 105 rc = vfs_fd_assign(oldfile, newfd); 106 *out_fd = newfd; 106 107 } else { 107 108 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) { 110 111 newfile->node = oldfile->node; 111 112 newfile->permissions = oldfile->permissions; … … 114 115 vfs_file_put(newfile); 115 116 } 116 rc = newfd;117 117 } 118 118 vfs_file_put(oldfile); … … 121 121 } 122 122 123 int vfs_op_put(int fd)123 errno_t vfs_op_put(int fd) 124 124 { 125 125 return vfs_fd_free(fd); 126 126 } 127 127 128 static int vfs_connect_internal(service_id_t service_id, unsigned flags,128 static errno_t vfs_connect_internal(service_id_t service_id, unsigned flags, 129 129 unsigned instance, const char *options, const char *fsname, 130 130 vfs_node_t **root) … … 152 152 &answer); 153 153 /* 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)); 155 155 if (rc != EOK) { 156 156 async_forget(msg); … … 188 188 } 189 189 190 int vfs_op_fsprobe(const char *fs_name, service_id_t sid,190 errno_t vfs_op_fsprobe(const char *fs_name, service_id_t sid, 191 191 vfs_fs_probe_info_t *info) 192 192 { 193 193 fs_handle_t fs_handle = 0; 194 sysarg_t rc;195 int retval;194 errno_t rc; 195 errno_t retval; 196 196 197 197 fibril_mutex_lock(&fs_list_lock); … … 222 222 } 223 223 224 int 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 int rc;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; 228 228 vfs_file_t *mp = NULL; 229 229 vfs_file_t *file = NULL; 230 intfd = -1;230 *out_fd = -1; 231 231 232 232 if (!(flags & VFS_MOUNT_CONNECT_ONLY)) { … … 254 254 255 255 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) { 259 258 goto out; 260 259 } … … 295 294 vfs_file_put(file); 296 295 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 303 301 return rc; 304 302 } 305 303 306 int vfs_op_open(int fd, int mode)304 errno_t vfs_op_open(int fd, int mode) 307 305 { 308 306 if (mode == 0) … … 338 336 } 339 337 340 int rc = vfs_open_node_remote(file->node);338 errno_t rc = vfs_open_node_remote(file->node); 341 339 if (rc != EOK) { 342 340 file->open_read = file->open_write = false; … … 349 347 } 350 348 351 typedef int (* rdwr_ipc_cb_t)(async_exch_t *, vfs_file_t *, aoff64_t,349 typedef errno_t (* rdwr_ipc_cb_t)(async_exch_t *, vfs_file_t *, aoff64_t, 352 350 ipc_call_t *, bool, void *); 353 351 354 static int rdwr_ipc_client(async_exch_t *exch, vfs_file_t *file, aoff64_t pos,352 static errno_t rdwr_ipc_client(async_exch_t *exch, vfs_file_t *file, aoff64_t pos, 355 353 ipc_call_t *answer, bool read, void *data) 356 354 { 357 355 size_t *bytes = (size_t *) data; 358 int rc;356 errno_t rc; 359 357 360 358 /* … … 380 378 } 381 379 382 static int rdwr_ipc_internal(async_exch_t *exch, vfs_file_t *file, aoff64_t pos,380 static errno_t rdwr_ipc_internal(async_exch_t *exch, vfs_file_t *file, aoff64_t pos, 383 381 ipc_call_t *answer, bool read, void *data) 384 382 { … … 394 392 return EINVAL; 395 393 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); 397 395 if (retval != EOK) { 398 396 async_forget(msg); … … 400 398 } 401 399 402 sysarg_t rc;400 errno_t rc; 403 401 async_wait_for(msg, &rc); 404 402 405 403 chunk->size = IPC_GET_ARG1(*answer); 406 404 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 408 static errno_t vfs_rdwr(int fd, aoff64_t pos, bool read, rdwr_ipc_cb_t ipc_cb, 411 409 void *ipc_cb_data) 412 410 { … … 477 475 */ 478 476 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); 480 478 481 479 vfs_exchange_release(fs_exch); … … 501 499 } 502 500 503 int vfs_rdwr_internal(int fd, aoff64_t pos, bool read, rdwr_io_chunk_t *chunk)501 errno_t vfs_rdwr_internal(int fd, aoff64_t pos, bool read, rdwr_io_chunk_t *chunk) 504 502 { 505 503 return vfs_rdwr(fd, pos, read, rdwr_ipc_internal, chunk); 506 504 } 507 505 508 int vfs_op_read(int fd, aoff64_t pos, size_t *out_bytes)506 errno_t vfs_op_read(int fd, aoff64_t pos, size_t *out_bytes) 509 507 { 510 508 return vfs_rdwr(fd, pos, true, rdwr_ipc_client, out_bytes); 511 509 } 512 510 513 int vfs_op_rename(int basefd, char *old, char *new)511 errno_t vfs_op_rename(int basefd, char *old, char *new) 514 512 { 515 513 vfs_file_t *base_file = vfs_file_get(basefd); … … 526 524 bool orig_unlinked = false; 527 525 528 int rc;526 errno_t rc; 529 527 530 528 size_t shared = shared_path(old, new); … … 612 610 } 613 611 614 int vfs_op_resize(int fd, int64_t size)612 errno_t vfs_op_resize(int fd, int64_t size) 615 613 { 616 614 vfs_file_t *file = vfs_file_get(fd); … … 620 618 fibril_rwlock_write_lock(&file->node->contents_rwlock); 621 619 622 int rc = vfs_truncate_internal(file->node->fs_handle,620 errno_t rc = vfs_truncate_internal(file->node->fs_handle, 623 621 file->node->service_id, file->node->index, size); 624 622 if (rc == EOK) … … 630 628 } 631 629 632 int vfs_op_stat(int fd)630 errno_t vfs_op_stat(int fd) 633 631 { 634 632 vfs_file_t *file = vfs_file_get(fd); … … 639 637 640 638 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, 642 640 node->service_id, node->index, true, 0, NULL); 643 641 vfs_exchange_release(exch); … … 647 645 } 648 646 649 int vfs_op_statfs(int fd)647 errno_t vfs_op_statfs(int fd) 650 648 { 651 649 vfs_file_t *file = vfs_file_get(fd); … … 656 654 657 655 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, 659 657 node->service_id, node->index, false, 0, NULL); 660 658 vfs_exchange_release(exch); … … 664 662 } 665 663 666 int vfs_op_sync(int fd)664 errno_t vfs_op_sync(int fd) 667 665 { 668 666 vfs_file_t *file = vfs_file_get(fd); … … 679 677 vfs_exchange_release(fs_exch); 680 678 681 sysarg_t rc;679 errno_t rc; 682 680 async_wait_for(msg, &rc); 683 681 … … 687 685 } 688 686 689 static int vfs_truncate_internal(fs_handle_t fs_handle, service_id_t service_id,687 static errno_t vfs_truncate_internal(fs_handle_t fs_handle, service_id_t service_id, 690 688 fs_index_t index, aoff64_t size) 691 689 { 692 690 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, 694 692 (sysarg_t) service_id, (sysarg_t) index, LOWER32(size), 695 693 UPPER32(size)); 696 694 vfs_exchange_release(exch); 697 695 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 699 errno_t vfs_op_unlink(int parentfd, int expectfd, char *path) 700 { 701 errno_t rc = EOK; 704 702 vfs_file_t *parent = NULL; 705 703 vfs_file_t *expect = NULL; … … 780 778 } 781 779 782 int vfs_op_unmount(int mpfd)780 errno_t vfs_op_unmount(int mpfd) 783 781 { 784 782 vfs_file_t *mp = vfs_file_get(mpfd); … … 808 806 809 807 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, 811 809 mp->node->mount->service_id); 812 810 vfs_exchange_release(exch); … … 828 826 } 829 827 830 int vfs_op_wait_handle(bool high_fd)831 { 832 return vfs_wait_handle_internal(high_fd );828 errno_t vfs_op_wait_handle(bool high_fd, int *out_fd) 829 { 830 return vfs_wait_handle_internal(high_fd, out_fd); 833 831 } 834 832 … … 864 862 } 865 863 866 int vfs_op_walk(int parentfd, int flags, char *path, int *out_fd)864 errno_t vfs_op_walk(int parentfd, int flags, char *path, int *out_fd) 867 865 { 868 866 if (!walk_flags_valid(flags)) … … 876 874 877 875 vfs_lookup_res_t lr; 878 int rc = vfs_lookup_internal(parent->node, path,876 errno_t rc = vfs_lookup_internal(parent->node, path, 879 877 walk_lookup_flags(flags), &lr); 880 878 if (rc != EOK) { … … 892 890 893 891 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) { 896 894 vfs_node_put(node); 897 895 vfs_file_put(parent); 898 return fd;896 return rc; 899 897 } 900 898 assert(file != NULL); … … 910 908 fibril_rwlock_read_unlock(&namespace_rwlock); 911 909 912 *out_fd = fd;913 910 return EOK; 914 911 } 915 912 916 int vfs_op_write(int fd, aoff64_t pos, size_t *out_bytes)913 errno_t vfs_op_write(int fd, aoff64_t pos, size_t *out_bytes) 917 914 { 918 915 return vfs_rdwr(fd, pos, false, rdwr_ipc_client, out_bytes);
Note:
See TracChangeset
for help on using the changeset viewer.