Changes in uspace/srv/vfs/vfs_ops.c [3a4b3ba:ffa2c8ef] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_ops.c
r3a4b3ba rffa2c8ef 37 37 38 38 #include "vfs.h" 39 #include <ipc/ipc.h>40 39 #include <macros.h> 41 40 #include <stdint.h> … … 79 78 size_t rsize; 80 79 unsigned rlnkcnt; 81 ipcarg_t rc;80 sysarg_t rc; 82 81 int phone; 83 82 aid_t msg; … … 91 90 /* Trying to mount root FS over root FS */ 92 91 fibril_rwlock_write_unlock(&namespace_rwlock); 93 ipc_answer_0(rid, EBUSY);92 async_answer_0(rid, EBUSY); 94 93 return; 95 94 } … … 99 98 /* The lookup failed for some reason. */ 100 99 fibril_rwlock_write_unlock(&namespace_rwlock); 101 ipc_answer_0(rid, rc);100 async_answer_0(rid, rc); 102 101 return; 103 102 } … … 106 105 if (!mp_node) { 107 106 fibril_rwlock_write_unlock(&namespace_rwlock); 108 ipc_answer_0(rid, ENOMEM);107 async_answer_0(rid, ENOMEM); 109 108 return; 110 109 } … … 126 125 phone = vfs_grab_phone(fs_handle); 127 126 msg = async_send_1(phone, VFS_OUT_MOUNTED, 128 ( ipcarg_t) devmap_handle, &answer);127 (sysarg_t) devmap_handle, &answer); 129 128 /* send the mount options */ 130 129 rc = async_data_write_start(phone, (void *)opts, … … 134 133 vfs_release_phone(fs_handle, phone); 135 134 fibril_rwlock_write_unlock(&namespace_rwlock); 136 ipc_answer_0(rid, rc);135 async_answer_0(rid, rc); 137 136 return; 138 137 } … … 142 141 if (rc != EOK) { 143 142 fibril_rwlock_write_unlock(&namespace_rwlock); 144 ipc_answer_0(rid, rc);143 async_answer_0(rid, rc); 145 144 return; 146 145 } … … 165 164 166 165 fibril_rwlock_write_unlock(&namespace_rwlock); 167 ipc_answer_0(rid, rc);166 async_answer_0(rid, rc); 168 167 return; 169 168 } else { … … 173 172 */ 174 173 fibril_rwlock_write_unlock(&namespace_rwlock); 175 ipc_answer_0(rid, ENOENT);174 async_answer_0(rid, ENOENT); 176 175 return; 177 176 } … … 188 187 phone = vfs_grab_phone(mp_res.triplet.fs_handle); 189 188 msg = async_send_4(phone, VFS_OUT_MOUNT, 190 ( ipcarg_t) mp_res.triplet.devmap_handle,191 ( ipcarg_t) mp_res.triplet.index,192 ( ipcarg_t) fs_handle,193 ( ipcarg_t) devmap_handle, &answer);189 (sysarg_t) mp_res.triplet.devmap_handle, 190 (sysarg_t) mp_res.triplet.index, 191 (sysarg_t) fs_handle, 192 (sysarg_t) devmap_handle, &answer); 194 193 195 194 /* send connection */ … … 202 201 if (mp_node) 203 202 vfs_node_put(mp_node); 204 ipc_answer_0(rid, rc);203 async_answer_0(rid, rc); 205 204 fibril_rwlock_write_unlock(&namespace_rwlock); 206 205 return; … … 218 217 vfs_node_put(mp_node); 219 218 fibril_rwlock_write_unlock(&namespace_rwlock); 220 ipc_answer_0(rid, rc);219 async_answer_0(rid, rc); 221 220 return; 222 221 } … … 245 244 } 246 245 247 ipc_answer_0(rid, rc);246 async_answer_0(rid, rc); 248 247 fibril_rwlock_write_unlock(&namespace_rwlock); 249 248 } … … 275 274 0, NULL); 276 275 if (rc != EOK) { 277 ipc_answer_0(rid, rc);276 async_answer_0(rid, rc); 278 277 return; 279 278 } … … 285 284 if (rc != EOK) { 286 285 free(mp); 287 ipc_answer_0(rid, rc);286 async_answer_0(rid, rc); 288 287 return; 289 288 } … … 299 298 free(mp); 300 299 free(opts); 301 ipc_answer_0(rid, rc);300 async_answer_0(rid, rc); 302 301 return; 303 302 } … … 309 308 ipc_call_t data; 310 309 ipc_callid_t callid = async_get_call(&data); 311 if (IPC_GET_ METHOD(data) != IPC_M_PING) {312 ipc_answer_0(callid, ENOTSUP);313 ipc_answer_0(rid, ENOTSUP);310 if (IPC_GET_IMETHOD(data) != IPC_M_PING) { 311 async_answer_0(callid, ENOTSUP); 312 async_answer_0(rid, ENOTSUP); 314 313 free(mp); 315 314 free(opts); … … 333 332 334 333 fibril_mutex_unlock(&fs_head_lock); 335 ipc_answer_0(callid, ENOENT);336 ipc_answer_0(rid, ENOENT);334 async_answer_0(callid, ENOENT); 335 async_answer_0(rid, ENOENT); 337 336 free(mp); 338 337 free(fs_name); … … 343 342 344 343 /* Acknowledge that we know fs_name. */ 345 ipc_answer_0(callid, EOK);344 async_answer_0(callid, EOK); 346 345 347 346 /* Do the mount */ … … 367 366 0, NULL); 368 367 if (rc != EOK) 369 ipc_answer_0(rid, rc);368 async_answer_0(rid, rc); 370 369 371 370 /* … … 386 385 fibril_rwlock_write_unlock(&namespace_rwlock); 387 386 free(mp); 388 ipc_answer_0(rid, rc);387 async_answer_0(rid, rc); 389 388 return; 390 389 } … … 393 392 fibril_rwlock_write_unlock(&namespace_rwlock); 394 393 free(mp); 395 ipc_answer_0(rid, ENOMEM);394 async_answer_0(rid, ENOMEM); 396 395 return; 397 396 } … … 409 408 vfs_node_put(mr_node); 410 409 free(mp); 411 ipc_answer_0(rid, EBUSY);410 async_answer_0(rid, EBUSY); 412 411 return; 413 412 } … … 430 429 fibril_rwlock_write_unlock(&namespace_rwlock); 431 430 vfs_node_put(mr_node); 432 ipc_answer_0(rid, rc);431 async_answer_0(rid, rc); 433 432 return; 434 433 } … … 449 448 fibril_rwlock_write_unlock(&namespace_rwlock); 450 449 vfs_node_put(mr_node); 451 ipc_answer_0(rid, rc);450 async_answer_0(rid, rc); 452 451 return; 453 452 } … … 456 455 fibril_rwlock_write_unlock(&namespace_rwlock); 457 456 vfs_node_put(mr_node); 458 ipc_answer_0(rid, ENOMEM);457 async_answer_0(rid, ENOMEM); 459 458 return; 460 459 } … … 468 467 vfs_node_put(mp_node); 469 468 vfs_node_put(mr_node); 470 ipc_answer_0(rid, rc);469 async_answer_0(rid, rc); 471 470 return; 472 471 } … … 486 485 487 486 fibril_rwlock_write_unlock(&namespace_rwlock); 488 ipc_answer_0(rid, EOK);487 async_answer_0(rid, EOK); 489 488 } 490 489 491 490 void vfs_open(ipc_callid_t rid, ipc_call_t *request) 492 491 { 493 if (!vfs_files_init()) {494 ipc_answer_0(rid, ENOMEM);495 return;496 }497 498 492 /* 499 493 * The POSIX interface is open(path, oflag, mode). … … 519 513 ((lflag & (L_FILE | L_DIRECTORY)) == (L_FILE | L_DIRECTORY)) || 520 514 (lflag & (L_OPEN | L_ROOT | L_MP))) { 521 ipc_answer_0(rid, EINVAL);515 async_answer_0(rid, EINVAL); 522 516 return; 523 517 } … … 531 525 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL); 532 526 if (rc != EOK) { 533 ipc_answer_0(rid, rc);527 async_answer_0(rid, rc); 534 528 return; 535 529 } … … 553 547 else 554 548 fibril_rwlock_read_unlock(&namespace_rwlock); 555 ipc_answer_0(rid, rc);549 async_answer_0(rid, rc); 556 550 free(path); 557 551 return; … … 576 570 fibril_rwlock_write_unlock(&node->contents_rwlock); 577 571 vfs_node_put(node); 578 ipc_answer_0(rid, rc);572 async_answer_0(rid, rc); 579 573 return; 580 574 } … … 591 585 if (fd < 0) { 592 586 vfs_node_put(node); 593 ipc_answer_0(rid, fd);587 async_answer_0(rid, fd); 594 588 return; 595 589 } … … 609 603 vfs_node_addref(node); 610 604 vfs_node_put(node); 605 vfs_file_put(file); 611 606 612 607 /* Success! Return the new file descriptor to the client. */ 613 ipc_answer_1(rid, EOK, fd);608 async_answer_1(rid, EOK, fd); 614 609 } 615 610 … … 617 612 { 618 613 // FIXME: check for sanity of the supplied fs, dev and index 619 620 if (!vfs_files_init()) {621 ipc_answer_0(rid, ENOMEM);622 return;623 }624 614 625 615 /* … … 638 628 if (rc != EOK) { 639 629 fibril_rwlock_read_unlock(&namespace_rwlock); 640 ipc_answer_0(rid, rc);630 async_answer_0(rid, rc); 641 631 return; 642 632 } … … 654 644 fibril_rwlock_write_unlock(&node->contents_rwlock); 655 645 vfs_node_put(node); 656 ipc_answer_0(rid, rc);646 async_answer_0(rid, rc); 657 647 return; 658 648 } … … 669 659 if (fd < 0) { 670 660 vfs_node_put(node); 671 ipc_answer_0(rid, fd);661 async_answer_0(rid, fd); 672 662 return; 673 663 } … … 686 676 vfs_node_addref(node); 687 677 vfs_node_put(node); 678 vfs_file_put(file); 688 679 689 680 /* Success! Return the new file descriptor to the client. */ 690 ipc_answer_1(rid, EOK, fd);681 async_answer_1(rid, EOK, fd); 691 682 } 692 683 … … 698 689 vfs_file_t *file = vfs_file_get(fd); 699 690 if (!file) { 700 ipc_answer_0(rid, ENOENT);691 async_answer_0(rid, ENOENT); 701 692 return; 702 693 } … … 716 707 717 708 /* Wait for reply from the FS server. */ 718 ipcarg_t rc;709 sysarg_t rc; 719 710 async_wait_for(msg, &rc); 720 711 721 712 vfs_release_phone(file->node->fs_handle, fs_phone); 722 713 fibril_mutex_unlock(&file->lock); 723 724 ipc_answer_0(rid, rc); 714 715 vfs_file_put(file); 716 async_answer_0(rid, rc); 725 717 } 726 718 … … 747 739 748 740 /* Wait for reply from the FS server. */ 749 ipcarg_t rc;741 sysarg_t rc; 750 742 async_wait_for(msg, &rc); 751 743 … … 767 759 vfs_file_t *file = vfs_file_get(fd); 768 760 if (!file) { 769 ipc_answer_0(rid, ENOENT);761 async_answer_0(rid, ENOENT); 770 762 return; 771 763 } … … 773 765 int ret = vfs_close_internal(file); 774 766 if (ret != EOK) 775 ipc_answer_0(rid, ret); 776 767 async_answer_0(rid, ret); 768 769 vfs_file_put(file); 777 770 ret = vfs_fd_free(fd); 778 ipc_answer_0(rid, ret);771 async_answer_0(rid, ret); 779 772 } 780 773 781 774 static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read) 782 775 { 776 vfs_info_t *vi; 783 777 784 778 /* … … 797 791 vfs_file_t *file = vfs_file_get(fd); 798 792 if (!file) { 799 ipc_answer_0(rid, ENOENT);793 async_answer_0(rid, ENOENT); 800 794 return; 801 795 } … … 807 801 fibril_mutex_lock(&file->lock); 808 802 803 vi = fs_handle_to_info(file->node->fs_handle); 804 assert(vi); 805 809 806 /* 810 807 * Lock the file's node so that no other client can read/write to it at 811 * the same time. 812 */ 813 if (read) 808 * the same time unless the FS supports concurrent reads/writes and its 809 * write implementation does not modify the file size. 810 */ 811 if (read || (vi->concurrent_read_write && vi->write_retains_size)) 814 812 fibril_rwlock_read_lock(&file->node->contents_rwlock); 815 813 else … … 834 832 * don't have to bother. 835 833 */ 836 ipcarg_t rc;834 sysarg_t rc; 837 835 ipc_call_t answer; 838 836 if (read) { … … 857 855 858 856 /* Unlock the VFS node. */ 859 if (read )857 if (read || (vi->concurrent_read_write && vi->write_retains_size)) 860 858 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 861 859 else { … … 870 868 file->pos += bytes; 871 869 fibril_mutex_unlock(&file->lock); 872 870 vfs_file_put(file); 871 873 872 /* 874 873 * FS server's reply is the final result of the whole operation we 875 874 * return to the client. 876 875 */ 877 ipc_answer_1(rid, rc, bytes);876 async_answer_1(rid, rc, bytes); 878 877 } 879 878 … … 898 897 vfs_file_t *file = vfs_file_get(fd); 899 898 if (!file) { 900 ipc_answer_0(rid, ENOENT);899 async_answer_0(rid, ENOENT); 901 900 return; 902 901 } … … 910 909 file->pos = (aoff64_t) off; 911 910 fibril_mutex_unlock(&file->lock); 912 ipc_answer_1(rid, EOK, off); 911 vfs_file_put(file); 912 async_answer_1(rid, EOK, off); 913 913 return; 914 914 } … … 917 917 if ((off >= 0) && (file->pos + off < file->pos)) { 918 918 fibril_mutex_unlock(&file->lock); 919 ipc_answer_0(rid, EOVERFLOW); 919 vfs_file_put(file); 920 async_answer_0(rid, EOVERFLOW); 920 921 return; 921 922 } … … 923 924 if ((off < 0) && (file->pos < (aoff64_t) -off)) { 924 925 fibril_mutex_unlock(&file->lock); 925 ipc_answer_0(rid, EOVERFLOW); 926 vfs_file_put(file); 927 async_answer_0(rid, EOVERFLOW); 926 928 return; 927 929 } … … 931 933 932 934 fibril_mutex_unlock(&file->lock); 933 ipc_answer_2(rid, EOK, LOWER32(newoff), 935 vfs_file_put(file); 936 async_answer_2(rid, EOK, LOWER32(newoff), 934 937 UPPER32(newoff)); 935 938 return; … … 941 944 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 942 945 fibril_mutex_unlock(&file->lock); 943 ipc_answer_0(rid, EOVERFLOW); 946 vfs_file_put(file); 947 async_answer_0(rid, EOVERFLOW); 944 948 return; 945 949 } … … 948 952 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 949 953 fibril_mutex_unlock(&file->lock); 950 ipc_answer_0(rid, EOVERFLOW); 954 vfs_file_put(file); 955 async_answer_0(rid, EOVERFLOW); 951 956 return; 952 957 } … … 957 962 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 958 963 fibril_mutex_unlock(&file->lock); 959 ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff)); 964 vfs_file_put(file); 965 async_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff)); 960 966 return; 961 967 } 962 968 963 969 fibril_mutex_unlock(&file->lock); 964 ipc_answer_0(rid, EINVAL); 970 vfs_file_put(file); 971 async_answer_0(rid, EINVAL); 965 972 } 966 973 … … 968 975 fs_index_t index, aoff64_t size) 969 976 { 970 ipcarg_t rc;977 sysarg_t rc; 971 978 int fs_phone; 972 979 973 980 fs_phone = vfs_grab_phone(fs_handle); 974 rc = async_req_4_0(fs_phone, VFS_OUT_TRUNCATE, ( ipcarg_t) devmap_handle,975 ( ipcarg_t) index, LOWER32(size), UPPER32(size));981 rc = async_req_4_0(fs_phone, VFS_OUT_TRUNCATE, (sysarg_t) devmap_handle, 982 (sysarg_t) index, LOWER32(size), UPPER32(size)); 976 983 vfs_release_phone(fs_handle, fs_phone); 977 984 return (int)rc; … … 987 994 vfs_file_t *file = vfs_file_get(fd); 988 995 if (!file) { 989 ipc_answer_0(rid, ENOENT);996 async_answer_0(rid, ENOENT); 990 997 return; 991 998 } … … 1000 1007 1001 1008 fibril_mutex_unlock(&file->lock); 1002 ipc_answer_0(rid, (ipcarg_t)rc); 1009 vfs_file_put(file); 1010 async_answer_0(rid, (sysarg_t)rc); 1003 1011 } 1004 1012 … … 1006 1014 { 1007 1015 int fd = IPC_GET_ARG1(*request); 1008 ipcarg_t rc;1016 sysarg_t rc; 1009 1017 1010 1018 vfs_file_t *file = vfs_file_get(fd); 1011 1019 if (!file) { 1012 ipc_answer_0(rid, ENOENT);1020 async_answer_0(rid, ENOENT); 1013 1021 return; 1014 1022 } … … 1016 1024 ipc_callid_t callid; 1017 1025 if (!async_data_read_receive(&callid, NULL)) { 1018 ipc_answer_0(callid, EINVAL); 1019 ipc_answer_0(rid, EINVAL); 1026 vfs_file_put(file); 1027 async_answer_0(callid, EINVAL); 1028 async_answer_0(rid, EINVAL); 1020 1029 return; 1021 1030 } … … 1028 1037 msg = async_send_3(fs_phone, VFS_OUT_STAT, file->node->devmap_handle, 1029 1038 file->node->index, true, NULL); 1030 ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);1039 async_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 1031 1040 async_wait_for(msg, &rc); 1032 1041 vfs_release_phone(file->node->fs_handle, fs_phone); 1033 1042 1034 1043 fibril_mutex_unlock(&file->lock); 1035 ipc_answer_0(rid, rc); 1044 vfs_file_put(file); 1045 async_answer_0(rid, rc); 1036 1046 } 1037 1047 … … 1041 1051 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL); 1042 1052 if (rc != EOK) { 1043 ipc_answer_0(rid, rc);1053 async_answer_0(rid, rc); 1044 1054 return; 1045 1055 } … … 1048 1058 if (!async_data_read_receive(&callid, NULL)) { 1049 1059 free(path); 1050 ipc_answer_0(callid, EINVAL);1051 ipc_answer_0(rid, EINVAL);1060 async_answer_0(callid, EINVAL); 1061 async_answer_0(rid, EINVAL); 1052 1062 return; 1053 1063 } … … 1059 1069 if (rc != EOK) { 1060 1070 fibril_rwlock_read_unlock(&namespace_rwlock); 1061 ipc_answer_0(callid, rc);1062 ipc_answer_0(rid, rc);1071 async_answer_0(callid, rc); 1072 async_answer_0(rid, rc); 1063 1073 return; 1064 1074 } … … 1066 1076 if (!node) { 1067 1077 fibril_rwlock_read_unlock(&namespace_rwlock); 1068 ipc_answer_0(callid, ENOMEM);1069 ipc_answer_0(rid, ENOMEM);1078 async_answer_0(callid, ENOMEM); 1079 async_answer_0(rid, ENOMEM); 1070 1080 return; 1071 1081 } … … 1077 1087 msg = async_send_3(fs_phone, VFS_OUT_STAT, node->devmap_handle, 1078 1088 node->index, false, NULL); 1079 ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);1080 1081 ipcarg_t rv;1089 async_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 1090 1091 sysarg_t rv; 1082 1092 async_wait_for(msg, &rv); 1083 1093 vfs_release_phone(node->fs_handle, fs_phone); 1084 1094 1085 ipc_answer_0(rid, rv);1095 async_answer_0(rid, rv); 1086 1096 1087 1097 vfs_node_put(node); … … 1095 1105 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL); 1096 1106 if (rc != EOK) { 1097 ipc_answer_0(rid, rc);1107 async_answer_0(rid, rc); 1098 1108 return; 1099 1109 } … … 1107 1117 fibril_rwlock_write_unlock(&namespace_rwlock); 1108 1118 free(path); 1109 ipc_answer_0(rid, rc);1119 async_answer_0(rid, rc); 1110 1120 } 1111 1121 … … 1117 1127 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL); 1118 1128 if (rc != EOK) { 1119 ipc_answer_0(rid, rc);1129 async_answer_0(rid, rc); 1120 1130 return; 1121 1131 } … … 1128 1138 if (rc != EOK) { 1129 1139 fibril_rwlock_write_unlock(&namespace_rwlock); 1130 ipc_answer_0(rid, rc);1140 async_answer_0(rid, rc); 1131 1141 return; 1132 1142 } … … 1143 1153 fibril_rwlock_write_unlock(&namespace_rwlock); 1144 1154 vfs_node_put(node); 1145 ipc_answer_0(rid, EOK);1155 async_answer_0(rid, EOK); 1146 1156 } 1147 1157 … … 1152 1162 int rc = async_data_write_accept((void **) &old, true, 0, 0, 0, NULL); 1153 1163 if (rc != EOK) { 1154 ipc_answer_0(rid, rc);1164 async_answer_0(rid, rc); 1155 1165 return; 1156 1166 } … … 1161 1171 if (rc != EOK) { 1162 1172 free(old); 1163 ipc_answer_0(rid, rc);1173 async_answer_0(rid, rc); 1164 1174 return; 1165 1175 } … … 1171 1181 1172 1182 if ((!oldc) || (!newc)) { 1173 ipc_answer_0(rid, EINVAL);1183 async_answer_0(rid, EINVAL); 1174 1184 free(old); 1175 1185 free(new); … … 1190 1200 * - oldc and newc are equal. 1191 1201 */ 1192 ipc_answer_0(rid, EINVAL);1202 async_answer_0(rid, EINVAL); 1193 1203 free(old); 1194 1204 free(new); … … 1205 1215 if (rc != EOK) { 1206 1216 fibril_rwlock_write_unlock(&namespace_rwlock); 1207 ipc_answer_0(rid, rc);1217 async_answer_0(rid, rc); 1208 1218 free(old); 1209 1219 free(new); … … 1214 1224 if (!old_node) { 1215 1225 fibril_rwlock_write_unlock(&namespace_rwlock); 1216 ipc_answer_0(rid, ENOMEM);1226 async_answer_0(rid, ENOMEM); 1217 1227 free(old); 1218 1228 free(new); … … 1224 1234 if (!parentc) { 1225 1235 fibril_rwlock_write_unlock(&namespace_rwlock); 1226 ipc_answer_0(rid, rc);1236 async_answer_0(rid, rc); 1227 1237 free(old); 1228 1238 free(new); … … 1241 1251 if (rc != EOK) { 1242 1252 fibril_rwlock_write_unlock(&namespace_rwlock); 1243 ipc_answer_0(rid, rc);1253 async_answer_0(rid, rc); 1244 1254 free(old); 1245 1255 free(new); … … 1251 1261 (old_node->devmap_handle != new_par_lr.triplet.devmap_handle)) { 1252 1262 fibril_rwlock_write_unlock(&namespace_rwlock); 1253 ipc_answer_0(rid, EXDEV); /* different file systems */1263 async_answer_0(rid, EXDEV); /* different file systems */ 1254 1264 free(old); 1255 1265 free(new); … … 1269 1279 if (!new_node) { 1270 1280 fibril_rwlock_write_unlock(&namespace_rwlock); 1271 ipc_answer_0(rid, ENOMEM);1281 async_answer_0(rid, ENOMEM); 1272 1282 free(old); 1273 1283 free(new); … … 1280 1290 default: 1281 1291 fibril_rwlock_write_unlock(&namespace_rwlock); 1282 ipc_answer_0(rid, ENOTEMPTY);1292 async_answer_0(rid, ENOTEMPTY); 1283 1293 free(old); 1284 1294 free(new); … … 1292 1302 if (new_node) 1293 1303 vfs_node_put(new_node); 1294 ipc_answer_0(rid, rc);1304 async_answer_0(rid, rc); 1295 1305 free(old); 1296 1306 free(new); … … 1309 1319 if (new_node) 1310 1320 vfs_node_put(new_node); 1311 ipc_answer_0(rid, rc);1321 async_answer_0(rid, rc); 1312 1322 free(old); 1313 1323 free(new); … … 1326 1336 free(old); 1327 1337 free(new); 1328 ipc_answer_0(rid, EOK);1338 async_answer_0(rid, EOK); 1329 1339 } 1330 1340 … … 1333 1343 int oldfd = IPC_GET_ARG1(*request); 1334 1344 int newfd = IPC_GET_ARG2(*request); 1345 1346 /* If the file descriptors are the same, do nothing. */ 1347 if (oldfd == newfd) { 1348 async_answer_1(rid, EOK, newfd); 1349 return; 1350 } 1335 1351 1336 1352 /* Lookup the file structure corresponding to oldfd. */ 1337 1353 vfs_file_t *oldfile = vfs_file_get(oldfd); 1338 1354 if (!oldfile) { 1339 ipc_answer_0(rid, EBADF); 1340 return; 1341 } 1342 1343 /* If the file descriptors are the same, do nothing. */ 1344 if (oldfd == newfd) { 1345 ipc_answer_1(rid, EOK, newfd); 1355 async_answer_0(rid, EBADF); 1346 1356 return; 1347 1357 } … … 1360 1370 if (ret != EOK) { 1361 1371 fibril_mutex_unlock(&oldfile->lock); 1362 ipc_answer_0(rid, ret); 1372 vfs_file_put(oldfile); 1373 vfs_file_put(newfile); 1374 async_answer_0(rid, ret); 1363 1375 return; 1364 1376 } … … 1367 1379 if (ret != EOK) { 1368 1380 fibril_mutex_unlock(&oldfile->lock); 1369 ipc_answer_0(rid, ret); 1370 return; 1371 } 1381 vfs_file_put(oldfile); 1382 vfs_file_put(newfile); 1383 async_answer_0(rid, ret); 1384 return; 1385 } 1386 vfs_file_put(newfile); 1372 1387 } 1373 1388 … … 1375 1390 int ret = vfs_fd_assign(oldfile, newfd); 1376 1391 fibril_mutex_unlock(&oldfile->lock); 1392 vfs_file_put(oldfile); 1377 1393 1378 1394 if (ret != EOK) 1379 ipc_answer_0(rid, ret);1395 async_answer_0(rid, ret); 1380 1396 else 1381 ipc_answer_1(rid, EOK, newfd);1397 async_answer_1(rid, EOK, newfd); 1382 1398 } 1383 1399
Note:
See TracChangeset
for help on using the changeset viewer.