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