Changes in uspace/srv/vfs/vfs_ops.c [4fe94c66:ffa2c8ef] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_ops.c
r4fe94c66 rffa2c8ef 37 37 38 38 #include "vfs.h" 39 #include <ipc/ipc.h>40 39 #include <macros.h> 41 40 #include <stdint.h> … … 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 } … … 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 } … … 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 } … … 310 309 ipc_callid_t callid = async_get_call(&data); 311 310 if (IPC_GET_IMETHOD(data) != IPC_M_PING) { 312 ipc_answer_0(callid, ENOTSUP);313 ipc_answer_0(rid, ENOTSUP);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 … … 514 513 ((lflag & (L_FILE | L_DIRECTORY)) == (L_FILE | L_DIRECTORY)) || 515 514 (lflag & (L_OPEN | L_ROOT | L_MP))) { 516 ipc_answer_0(rid, EINVAL);515 async_answer_0(rid, EINVAL); 517 516 return; 518 517 } … … 526 525 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL); 527 526 if (rc != EOK) { 528 ipc_answer_0(rid, rc);527 async_answer_0(rid, rc); 529 528 return; 530 529 } … … 548 547 else 549 548 fibril_rwlock_read_unlock(&namespace_rwlock); 550 ipc_answer_0(rid, rc);549 async_answer_0(rid, rc); 551 550 free(path); 552 551 return; … … 571 570 fibril_rwlock_write_unlock(&node->contents_rwlock); 572 571 vfs_node_put(node); 573 ipc_answer_0(rid, rc);572 async_answer_0(rid, rc); 574 573 return; 575 574 } … … 586 585 if (fd < 0) { 587 586 vfs_node_put(node); 588 ipc_answer_0(rid, fd);587 async_answer_0(rid, fd); 589 588 return; 590 589 } … … 607 606 608 607 /* Success! Return the new file descriptor to the client. */ 609 ipc_answer_1(rid, EOK, fd);608 async_answer_1(rid, EOK, fd); 610 609 } 611 610 … … 629 628 if (rc != EOK) { 630 629 fibril_rwlock_read_unlock(&namespace_rwlock); 631 ipc_answer_0(rid, rc);630 async_answer_0(rid, rc); 632 631 return; 633 632 } … … 645 644 fibril_rwlock_write_unlock(&node->contents_rwlock); 646 645 vfs_node_put(node); 647 ipc_answer_0(rid, rc);646 async_answer_0(rid, rc); 648 647 return; 649 648 } … … 660 659 if (fd < 0) { 661 660 vfs_node_put(node); 662 ipc_answer_0(rid, fd);661 async_answer_0(rid, fd); 663 662 return; 664 663 } … … 680 679 681 680 /* Success! Return the new file descriptor to the client. */ 682 ipc_answer_1(rid, EOK, fd);681 async_answer_1(rid, EOK, fd); 683 682 } 684 683 … … 690 689 vfs_file_t *file = vfs_file_get(fd); 691 690 if (!file) { 692 ipc_answer_0(rid, ENOENT);691 async_answer_0(rid, ENOENT); 693 692 return; 694 693 } … … 715 714 716 715 vfs_file_put(file); 717 ipc_answer_0(rid, rc);716 async_answer_0(rid, rc); 718 717 } 719 718 … … 760 759 vfs_file_t *file = vfs_file_get(fd); 761 760 if (!file) { 762 ipc_answer_0(rid, ENOENT);761 async_answer_0(rid, ENOENT); 763 762 return; 764 763 } … … 766 765 int ret = vfs_close_internal(file); 767 766 if (ret != EOK) 768 ipc_answer_0(rid, ret);767 async_answer_0(rid, ret); 769 768 770 769 vfs_file_put(file); 771 770 ret = vfs_fd_free(fd); 772 ipc_answer_0(rid, ret);771 async_answer_0(rid, ret); 773 772 } 774 773 … … 792 791 vfs_file_t *file = vfs_file_get(fd); 793 792 if (!file) { 794 ipc_answer_0(rid, ENOENT);793 async_answer_0(rid, ENOENT); 795 794 return; 796 795 } … … 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 } … … 911 910 fibril_mutex_unlock(&file->lock); 912 911 vfs_file_put(file); 913 ipc_answer_1(rid, EOK, off);912 async_answer_1(rid, EOK, off); 914 913 return; 915 914 } … … 919 918 fibril_mutex_unlock(&file->lock); 920 919 vfs_file_put(file); 921 ipc_answer_0(rid, EOVERFLOW);920 async_answer_0(rid, EOVERFLOW); 922 921 return; 923 922 } … … 926 925 fibril_mutex_unlock(&file->lock); 927 926 vfs_file_put(file); 928 ipc_answer_0(rid, EOVERFLOW);927 async_answer_0(rid, EOVERFLOW); 929 928 return; 930 929 } … … 935 934 fibril_mutex_unlock(&file->lock); 936 935 vfs_file_put(file); 937 ipc_answer_2(rid, EOK, LOWER32(newoff),936 async_answer_2(rid, EOK, LOWER32(newoff), 938 937 UPPER32(newoff)); 939 938 return; … … 946 945 fibril_mutex_unlock(&file->lock); 947 946 vfs_file_put(file); 948 ipc_answer_0(rid, EOVERFLOW);947 async_answer_0(rid, EOVERFLOW); 949 948 return; 950 949 } … … 954 953 fibril_mutex_unlock(&file->lock); 955 954 vfs_file_put(file); 956 ipc_answer_0(rid, EOVERFLOW);955 async_answer_0(rid, EOVERFLOW); 957 956 return; 958 957 } … … 964 963 fibril_mutex_unlock(&file->lock); 965 964 vfs_file_put(file); 966 ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));965 async_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff)); 967 966 return; 968 967 } … … 970 969 fibril_mutex_unlock(&file->lock); 971 970 vfs_file_put(file); 972 ipc_answer_0(rid, EINVAL);971 async_answer_0(rid, EINVAL); 973 972 } 974 973 … … 995 994 vfs_file_t *file = vfs_file_get(fd); 996 995 if (!file) { 997 ipc_answer_0(rid, ENOENT);996 async_answer_0(rid, ENOENT); 998 997 return; 999 998 } … … 1009 1008 fibril_mutex_unlock(&file->lock); 1010 1009 vfs_file_put(file); 1011 ipc_answer_0(rid, (sysarg_t)rc);1010 async_answer_0(rid, (sysarg_t)rc); 1012 1011 } 1013 1012 … … 1019 1018 vfs_file_t *file = vfs_file_get(fd); 1020 1019 if (!file) { 1021 ipc_answer_0(rid, ENOENT);1020 async_answer_0(rid, ENOENT); 1022 1021 return; 1023 1022 } … … 1026 1025 if (!async_data_read_receive(&callid, NULL)) { 1027 1026 vfs_file_put(file); 1028 ipc_answer_0(callid, EINVAL);1029 ipc_answer_0(rid, EINVAL);1027 async_answer_0(callid, EINVAL); 1028 async_answer_0(rid, EINVAL); 1030 1029 return; 1031 1030 } … … 1038 1037 msg = async_send_3(fs_phone, VFS_OUT_STAT, file->node->devmap_handle, 1039 1038 file->node->index, true, NULL); 1040 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); 1041 1040 async_wait_for(msg, &rc); 1042 1041 vfs_release_phone(file->node->fs_handle, fs_phone); … … 1044 1043 fibril_mutex_unlock(&file->lock); 1045 1044 vfs_file_put(file); 1046 ipc_answer_0(rid, rc);1045 async_answer_0(rid, rc); 1047 1046 } 1048 1047 … … 1052 1051 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL); 1053 1052 if (rc != EOK) { 1054 ipc_answer_0(rid, rc);1053 async_answer_0(rid, rc); 1055 1054 return; 1056 1055 } … … 1059 1058 if (!async_data_read_receive(&callid, NULL)) { 1060 1059 free(path); 1061 ipc_answer_0(callid, EINVAL);1062 ipc_answer_0(rid, EINVAL);1060 async_answer_0(callid, EINVAL); 1061 async_answer_0(rid, EINVAL); 1063 1062 return; 1064 1063 } … … 1070 1069 if (rc != EOK) { 1071 1070 fibril_rwlock_read_unlock(&namespace_rwlock); 1072 ipc_answer_0(callid, rc);1073 ipc_answer_0(rid, rc);1071 async_answer_0(callid, rc); 1072 async_answer_0(rid, rc); 1074 1073 return; 1075 1074 } … … 1077 1076 if (!node) { 1078 1077 fibril_rwlock_read_unlock(&namespace_rwlock); 1079 ipc_answer_0(callid, ENOMEM);1080 ipc_answer_0(rid, ENOMEM);1078 async_answer_0(callid, ENOMEM); 1079 async_answer_0(rid, ENOMEM); 1081 1080 return; 1082 1081 } … … 1088 1087 msg = async_send_3(fs_phone, VFS_OUT_STAT, node->devmap_handle, 1089 1088 node->index, false, NULL); 1090 ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);1089 async_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 1091 1090 1092 1091 sysarg_t rv; … … 1094 1093 vfs_release_phone(node->fs_handle, fs_phone); 1095 1094 1096 ipc_answer_0(rid, rv);1095 async_answer_0(rid, rv); 1097 1096 1098 1097 vfs_node_put(node); … … 1106 1105 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL); 1107 1106 if (rc != EOK) { 1108 ipc_answer_0(rid, rc);1107 async_answer_0(rid, rc); 1109 1108 return; 1110 1109 } … … 1118 1117 fibril_rwlock_write_unlock(&namespace_rwlock); 1119 1118 free(path); 1120 ipc_answer_0(rid, rc);1119 async_answer_0(rid, rc); 1121 1120 } 1122 1121 … … 1128 1127 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL); 1129 1128 if (rc != EOK) { 1130 ipc_answer_0(rid, rc);1129 async_answer_0(rid, rc); 1131 1130 return; 1132 1131 } … … 1139 1138 if (rc != EOK) { 1140 1139 fibril_rwlock_write_unlock(&namespace_rwlock); 1141 ipc_answer_0(rid, rc);1140 async_answer_0(rid, rc); 1142 1141 return; 1143 1142 } … … 1154 1153 fibril_rwlock_write_unlock(&namespace_rwlock); 1155 1154 vfs_node_put(node); 1156 ipc_answer_0(rid, EOK);1155 async_answer_0(rid, EOK); 1157 1156 } 1158 1157 … … 1163 1162 int rc = async_data_write_accept((void **) &old, true, 0, 0, 0, NULL); 1164 1163 if (rc != EOK) { 1165 ipc_answer_0(rid, rc);1164 async_answer_0(rid, rc); 1166 1165 return; 1167 1166 } … … 1172 1171 if (rc != EOK) { 1173 1172 free(old); 1174 ipc_answer_0(rid, rc);1173 async_answer_0(rid, rc); 1175 1174 return; 1176 1175 } … … 1182 1181 1183 1182 if ((!oldc) || (!newc)) { 1184 ipc_answer_0(rid, EINVAL);1183 async_answer_0(rid, EINVAL); 1185 1184 free(old); 1186 1185 free(new); … … 1201 1200 * - oldc and newc are equal. 1202 1201 */ 1203 ipc_answer_0(rid, EINVAL);1202 async_answer_0(rid, EINVAL); 1204 1203 free(old); 1205 1204 free(new); … … 1216 1215 if (rc != EOK) { 1217 1216 fibril_rwlock_write_unlock(&namespace_rwlock); 1218 ipc_answer_0(rid, rc);1217 async_answer_0(rid, rc); 1219 1218 free(old); 1220 1219 free(new); … … 1225 1224 if (!old_node) { 1226 1225 fibril_rwlock_write_unlock(&namespace_rwlock); 1227 ipc_answer_0(rid, ENOMEM);1226 async_answer_0(rid, ENOMEM); 1228 1227 free(old); 1229 1228 free(new); … … 1235 1234 if (!parentc) { 1236 1235 fibril_rwlock_write_unlock(&namespace_rwlock); 1237 ipc_answer_0(rid, rc);1236 async_answer_0(rid, rc); 1238 1237 free(old); 1239 1238 free(new); … … 1252 1251 if (rc != EOK) { 1253 1252 fibril_rwlock_write_unlock(&namespace_rwlock); 1254 ipc_answer_0(rid, rc);1253 async_answer_0(rid, rc); 1255 1254 free(old); 1256 1255 free(new); … … 1262 1261 (old_node->devmap_handle != new_par_lr.triplet.devmap_handle)) { 1263 1262 fibril_rwlock_write_unlock(&namespace_rwlock); 1264 ipc_answer_0(rid, EXDEV); /* different file systems */1263 async_answer_0(rid, EXDEV); /* different file systems */ 1265 1264 free(old); 1266 1265 free(new); … … 1280 1279 if (!new_node) { 1281 1280 fibril_rwlock_write_unlock(&namespace_rwlock); 1282 ipc_answer_0(rid, ENOMEM);1281 async_answer_0(rid, ENOMEM); 1283 1282 free(old); 1284 1283 free(new); … … 1291 1290 default: 1292 1291 fibril_rwlock_write_unlock(&namespace_rwlock); 1293 ipc_answer_0(rid, ENOTEMPTY);1292 async_answer_0(rid, ENOTEMPTY); 1294 1293 free(old); 1295 1294 free(new); … … 1303 1302 if (new_node) 1304 1303 vfs_node_put(new_node); 1305 ipc_answer_0(rid, rc);1304 async_answer_0(rid, rc); 1306 1305 free(old); 1307 1306 free(new); … … 1320 1319 if (new_node) 1321 1320 vfs_node_put(new_node); 1322 ipc_answer_0(rid, rc);1321 async_answer_0(rid, rc); 1323 1322 free(old); 1324 1323 free(new); … … 1337 1336 free(old); 1338 1337 free(new); 1339 ipc_answer_0(rid, EOK);1338 async_answer_0(rid, EOK); 1340 1339 } 1341 1340 … … 1347 1346 /* If the file descriptors are the same, do nothing. */ 1348 1347 if (oldfd == newfd) { 1349 ipc_answer_1(rid, EOK, newfd);1348 async_answer_1(rid, EOK, newfd); 1350 1349 return; 1351 1350 } … … 1354 1353 vfs_file_t *oldfile = vfs_file_get(oldfd); 1355 1354 if (!oldfile) { 1356 ipc_answer_0(rid, EBADF);1355 async_answer_0(rid, EBADF); 1357 1356 return; 1358 1357 } … … 1373 1372 vfs_file_put(oldfile); 1374 1373 vfs_file_put(newfile); 1375 ipc_answer_0(rid, ret);1374 async_answer_0(rid, ret); 1376 1375 return; 1377 1376 } … … 1382 1381 vfs_file_put(oldfile); 1383 1382 vfs_file_put(newfile); 1384 ipc_answer_0(rid, ret);1383 async_answer_0(rid, ret); 1385 1384 return; 1386 1385 } … … 1394 1393 1395 1394 if (ret != EOK) 1396 ipc_answer_0(rid, ret);1395 async_answer_0(rid, ret); 1397 1396 else 1398 ipc_answer_1(rid, EOK, newfd);1397 async_answer_1(rid, EOK, newfd); 1399 1398 } 1400 1399
Note:
See TracChangeset
for help on using the changeset viewer.