Changes in uspace/lib/c/generic/vfs/vfs.c [8e3498b:39330200] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/vfs/vfs.c
r8e3498b r39330200 86 86 * and consume system resources. 87 87 * 88 * Functions that return int return an error code on error and do not88 * Functions that return errno_t return an error code on error and do not 89 89 * set errno. Depending on function, success is signalled by returning either 90 90 * EOK or a non-negative file handle. … … 97 97 * if (file < 0) 98 98 * return file; 99 * int rc = vfs_open(file, MODE_READ);99 * errno_t rc = vfs_open(file, MODE_READ); 100 100 * if (rc != EOK) { 101 101 * (void) vfs_put(file); … … 128 128 static int root_fd = -1; 129 129 130 static int get_parent_and_child(const char *path, char **child)130 static errno_t get_parent_and_child(const char *path, int *parent, char **child) 131 131 { 132 132 size_t size; … … 136 136 137 137 char *slash = str_rchr(apath, L'/'); 138 int parent;139 138 if (slash == apath) { 140 parent = vfs_root(); 139 *parent = vfs_root(); 140 if (*parent < 0) { 141 free(apath); 142 return EBADF; 143 } 141 144 *child = apath; 145 return EOK; 142 146 } else { 143 147 *slash = '\0'; 144 parent = vfs_lookup(apath, WALK_DIRECTORY);145 if ( parent < 0) {148 errno_t rc = vfs_lookup(apath, WALK_DIRECTORY, parent); 149 if (rc != EOK) { 146 150 free(apath); 147 return parent;151 return rc; 148 152 } 149 153 *slash = '/'; … … 151 155 free(apath); 152 156 if (!*child) { 153 vfs_put( parent);157 vfs_put(*parent); 154 158 return ENOMEM; 155 159 } 156 } 157 158 return parent; 160 161 return rc; 162 } 163 159 164 } 160 165 … … 231 236 * handle will be allocated from high indices 232 237 * 233 * @return New file handle on success or a negative error code 234 */ 235 int vfs_clone(int file_from, int file_to, bool high) 236 { 238 * @return New file handle on success or an error code 239 */ 240 errno_t vfs_clone(int file_from, int file_to, bool high, int *handle) 241 { 242 assert(handle != NULL); 243 237 244 async_exch_t *vfs_exch = vfs_exchange_begin(); 238 int rc = async_req_3_0(vfs_exch, VFS_IN_CLONE, (sysarg_t) file_from, 239 (sysarg_t) file_to, (sysarg_t) high); 245 sysarg_t ret; 246 errno_t rc = async_req_3_1(vfs_exch, VFS_IN_CLONE, (sysarg_t) file_from, 247 (sysarg_t) file_to, (sysarg_t) high, &ret); 240 248 vfs_exchange_end(vfs_exch); 249 250 if (rc == EOK) { 251 *handle = ret; 252 } 241 253 return rc; 242 254 } … … 247 259 * @param size Size of @a buf 248 260 * 249 * @return EOK on success or a non- negativeerror code250 */ 251 int vfs_cwd_get(char *buf, size_t size)261 * @return EOK on success or a non-error code 262 */ 263 errno_t vfs_cwd_get(char *buf, size_t size) 252 264 { 253 265 fibril_mutex_lock(&cwd_mutex); … … 268 280 * @param path Path of the new working directory 269 281 * 270 * @return EOK on success or a negativeerror code271 */ 272 int vfs_cwd_set(const char *path)282 * @return EOK on success or an error code 283 */ 284 errno_t vfs_cwd_set(const char *path) 273 285 { 274 286 size_t abs_size; … … 277 289 return ENOMEM; 278 290 279 int fd = vfs_lookup(abs, WALK_DIRECTORY); 280 if (fd < 0) { 291 int fd; 292 errno_t rc = vfs_lookup(abs, WALK_DIRECTORY, &fd); 293 if (rc != EOK) { 281 294 free(abs); 282 return fd;295 return rc; 283 296 } 284 297 … … 339 352 async_sess_t *vfs_fd_session(int file, iface_t iface) 340 353 { 341 struct stat stat;342 int rc = vfs_stat(file, &stat);343 if (rc != 0)354 vfs_stat_t stat; 355 errno_t rc = vfs_stat(file, &stat); 356 if (rc != EOK) 344 357 return NULL; 345 358 … … 357 370 * @param info Place to store volume identification information 358 371 * 359 * @return EOK on success or a negativeerror code360 */ 361 int vfs_fsprobe(const char *fs_name, service_id_t serv,372 * @return EOK on success or an error code 373 */ 374 errno_t vfs_fsprobe(const char *fs_name, service_id_t serv, 362 375 vfs_fs_probe_info_t *info) 363 376 { 364 sysarg_t rc;377 errno_t rc; 365 378 366 379 ipc_call_t answer; … … 391 404 * fstypes->fstypes[0..]. To free the list use vfs_fstypes_free(). 392 405 * 393 * @return EOK on success or a negativeerror code394 */ 395 int vfs_fstypes(vfs_fstypes_t *fstypes)406 * @return EOK on success or an error code 407 */ 408 errno_t vfs_fstypes(vfs_fstypes_t *fstypes) 396 409 { 397 410 sysarg_t size; … … 401 414 402 415 async_exch_t *exch = vfs_exchange_begin(); 403 int rc = async_req_0_1(exch, VFS_IN_FSTYPES, &size);416 errno_t rc = async_req_0_1(exch, VFS_IN_FSTYPES, &size); 404 417 405 418 if (rc != EOK) { … … 486 499 * @param[out] linkedfd If not NULL, will receive a file handle to the linked 487 500 * child 488 * @return EOK on success or a negativeerror code489 */ 490 int vfs_link(int parent, const char *child, vfs_file_kind_t kind, int *linkedfd)501 * @return EOK on success or an error code 502 */ 503 errno_t vfs_link(int parent, const char *child, vfs_file_kind_t kind, int *linkedfd) 491 504 { 492 505 int flags = (kind == KIND_DIRECTORY) ? WALK_DIRECTORY : WALK_REGULAR; 493 int file = vfs_walk(parent, child, WALK_MUST_CREATE | flags);494 495 if ( file < 0)496 return file;506 int file = -1; 507 errno_t rc = vfs_walk(parent, child, WALK_MUST_CREATE | flags, &file); 508 if (rc != EOK) 509 return rc; 497 510 498 511 if (linkedfd) … … 516 529 * @param[out] linkedfd If not NULL, will receive a file handle to the linked 517 530 * child 518 * @return EOK on success or a negativeerror code519 */ 520 int vfs_link_path(const char *path, vfs_file_kind_t kind, int *linkedfd)531 * @return EOK on success or an error code 532 */ 533 errno_t vfs_link_path(const char *path, vfs_file_kind_t kind, int *linkedfd) 521 534 { 522 535 char *child; 523 int parent = get_parent_and_child(path, &child); 524 if (parent < 0) 525 return parent; 526 527 int rc = vfs_link(parent, child, kind, linkedfd); 536 int parent; 537 errno_t rc = get_parent_and_child(path, &parent, &child); 538 if (rc != EOK) 539 return rc; 540 541 rc = vfs_link(parent, child, kind, linkedfd); 528 542 529 543 free(child); 530 544 vfs_put(parent); 531 545 return rc; 532 } 546 } 533 547 534 548 /** Lookup a path relative to the local root … … 536 550 * @param path Path to be looked up 537 551 * @param flags Walk flags 538 * 539 * @return File handle representing the result on success or a negative540 * error code on error541 */ 542 int vfs_lookup(const char *path, int flags)552 * @param[out] handle Pointer to variable where handle is to be written. 553 * 554 * @return EOK on success or an error code. 555 */ 556 errno_t vfs_lookup(const char *path, int flags, int *handle) 543 557 { 544 558 size_t size; … … 546 560 if (!p) 547 561 return ENOMEM; 562 548 563 int root = vfs_root(); 549 564 if (root < 0) { … … 551 566 return ENOENT; 552 567 } 553 int rc = vfs_walk(root, p, flags); 568 569 // XXX: Workaround for GCC diagnostics. 570 *handle = -1; 571 572 errno_t rc = vfs_walk(root, p, flags, handle); 554 573 vfs_put(root); 555 574 free(p); … … 564 583 * @param flags Walk flags 565 584 * @param mode Mode in which to open file in 566 * 567 * @return EOK on success or a negative error code 568 */ 569 int vfs_lookup_open(const char *path, int flags, int mode) 570 { 571 int file = vfs_lookup(path, flags); 572 if (file < 0) 573 return file; 574 575 int rc = vfs_open(file, mode); 585 * @param[out] handle Pointer to variable where handle is to be written. 586 * 587 * @return EOK on success or an error code 588 */ 589 errno_t vfs_lookup_open(const char *path, int flags, int mode, int *handle) 590 { 591 int file; 592 errno_t rc = vfs_lookup(path, flags, &file); 593 if (rc != EOK) 594 return rc; 595 596 rc = vfs_open(file, mode); 576 597 if (rc != EOK) { 577 598 vfs_put(file); 578 599 return rc; 579 600 } 580 581 return file; 601 602 *handle = file; 603 return EOK; 582 604 } 583 605 … … 592 614 * @param[out] mountedfd File handle of the mounted root if not NULL 593 615 * 594 * @return EOK on success or a negativeerror code595 */ 596 int vfs_mount(int mp, const char *fs_name, service_id_t serv, const char *opts,616 * @return EOK on success or an error code 617 */ 618 errno_t vfs_mount(int mp, const char *fs_name, service_id_t serv, const char *opts, 597 619 unsigned int flags, unsigned int instance, int *mountedfd) 598 620 { 599 sysarg_t rc, rc1;621 errno_t rc, rc1; 600 622 601 623 if (!mountedfd) … … 636 658 * @param[in] instance Instance number of the file system server 637 659 * 638 * @return EOK on success or a negativeerror code639 */ 640 int vfs_mount_path(const char *mp, const char *fs_name, const char *fqsn,660 * @return EOK on success or an error code 661 */ 662 errno_t vfs_mount_path(const char *mp, const char *fs_name, const char *fqsn, 641 663 const char *opts, unsigned int flags, unsigned int instance) 642 664 { … … 663 685 664 686 service_id_t service_id; 665 int res = loc_service_get_id(fqsn, &service_id, flags);687 errno_t res = loc_service_get_id(fqsn, &service_id, flags); 666 688 if (res != EOK) { 667 689 if (null_id != -1) … … 682 704 fibril_mutex_lock(&root_mutex); 683 705 684 int rc;706 errno_t rc; 685 707 686 708 if (str_cmp(mpa, "/") == 0) { … … 707 729 } 708 730 709 int mpfd = vfs_walk(root_fd, mpa, WALK_DIRECTORY); 710 if (mpfd >= 0) { 731 int mpfd; 732 rc = vfs_walk(root_fd, mpa, WALK_DIRECTORY, &mpfd); 733 if (rc == EOK) { 711 734 rc = vfs_mount(mpfd, fs_name, service_id, opts, flags, 712 735 instance, NULL); 713 736 vfs_put(mpfd); 714 } else {715 rc = mpfd;716 737 } 717 738 } … … 722 743 loc_null_destroy(null_id); 723 744 724 return ( int) rc;745 return (errno_t) rc; 725 746 } 726 747 … … 731 752 * @param mode Mode in which to open file in 732 753 * 733 * @return EOK on success or a negativeerror code734 */ 735 int vfs_open(int file, int mode)736 { 737 async_exch_t *exch = vfs_exchange_begin(); 738 int rc = async_req_2_0(exch, VFS_IN_OPEN, file, mode);754 * @return EOK on success or an error code 755 */ 756 errno_t vfs_open(int file, int mode) 757 { 758 async_exch_t *exch = vfs_exchange_begin(); 759 errno_t rc = async_req_2_0(exch, VFS_IN_OPEN, file, mode); 739 760 vfs_exchange_end(exch); 740 761 … … 748 769 * @param exch Exchange to the acceptor 749 770 * 750 * @return EOK on success or a negativeerror code751 */ 752 int vfs_pass_handle(async_exch_t *vfs_exch, int file, async_exch_t *exch)771 * @return EOK on success or an error code 772 */ 773 errno_t vfs_pass_handle(async_exch_t *vfs_exch, int file, async_exch_t *exch) 753 774 { 754 775 return async_state_change_start(exch, VFS_PASS_HANDLE, (sysarg_t) file, … … 760 781 * @param file File handle to put 761 782 * 762 * @return EOK on success or a negativeerror code763 */ 764 int vfs_put(int file)765 { 766 async_exch_t *exch = vfs_exchange_begin(); 767 int rc = async_req_1_0(exch, VFS_IN_PUT, file);783 * @return EOK on success or an error code 784 */ 785 errno_t vfs_put(int file) 786 { 787 async_exch_t *exch = vfs_exchange_begin(); 788 errno_t rc = async_req_1_0(exch, VFS_IN_PUT, file); 768 789 vfs_exchange_end(exch); 769 790 … … 775 796 * @param high If true, the received file handle will be allocated from high 776 797 * indices 777 * 778 * @return EOK on success or a negative error code 779 */ 780 int vfs_receive_handle(bool high) 798 * @param[out] handle Received handle. 799 * 800 * @return EOK on success or an error code 801 */ 802 errno_t vfs_receive_handle(bool high, int *handle) 781 803 { 782 804 ipc_callid_t callid; … … 791 813 792 814 sysarg_t ret; 793 sysarg_t rc = async_req_1_1(vfs_exch, VFS_IN_WAIT_HANDLE, high, &ret);815 errno_t rc = async_req_1_1(vfs_exch, VFS_IN_WAIT_HANDLE, high, &ret); 794 816 795 817 async_exchange_end(vfs_exch); 796 818 797 if (rc != EOK) 798 return rc; 799 return ret; 819 if (rc == EOK) { 820 *handle = (int) ret; 821 } 822 823 return rc; 800 824 } 801 825 … … 815 839 * @return On failure, an error code 816 840 */ 817 int vfs_read(int file, aoff64_t *pos, void *buf, size_t nbyte, size_t *nread)841 errno_t vfs_read(int file, aoff64_t *pos, void *buf, size_t nbyte, size_t *nread) 818 842 { 819 843 ssize_t cnt = 0; 820 844 size_t nr = 0; 821 845 uint8_t *bp = (uint8_t *) buf; 822 int rc;846 errno_t rc; 823 847 824 848 do { … … 853 877 * @param[out] nread Actual number of bytes read (0 or more) 854 878 * 855 * @return EOK on success or a negativeerror code856 */ 857 int vfs_read_short(int file, aoff64_t pos, void *buf, size_t nbyte,879 * @return EOK on success or an error code 880 */ 881 errno_t vfs_read_short(int file, aoff64_t pos, void *buf, size_t nbyte, 858 882 ssize_t *nread) 859 883 { 860 sysarg_t rc;884 errno_t rc; 861 885 ipc_call_t answer; 862 886 aid_t req; … … 895 919 * @param new New path 896 920 * 897 * @return EOK on success or a negativeerror code898 */ 899 int vfs_rename_path(const char *old, const char *new)900 { 901 sysarg_t rc;902 sysarg_t rc_orig;921 * @return EOK on success or an error code 922 */ 923 errno_t vfs_rename_path(const char *old, const char *new) 924 { 925 errno_t rc; 926 errno_t rc_orig; 903 927 aid_t req; 904 928 … … 962 986 * @param length New length 963 987 * 964 * @return EOK on success or a negativeerror code965 */ 966 int vfs_resize(int file, aoff64_t length)967 { 968 async_exch_t *exch = vfs_exchange_begin(); 969 int rc = async_req_3_0(exch, VFS_IN_RESIZE, file, LOWER32(length),988 * @return EOK on success or an error code 989 */ 990 errno_t vfs_resize(int file, aoff64_t length) 991 { 992 async_exch_t *exch = vfs_exchange_begin(); 993 errno_t rc = async_req_3_0(exch, VFS_IN_RESIZE, file, LOWER32(length), 970 994 UPPER32(length)); 971 995 vfs_exchange_end(exch); … … 976 1000 /** Return a new file handle representing the local root 977 1001 * 978 * @return A clone of the local root file handle or a negative error code1002 * @return A clone of the local root file handle or -1 979 1003 */ 980 1004 int vfs_root(void) 981 1005 { 982 fibril_mutex_lock(&root_mutex); 983 int r; 984 if (root_fd < 0) 985 r = ENOENT; 986 else 987 r = vfs_clone(root_fd, -1, true); 1006 fibril_mutex_lock(&root_mutex); 1007 int fd; 1008 if (root_fd < 0) { 1009 fd = -1; 1010 } else { 1011 errno_t rc = vfs_clone(root_fd, -1, true, &fd); 1012 if (rc != EOK) { 1013 fd = -1; 1014 } 1015 } 988 1016 fibril_mutex_unlock(&root_mutex); 989 return r;1017 return fd; 990 1018 } 991 1019 … … 997 1025 * 998 1026 * @param nroot The new local root file handle 999 */ 1000 void vfs_root_set(int nroot) 1001 { 1027 * 1028 * @return Error code 1029 */ 1030 errno_t vfs_root_set(int nroot) 1031 { 1032 int new_root; 1033 errno_t rc = vfs_clone(nroot, -1, true, &new_root); 1034 if (rc != EOK) { 1035 return rc; 1036 } 1037 1002 1038 fibril_mutex_lock(&root_mutex); 1003 1039 if (root_fd >= 0) 1004 1040 vfs_put(root_fd); 1005 root_fd = vfs_clone(nroot, -1, true);1041 root_fd = new_root; 1006 1042 fibril_mutex_unlock(&root_mutex); 1043 1044 return EOK; 1007 1045 } 1008 1046 … … 1012 1050 * @param[out] stat Place to store file information 1013 1051 * 1014 * @return EOK on success or a negativeerror code1015 */ 1016 int vfs_stat(int file, struct stat *stat)1017 { 1018 sysarg_t rc;1052 * @return EOK on success or an error code 1053 */ 1054 errno_t vfs_stat(int file, vfs_stat_t *stat) 1055 { 1056 errno_t rc; 1019 1057 aid_t req; 1020 1058 … … 1022 1060 1023 1061 req = async_send_1(exch, VFS_IN_STAT, file, NULL); 1024 rc = async_data_read_start(exch, (void *) stat, sizeof( struct stat));1062 rc = async_data_read_start(exch, (void *) stat, sizeof(vfs_stat_t)); 1025 1063 if (rc != EOK) { 1026 1064 vfs_exchange_end(exch); 1027 1065 1028 sysarg_t rc_orig;1066 errno_t rc_orig; 1029 1067 async_wait_for(req, &rc_orig); 1030 1068 … … 1046 1084 * @param[out] stat Place to store file information 1047 1085 * 1048 * @return EOK on success or a negative error code 1049 */ 1050 int vfs_stat_path(const char *path, struct stat *stat) 1051 { 1052 int file = vfs_lookup(path, 0); 1053 if (file < 0) 1054 return file; 1055 1056 int rc = vfs_stat(file, stat); 1086 * @return EOK on success or an error code 1087 */ 1088 errno_t vfs_stat_path(const char *path, vfs_stat_t *stat) 1089 { 1090 int file; 1091 errno_t rc = vfs_lookup(path, 0, &file); 1092 if (rc != EOK) 1093 return rc; 1094 1095 rc = vfs_stat(file, stat); 1057 1096 1058 1097 vfs_put(file); … … 1066 1105 * @param[out] st Buffer for storing information 1067 1106 * 1068 * @return EOK on success or a negativeerror code1069 */ 1070 int vfs_statfs(int file, struct statfs*st)1071 { 1072 sysarg_t rc, ret;1107 * @return EOK on success or an error code 1108 */ 1109 errno_t vfs_statfs(int file, vfs_statfs_t *st) 1110 { 1111 errno_t rc, ret; 1073 1112 aid_t req; 1074 1113 … … 1091 1130 * @param[out] st Buffer for storing information 1092 1131 * 1093 * @return EOK on success or a negative error code 1094 */ 1095 int vfs_statfs_path(const char *path, struct statfs *st) 1096 { 1097 int file = vfs_lookup(path, 0); 1098 if (file < 0) 1099 return file; 1100 1101 int rc = vfs_statfs(file, st); 1132 * @return EOK on success or an error code 1133 */ 1134 errno_t vfs_statfs_path(const char *path, vfs_statfs_t *st) 1135 { 1136 int file; 1137 errno_t rc = vfs_lookup(path, 0, &file); 1138 if (rc != EOK) 1139 return rc; 1140 1141 rc = vfs_statfs(file, st); 1102 1142 1103 1143 vfs_put(file); … … 1110 1150 * @param file File handle to synchronize 1111 1151 * 1112 * @return EOK on success or a negativeerror code1113 */ 1114 int vfs_sync(int file)1115 { 1116 async_exch_t *exch = vfs_exchange_begin(); 1117 int rc = async_req_1_0(exch, VFS_IN_SYNC, file);1152 * @return EOK on success or an error code 1153 */ 1154 errno_t vfs_sync(int file) 1155 { 1156 async_exch_t *exch = vfs_exchange_begin(); 1157 errno_t rc = async_req_1_0(exch, VFS_IN_SYNC, file); 1118 1158 vfs_exchange_end(exch); 1119 1159 … … 1132 1172 * @param expect File handle of the unlinked child 1133 1173 * 1134 * @return EOK on success or a negativeerror code1135 */ 1136 int vfs_unlink(int parent, const char *child, int expect)1137 { 1138 sysarg_t rc;1174 * @return EOK on success or an error code 1175 */ 1176 errno_t vfs_unlink(int parent, const char *child, int expect) 1177 { 1178 errno_t rc; 1139 1179 aid_t req; 1140 1180 … … 1146 1186 vfs_exchange_end(exch); 1147 1187 1148 sysarg_t rc_orig;1188 errno_t rc_orig; 1149 1189 async_wait_for(req, &rc_orig); 1150 1190 1151 1191 if (rc_orig != EOK) 1152 return ( int) rc_orig;1192 return (errno_t) rc_orig; 1153 1193 return rc; 1154 1194 } … … 1161 1201 * @param path Old path to be unlinked 1162 1202 * 1163 * @return EOK on success or a negative error code 1164 */ 1165 int vfs_unlink_path(const char *path) 1166 { 1167 int expect = vfs_lookup(path, 0); 1168 if (expect < 0) 1169 return expect; 1203 * @return EOK on success or an error code 1204 */ 1205 errno_t vfs_unlink_path(const char *path) 1206 { 1207 int expect; 1208 errno_t rc = vfs_lookup(path, 0, &expect); 1209 if (rc != EOK) 1210 return rc; 1170 1211 1171 1212 char *child; 1172 int parent = get_parent_and_child(path, &child); 1173 if (parent < 0) { 1213 int parent; 1214 rc = get_parent_and_child(path, &parent, &child); 1215 if (rc != EOK) { 1174 1216 vfs_put(expect); 1175 return parent;1176 } 1177 1178 intrc = vfs_unlink(parent, child, expect);1217 return rc; 1218 } 1219 1220 rc = vfs_unlink(parent, child, expect); 1179 1221 1180 1222 free(child); … … 1188 1230 * @param mp File handle representing the mount-point 1189 1231 * 1190 * @return EOK on success or a negativeerror code1191 */ 1192 int vfs_unmount(int mp)1193 { 1194 async_exch_t *exch = vfs_exchange_begin(); 1195 int rc = async_req_1_0(exch, VFS_IN_UNMOUNT, mp);1232 * @return EOK on success or an error code 1233 */ 1234 errno_t vfs_unmount(int mp) 1235 { 1236 async_exch_t *exch = vfs_exchange_begin(); 1237 errno_t rc = async_req_1_0(exch, VFS_IN_UNMOUNT, mp); 1196 1238 vfs_exchange_end(exch); 1197 1239 return rc; … … 1202 1244 * @param mpp Mount-point path 1203 1245 * 1204 * @return EOK on success or a negative error code 1205 */ 1206 int vfs_unmount_path(const char *mpp) 1207 { 1208 int mp = vfs_lookup(mpp, WALK_MOUNT_POINT | WALK_DIRECTORY); 1209 if (mp < 0) 1210 return mp; 1211 1212 int rc = vfs_unmount(mp); 1246 * @return EOK on success or an error code 1247 */ 1248 errno_t vfs_unmount_path(const char *mpp) 1249 { 1250 int mp; 1251 errno_t rc = vfs_lookup(mpp, WALK_MOUNT_POINT | WALK_DIRECTORY, &mp); 1252 if (rc != EOK) 1253 return rc; 1254 1255 rc = vfs_unmount(mp); 1213 1256 vfs_put(mp); 1214 1257 return rc; … … 1220 1263 * @param path Parent-relative path to be walked 1221 1264 * @param flags Flags influencing the walk 1222 * 1223 * @retrun File handle representing the result on success or1224 * a negative error code on error1225 */ 1226 int vfs_walk(int parent, const char *path, int flags)1265 * @param[out] handle File handle representing the result on success. 1266 * 1267 * @return Error code. 1268 */ 1269 errno_t vfs_walk(int parent, const char *path, int flags, int *handle) 1227 1270 { 1228 1271 async_exch_t *exch = vfs_exchange_begin(); … … 1230 1273 ipc_call_t answer; 1231 1274 aid_t req = async_send_2(exch, VFS_IN_WALK, parent, flags, &answer); 1232 sysarg_t rc = async_data_write_start(exch, path, str_size(path));1275 errno_t rc = async_data_write_start(exch, path, str_size(path)); 1233 1276 vfs_exchange_end(exch); 1234 1277 1235 sysarg_t rc_orig;1278 errno_t rc_orig; 1236 1279 async_wait_for(req, &rc_orig); 1237 1280 1238 1281 if (rc_orig != EOK) 1239 return ( int) rc_orig;1282 return (errno_t) rc_orig; 1240 1283 1241 1284 if (rc != EOK) 1242 return (int) rc; 1243 1244 return (int) IPC_GET_ARG1(answer); 1285 return (errno_t) rc; 1286 1287 *handle = (int) IPC_GET_ARG1(answer); 1288 return EOK; 1245 1289 } 1246 1290 … … 1260 1304 * @return On failure, an error code 1261 1305 */ 1262 int vfs_write(int file, aoff64_t *pos, const void *buf, size_t nbyte,1306 errno_t vfs_write(int file, aoff64_t *pos, const void *buf, size_t nbyte, 1263 1307 size_t *nwritten) 1264 1308 { … … 1266 1310 ssize_t nwr = 0; 1267 1311 const uint8_t *bp = (uint8_t *) buf; 1268 int rc;1312 errno_t rc; 1269 1313 1270 1314 do { … … 1297 1341 * @param[out] nread Actual number of bytes written (0 or more) 1298 1342 * 1299 * @return EOK on success or a negativeerror code1300 */ 1301 int vfs_write_short(int file, aoff64_t pos, const void *buf, size_t nbyte,1343 * @return EOK on success or an error code 1344 */ 1345 errno_t vfs_write_short(int file, aoff64_t pos, const void *buf, size_t nbyte, 1302 1346 ssize_t *nwritten) 1303 1347 { 1304 sysarg_t rc;1348 errno_t rc; 1305 1349 ipc_call_t answer; 1306 1350 aid_t req;
Note:
See TracChangeset
for help on using the changeset viewer.