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