Changes in uspace/srv/vfs/vfs_ops.c [ffa2c8ef:4fe94c66] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_ops.c
rffa2c8ef r4fe94c66 37 37 38 38 #include "vfs.h" 39 #include <ipc/ipc.h> 39 40 #include <macros.h> 40 41 #include <stdint.h> … … 90 91 /* Trying to mount root FS over root FS */ 91 92 fibril_rwlock_write_unlock(&namespace_rwlock); 92 async_answer_0(rid, EBUSY);93 ipc_answer_0(rid, EBUSY); 93 94 return; 94 95 } … … 98 99 /* The lookup failed for some reason. */ 99 100 fibril_rwlock_write_unlock(&namespace_rwlock); 100 async_answer_0(rid, rc);101 ipc_answer_0(rid, rc); 101 102 return; 102 103 } … … 105 106 if (!mp_node) { 106 107 fibril_rwlock_write_unlock(&namespace_rwlock); 107 async_answer_0(rid, ENOMEM);108 ipc_answer_0(rid, ENOMEM); 108 109 return; 109 110 } … … 133 134 vfs_release_phone(fs_handle, phone); 134 135 fibril_rwlock_write_unlock(&namespace_rwlock); 135 async_answer_0(rid, rc);136 ipc_answer_0(rid, rc); 136 137 return; 137 138 } … … 141 142 if (rc != EOK) { 142 143 fibril_rwlock_write_unlock(&namespace_rwlock); 143 async_answer_0(rid, rc);144 ipc_answer_0(rid, rc); 144 145 return; 145 146 } … … 164 165 165 166 fibril_rwlock_write_unlock(&namespace_rwlock); 166 async_answer_0(rid, rc);167 ipc_answer_0(rid, rc); 167 168 return; 168 169 } else { … … 172 173 */ 173 174 fibril_rwlock_write_unlock(&namespace_rwlock); 174 async_answer_0(rid, ENOENT);175 ipc_answer_0(rid, ENOENT); 175 176 return; 176 177 } … … 201 202 if (mp_node) 202 203 vfs_node_put(mp_node); 203 async_answer_0(rid, rc);204 ipc_answer_0(rid, rc); 204 205 fibril_rwlock_write_unlock(&namespace_rwlock); 205 206 return; … … 217 218 vfs_node_put(mp_node); 218 219 fibril_rwlock_write_unlock(&namespace_rwlock); 219 async_answer_0(rid, rc);220 ipc_answer_0(rid, rc); 220 221 return; 221 222 } … … 244 245 } 245 246 246 async_answer_0(rid, rc);247 ipc_answer_0(rid, rc); 247 248 fibril_rwlock_write_unlock(&namespace_rwlock); 248 249 } … … 274 275 0, NULL); 275 276 if (rc != EOK) { 276 async_answer_0(rid, rc);277 ipc_answer_0(rid, rc); 277 278 return; 278 279 } … … 284 285 if (rc != EOK) { 285 286 free(mp); 286 async_answer_0(rid, rc);287 ipc_answer_0(rid, rc); 287 288 return; 288 289 } … … 298 299 free(mp); 299 300 free(opts); 300 async_answer_0(rid, rc);301 ipc_answer_0(rid, rc); 301 302 return; 302 303 } … … 309 310 ipc_callid_t callid = async_get_call(&data); 310 311 if (IPC_GET_IMETHOD(data) != IPC_M_PING) { 311 async_answer_0(callid, ENOTSUP);312 async_answer_0(rid, ENOTSUP);312 ipc_answer_0(callid, ENOTSUP); 313 ipc_answer_0(rid, ENOTSUP); 313 314 free(mp); 314 315 free(opts); … … 332 333 333 334 fibril_mutex_unlock(&fs_head_lock); 334 async_answer_0(callid, ENOENT);335 async_answer_0(rid, ENOENT);335 ipc_answer_0(callid, ENOENT); 336 ipc_answer_0(rid, ENOENT); 336 337 free(mp); 337 338 free(fs_name); … … 342 343 343 344 /* Acknowledge that we know fs_name. */ 344 async_answer_0(callid, EOK);345 ipc_answer_0(callid, EOK); 345 346 346 347 /* Do the mount */ … … 366 367 0, NULL); 367 368 if (rc != EOK) 368 async_answer_0(rid, rc);369 ipc_answer_0(rid, rc); 369 370 370 371 /* … … 385 386 fibril_rwlock_write_unlock(&namespace_rwlock); 386 387 free(mp); 387 async_answer_0(rid, rc);388 ipc_answer_0(rid, rc); 388 389 return; 389 390 } … … 392 393 fibril_rwlock_write_unlock(&namespace_rwlock); 393 394 free(mp); 394 async_answer_0(rid, ENOMEM);395 ipc_answer_0(rid, ENOMEM); 395 396 return; 396 397 } … … 408 409 vfs_node_put(mr_node); 409 410 free(mp); 410 async_answer_0(rid, EBUSY);411 ipc_answer_0(rid, EBUSY); 411 412 return; 412 413 } … … 429 430 fibril_rwlock_write_unlock(&namespace_rwlock); 430 431 vfs_node_put(mr_node); 431 async_answer_0(rid, rc);432 ipc_answer_0(rid, rc); 432 433 return; 433 434 } … … 448 449 fibril_rwlock_write_unlock(&namespace_rwlock); 449 450 vfs_node_put(mr_node); 450 async_answer_0(rid, rc);451 ipc_answer_0(rid, rc); 451 452 return; 452 453 } … … 455 456 fibril_rwlock_write_unlock(&namespace_rwlock); 456 457 vfs_node_put(mr_node); 457 async_answer_0(rid, ENOMEM);458 ipc_answer_0(rid, ENOMEM); 458 459 return; 459 460 } … … 467 468 vfs_node_put(mp_node); 468 469 vfs_node_put(mr_node); 469 async_answer_0(rid, rc);470 ipc_answer_0(rid, rc); 470 471 return; 471 472 } … … 485 486 486 487 fibril_rwlock_write_unlock(&namespace_rwlock); 487 async_answer_0(rid, EOK);488 ipc_answer_0(rid, EOK); 488 489 } 489 490 … … 513 514 ((lflag & (L_FILE | L_DIRECTORY)) == (L_FILE | L_DIRECTORY)) || 514 515 (lflag & (L_OPEN | L_ROOT | L_MP))) { 515 async_answer_0(rid, EINVAL);516 ipc_answer_0(rid, EINVAL); 516 517 return; 517 518 } … … 525 526 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL); 526 527 if (rc != EOK) { 527 async_answer_0(rid, rc);528 ipc_answer_0(rid, rc); 528 529 return; 529 530 } … … 547 548 else 548 549 fibril_rwlock_read_unlock(&namespace_rwlock); 549 async_answer_0(rid, rc);550 ipc_answer_0(rid, rc); 550 551 free(path); 551 552 return; … … 570 571 fibril_rwlock_write_unlock(&node->contents_rwlock); 571 572 vfs_node_put(node); 572 async_answer_0(rid, rc);573 ipc_answer_0(rid, rc); 573 574 return; 574 575 } … … 585 586 if (fd < 0) { 586 587 vfs_node_put(node); 587 async_answer_0(rid, fd);588 ipc_answer_0(rid, fd); 588 589 return; 589 590 } … … 606 607 607 608 /* Success! Return the new file descriptor to the client. */ 608 async_answer_1(rid, EOK, fd);609 ipc_answer_1(rid, EOK, fd); 609 610 } 610 611 … … 628 629 if (rc != EOK) { 629 630 fibril_rwlock_read_unlock(&namespace_rwlock); 630 async_answer_0(rid, rc);631 ipc_answer_0(rid, rc); 631 632 return; 632 633 } … … 644 645 fibril_rwlock_write_unlock(&node->contents_rwlock); 645 646 vfs_node_put(node); 646 async_answer_0(rid, rc);647 ipc_answer_0(rid, rc); 647 648 return; 648 649 } … … 659 660 if (fd < 0) { 660 661 vfs_node_put(node); 661 async_answer_0(rid, fd);662 ipc_answer_0(rid, fd); 662 663 return; 663 664 } … … 679 680 680 681 /* Success! Return the new file descriptor to the client. */ 681 async_answer_1(rid, EOK, fd);682 ipc_answer_1(rid, EOK, fd); 682 683 } 683 684 … … 689 690 vfs_file_t *file = vfs_file_get(fd); 690 691 if (!file) { 691 async_answer_0(rid, ENOENT);692 ipc_answer_0(rid, ENOENT); 692 693 return; 693 694 } … … 714 715 715 716 vfs_file_put(file); 716 async_answer_0(rid, rc);717 ipc_answer_0(rid, rc); 717 718 } 718 719 … … 759 760 vfs_file_t *file = vfs_file_get(fd); 760 761 if (!file) { 761 async_answer_0(rid, ENOENT);762 ipc_answer_0(rid, ENOENT); 762 763 return; 763 764 } … … 765 766 int ret = vfs_close_internal(file); 766 767 if (ret != EOK) 767 async_answer_0(rid, ret);768 ipc_answer_0(rid, ret); 768 769 769 770 vfs_file_put(file); 770 771 ret = vfs_fd_free(fd); 771 async_answer_0(rid, ret);772 ipc_answer_0(rid, ret); 772 773 } 773 774 … … 791 792 vfs_file_t *file = vfs_file_get(fd); 792 793 if (!file) { 793 async_answer_0(rid, ENOENT);794 ipc_answer_0(rid, ENOENT); 794 795 return; 795 796 } … … 874 875 * return to the client. 875 876 */ 876 async_answer_1(rid, rc, bytes);877 ipc_answer_1(rid, rc, bytes); 877 878 } 878 879 … … 897 898 vfs_file_t *file = vfs_file_get(fd); 898 899 if (!file) { 899 async_answer_0(rid, ENOENT);900 ipc_answer_0(rid, ENOENT); 900 901 return; 901 902 } … … 910 911 fibril_mutex_unlock(&file->lock); 911 912 vfs_file_put(file); 912 async_answer_1(rid, EOK, off);913 ipc_answer_1(rid, EOK, off); 913 914 return; 914 915 } … … 918 919 fibril_mutex_unlock(&file->lock); 919 920 vfs_file_put(file); 920 async_answer_0(rid, EOVERFLOW);921 ipc_answer_0(rid, EOVERFLOW); 921 922 return; 922 923 } … … 925 926 fibril_mutex_unlock(&file->lock); 926 927 vfs_file_put(file); 927 async_answer_0(rid, EOVERFLOW);928 ipc_answer_0(rid, EOVERFLOW); 928 929 return; 929 930 } … … 934 935 fibril_mutex_unlock(&file->lock); 935 936 vfs_file_put(file); 936 async_answer_2(rid, EOK, LOWER32(newoff),937 ipc_answer_2(rid, EOK, LOWER32(newoff), 937 938 UPPER32(newoff)); 938 939 return; … … 945 946 fibril_mutex_unlock(&file->lock); 946 947 vfs_file_put(file); 947 async_answer_0(rid, EOVERFLOW);948 ipc_answer_0(rid, EOVERFLOW); 948 949 return; 949 950 } … … 953 954 fibril_mutex_unlock(&file->lock); 954 955 vfs_file_put(file); 955 async_answer_0(rid, EOVERFLOW);956 ipc_answer_0(rid, EOVERFLOW); 956 957 return; 957 958 } … … 963 964 fibril_mutex_unlock(&file->lock); 964 965 vfs_file_put(file); 965 async_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));966 ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff)); 966 967 return; 967 968 } … … 969 970 fibril_mutex_unlock(&file->lock); 970 971 vfs_file_put(file); 971 async_answer_0(rid, EINVAL);972 ipc_answer_0(rid, EINVAL); 972 973 } 973 974 … … 994 995 vfs_file_t *file = vfs_file_get(fd); 995 996 if (!file) { 996 async_answer_0(rid, ENOENT);997 ipc_answer_0(rid, ENOENT); 997 998 return; 998 999 } … … 1008 1009 fibril_mutex_unlock(&file->lock); 1009 1010 vfs_file_put(file); 1010 async_answer_0(rid, (sysarg_t)rc);1011 ipc_answer_0(rid, (sysarg_t)rc); 1011 1012 } 1012 1013 … … 1018 1019 vfs_file_t *file = vfs_file_get(fd); 1019 1020 if (!file) { 1020 async_answer_0(rid, ENOENT);1021 ipc_answer_0(rid, ENOENT); 1021 1022 return; 1022 1023 } … … 1025 1026 if (!async_data_read_receive(&callid, NULL)) { 1026 1027 vfs_file_put(file); 1027 async_answer_0(callid, EINVAL);1028 async_answer_0(rid, EINVAL);1028 ipc_answer_0(callid, EINVAL); 1029 ipc_answer_0(rid, EINVAL); 1029 1030 return; 1030 1031 } … … 1037 1038 msg = async_send_3(fs_phone, VFS_OUT_STAT, file->node->devmap_handle, 1038 1039 file->node->index, true, NULL); 1039 async_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);1040 ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 1040 1041 async_wait_for(msg, &rc); 1041 1042 vfs_release_phone(file->node->fs_handle, fs_phone); … … 1043 1044 fibril_mutex_unlock(&file->lock); 1044 1045 vfs_file_put(file); 1045 async_answer_0(rid, rc);1046 ipc_answer_0(rid, rc); 1046 1047 } 1047 1048 … … 1051 1052 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL); 1052 1053 if (rc != EOK) { 1053 async_answer_0(rid, rc);1054 ipc_answer_0(rid, rc); 1054 1055 return; 1055 1056 } … … 1058 1059 if (!async_data_read_receive(&callid, NULL)) { 1059 1060 free(path); 1060 async_answer_0(callid, EINVAL);1061 async_answer_0(rid, EINVAL);1061 ipc_answer_0(callid, EINVAL); 1062 ipc_answer_0(rid, EINVAL); 1062 1063 return; 1063 1064 } … … 1069 1070 if (rc != EOK) { 1070 1071 fibril_rwlock_read_unlock(&namespace_rwlock); 1071 async_answer_0(callid, rc);1072 async_answer_0(rid, rc);1072 ipc_answer_0(callid, rc); 1073 ipc_answer_0(rid, rc); 1073 1074 return; 1074 1075 } … … 1076 1077 if (!node) { 1077 1078 fibril_rwlock_read_unlock(&namespace_rwlock); 1078 async_answer_0(callid, ENOMEM);1079 async_answer_0(rid, ENOMEM);1079 ipc_answer_0(callid, ENOMEM); 1080 ipc_answer_0(rid, ENOMEM); 1080 1081 return; 1081 1082 } … … 1087 1088 msg = async_send_3(fs_phone, VFS_OUT_STAT, node->devmap_handle, 1088 1089 node->index, false, NULL); 1089 async_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);1090 ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 1090 1091 1091 1092 sysarg_t rv; … … 1093 1094 vfs_release_phone(node->fs_handle, fs_phone); 1094 1095 1095 async_answer_0(rid, rv);1096 ipc_answer_0(rid, rv); 1096 1097 1097 1098 vfs_node_put(node); … … 1105 1106 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL); 1106 1107 if (rc != EOK) { 1107 async_answer_0(rid, rc);1108 ipc_answer_0(rid, rc); 1108 1109 return; 1109 1110 } … … 1117 1118 fibril_rwlock_write_unlock(&namespace_rwlock); 1118 1119 free(path); 1119 async_answer_0(rid, rc);1120 ipc_answer_0(rid, rc); 1120 1121 } 1121 1122 … … 1127 1128 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL); 1128 1129 if (rc != EOK) { 1129 async_answer_0(rid, rc);1130 ipc_answer_0(rid, rc); 1130 1131 return; 1131 1132 } … … 1138 1139 if (rc != EOK) { 1139 1140 fibril_rwlock_write_unlock(&namespace_rwlock); 1140 async_answer_0(rid, rc);1141 ipc_answer_0(rid, rc); 1141 1142 return; 1142 1143 } … … 1153 1154 fibril_rwlock_write_unlock(&namespace_rwlock); 1154 1155 vfs_node_put(node); 1155 async_answer_0(rid, EOK);1156 ipc_answer_0(rid, EOK); 1156 1157 } 1157 1158 … … 1162 1163 int rc = async_data_write_accept((void **) &old, true, 0, 0, 0, NULL); 1163 1164 if (rc != EOK) { 1164 async_answer_0(rid, rc);1165 ipc_answer_0(rid, rc); 1165 1166 return; 1166 1167 } … … 1171 1172 if (rc != EOK) { 1172 1173 free(old); 1173 async_answer_0(rid, rc);1174 ipc_answer_0(rid, rc); 1174 1175 return; 1175 1176 } … … 1181 1182 1182 1183 if ((!oldc) || (!newc)) { 1183 async_answer_0(rid, EINVAL);1184 ipc_answer_0(rid, EINVAL); 1184 1185 free(old); 1185 1186 free(new); … … 1200 1201 * - oldc and newc are equal. 1201 1202 */ 1202 async_answer_0(rid, EINVAL);1203 ipc_answer_0(rid, EINVAL); 1203 1204 free(old); 1204 1205 free(new); … … 1215 1216 if (rc != EOK) { 1216 1217 fibril_rwlock_write_unlock(&namespace_rwlock); 1217 async_answer_0(rid, rc);1218 ipc_answer_0(rid, rc); 1218 1219 free(old); 1219 1220 free(new); … … 1224 1225 if (!old_node) { 1225 1226 fibril_rwlock_write_unlock(&namespace_rwlock); 1226 async_answer_0(rid, ENOMEM);1227 ipc_answer_0(rid, ENOMEM); 1227 1228 free(old); 1228 1229 free(new); … … 1234 1235 if (!parentc) { 1235 1236 fibril_rwlock_write_unlock(&namespace_rwlock); 1236 async_answer_0(rid, rc);1237 ipc_answer_0(rid, rc); 1237 1238 free(old); 1238 1239 free(new); … … 1251 1252 if (rc != EOK) { 1252 1253 fibril_rwlock_write_unlock(&namespace_rwlock); 1253 async_answer_0(rid, rc);1254 ipc_answer_0(rid, rc); 1254 1255 free(old); 1255 1256 free(new); … … 1261 1262 (old_node->devmap_handle != new_par_lr.triplet.devmap_handle)) { 1262 1263 fibril_rwlock_write_unlock(&namespace_rwlock); 1263 async_answer_0(rid, EXDEV); /* different file systems */1264 ipc_answer_0(rid, EXDEV); /* different file systems */ 1264 1265 free(old); 1265 1266 free(new); … … 1279 1280 if (!new_node) { 1280 1281 fibril_rwlock_write_unlock(&namespace_rwlock); 1281 async_answer_0(rid, ENOMEM);1282 ipc_answer_0(rid, ENOMEM); 1282 1283 free(old); 1283 1284 free(new); … … 1290 1291 default: 1291 1292 fibril_rwlock_write_unlock(&namespace_rwlock); 1292 async_answer_0(rid, ENOTEMPTY);1293 ipc_answer_0(rid, ENOTEMPTY); 1293 1294 free(old); 1294 1295 free(new); … … 1302 1303 if (new_node) 1303 1304 vfs_node_put(new_node); 1304 async_answer_0(rid, rc);1305 ipc_answer_0(rid, rc); 1305 1306 free(old); 1306 1307 free(new); … … 1319 1320 if (new_node) 1320 1321 vfs_node_put(new_node); 1321 async_answer_0(rid, rc);1322 ipc_answer_0(rid, rc); 1322 1323 free(old); 1323 1324 free(new); … … 1336 1337 free(old); 1337 1338 free(new); 1338 async_answer_0(rid, EOK);1339 ipc_answer_0(rid, EOK); 1339 1340 } 1340 1341 … … 1346 1347 /* If the file descriptors are the same, do nothing. */ 1347 1348 if (oldfd == newfd) { 1348 async_answer_1(rid, EOK, newfd);1349 ipc_answer_1(rid, EOK, newfd); 1349 1350 return; 1350 1351 } … … 1353 1354 vfs_file_t *oldfile = vfs_file_get(oldfd); 1354 1355 if (!oldfile) { 1355 async_answer_0(rid, EBADF);1356 ipc_answer_0(rid, EBADF); 1356 1357 return; 1357 1358 } … … 1372 1373 vfs_file_put(oldfile); 1373 1374 vfs_file_put(newfile); 1374 async_answer_0(rid, ret);1375 ipc_answer_0(rid, ret); 1375 1376 return; 1376 1377 } … … 1381 1382 vfs_file_put(oldfile); 1382 1383 vfs_file_put(newfile); 1383 async_answer_0(rid, ret);1384 ipc_answer_0(rid, ret); 1384 1385 return; 1385 1386 } … … 1393 1394 1394 1395 if (ret != EOK) 1395 async_answer_0(rid, ret);1396 ipc_answer_0(rid, ret); 1396 1397 else 1397 async_answer_1(rid, EOK, newfd);1398 ipc_answer_1(rid, EOK, newfd); 1398 1399 } 1399 1400
Note:
See TracChangeset
for help on using the changeset viewer.