Changeset 354b642 in mainline
- Timestamp:
- 2017-03-07T10:53:31Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a274a5f
- Parents:
- c577a9a
- git-author:
- Jiri Zarevucky <zarevucky.jiri@…> (2017-03-07 10:53:31)
- git-committer:
- Jakub Jermar <jakub@…> (2017-03-07 10:53:31)
- Location:
- uspace
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/loader.c
rc577a9a r354b642 271 271 272 272 for (i = 0; files[i]; i++) { 273 rc = async_state_change_start(exch, VFS_PASS_HANDLE, *files[i], 274 0, vfs_exch); 273 rc = vfs_pass_handle(vfs_exch, *files[i], exch); 275 274 if (rc != EOK) 276 275 break; -
uspace/lib/c/generic/vfs/vfs.c
rc577a9a r354b642 419 419 req = async_send_1(exch, VFS_IN_READ, fildes, &answer); 420 420 rc = async_data_read_start(exch, (void *) buf, nbyte); 421 if (rc != EOK) { 422 vfs_exchange_end(exch); 423 424 sysarg_t rc_orig; 425 async_wait_for(req, &rc_orig); 426 427 if (rc_orig == EOK) 428 return rc; 429 else 430 return rc_orig; 431 } 432 433 vfs_exchange_end(exch); 434 async_wait_for(req, &rc); 421 422 vfs_exchange_end(exch); 423 424 if (rc == EOK) { 425 async_wait_for(req, &rc); 426 } else { 427 async_forget(req); 428 } 435 429 436 430 if (rc != EOK) … … 467 461 req = async_send_1(exch, VFS_IN_WRITE, fildes, &answer); 468 462 rc = async_data_write_start(exch, (void *) buf, nbyte); 469 if (rc != EOK) { 470 vfs_exchange_end(exch); 471 472 sysarg_t rc_orig; 473 async_wait_for(req, &rc_orig); 474 475 if (rc_orig == EOK) 476 return rc; 477 else 478 return rc_orig; 479 } 480 481 vfs_exchange_end(exch); 482 async_wait_for(req, &rc); 483 463 464 vfs_exchange_end(exch); 465 466 if (rc == EOK) { 467 async_wait_for(req, &rc); 468 } else { 469 async_forget(req); 470 } 471 484 472 if (rc != EOK) 485 473 return rc; … … 1055 1043 } 1056 1044 1057 int vfs_fd_wait(void)1058 {1059 async_exch_t *exch = vfs_exchange_begin();1060 1061 sysarg_t ret;1062 sysarg_t rc = async_req_0_1(exch, VFS_IN_WAIT_HANDLE, &ret);1063 1064 vfs_exchange_end(exch);1065 1066 if (rc == EOK)1067 return (int) ret;1068 1069 return (int) rc;1070 }1071 1072 1045 int vfs_get_mtab_list(list_t *mtab_list) 1073 1046 { … … 1172 1145 } 1173 1146 1147 int vfs_pass_handle(async_exch_t *vfs_exch, int file, async_exch_t *exch) 1148 { 1149 return async_state_change_start(exch, VFS_PASS_HANDLE, (sysarg_t)file, 0, vfs_exch); 1150 } 1151 1152 int vfs_receive_handle() 1153 { 1154 ipc_callid_t callid; 1155 if (!async_state_change_receive(&callid, NULL, NULL, NULL)) { 1156 async_answer_0(callid, EINVAL); 1157 return EINVAL; 1158 } 1159 1160 async_exch_t *vfs_exch = vfs_exchange_begin(); 1161 1162 async_state_change_finalize(callid, vfs_exch); 1163 1164 sysarg_t ret; 1165 sysarg_t rc = async_req_0_1(vfs_exch, VFS_IN_WAIT_HANDLE, &ret); 1166 1167 async_exchange_end(vfs_exch); 1168 1169 if (rc != EOK) { 1170 return rc; 1171 } 1172 return ret; 1173 } 1174 1175 int vfs_clone(int file, bool high_descriptor) 1176 { 1177 async_exch_t *vfs_exch = vfs_exchange_begin(); 1178 int rc = async_req_2_0(vfs_exch, VFS_IN_CLONE, (sysarg_t) file, (sysarg_t) high_descriptor); 1179 vfs_exchange_end(vfs_exch); 1180 return rc; 1181 } 1182 1174 1183 /** @} 1175 1184 */ -
uspace/lib/c/include/ipc/vfs.h
rc577a9a r354b642 83 83 VFS_IN_OPEN2, 84 84 VFS_IN_UNLINK2, 85 VFS_IN_CLONE, 85 86 } vfs_in_request_t; 86 87 -
uspace/lib/c/include/vfs/vfs.h
rc577a9a r354b642 58 58 extern int vfs_fhandle(FILE *, int *); 59 59 60 extern int vfs_fd_wait(void);61 60 extern int vfs_get_mtab_list(list_t *mtab_list); 62 61 … … 67 66 extern int _vfs_open(int file, int mode); 68 67 68 extern int vfs_pass_handle(async_exch_t *vfs_exch, int file, async_exch_t *exch); 69 extern int vfs_receive_handle(void); 70 71 extern int vfs_clone(int file, bool high_descriptor); 72 73 69 74 #endif 70 75 -
uspace/srv/loader/main.c
rc577a9a r354b642 227 227 228 228 for (filc = 0; filc < count; filc++) { 229 ipc_callid_t callid; 230 int fd; 231 232 if (!async_state_change_receive(&callid, NULL, NULL, NULL)) { 233 async_answer_0(callid, EINVAL); 229 int fd = vfs_receive_handle(); 230 if (fd < 0) { 234 231 break; 235 232 } 236 async_state_change_finalize(callid, vfs_exch);237 fd = vfs_fd_wait();238 233 assert(fd == (int) filc); 239 234 } -
uspace/srv/vfs/vfs.c
rc577a9a r354b642 149 149 vfs_statfs(callid, &call); 150 150 break; 151 case VFS_IN_CLONE: 152 vfs_op_clone(callid, &call); 153 break; 151 154 default: 152 155 async_answer_0(callid, ENOTSUP); … … 164 167 { 165 168 if (IPC_GET_ARG1(*call) == VFS_PASS_HANDLE) 166 vfs_ pass_handle(169 vfs_op_pass_handle( 167 170 (task_id_t) MERGE_LOUP32(IPC_GET_ARG4(*call), 168 171 IPC_GET_ARG5(*call)), call->in_task_id, -
uspace/srv/vfs/vfs.h
rc577a9a r354b642 196 196 extern void vfs_client_data_destroy(void *); 197 197 198 extern void vfs_ pass_handle(task_id_t, task_id_t, int);198 extern void vfs_op_pass_handle(task_id_t, task_id_t, int); 199 199 extern int vfs_wait_handle_internal(void); 200 200 … … 237 237 extern void vfs_open2(ipc_callid_t, ipc_call_t *); 238 238 extern void vfs_unlink2(ipc_callid_t, ipc_call_t *); 239 extern void vfs_op_clone(ipc_callid_t, ipc_call_t *); 239 240 240 241 #endif -
uspace/srv/vfs/vfs_file.c
rc577a9a r354b642 360 360 } 361 361 362 void vfs_ pass_handle(task_id_t donor_id, task_id_t acceptor_id, int donor_fd)362 void vfs_op_pass_handle(task_id_t donor_id, task_id_t acceptor_id, int donor_fd) 363 363 { 364 364 vfs_client_data_t *donor_data = NULL; … … 397 397 */ 398 398 vfs_node_addref(donor_file->node); 399 (void) vfs_open_node_remote(donor_file->node);400 399 401 400 assert(acceptor_file); … … 412 411 acceptor_file->open_read = donor_file->open_read; 413 412 acceptor_file->open_write = donor_file->open_write; 413 414 if (acceptor_file->open_read || acceptor_file->open_write) { 415 (void) vfs_open_node_remote(acceptor_file->node); 416 } 414 417 415 418 out: -
uspace/srv/vfs/vfs_ops.c
rc577a9a r354b642 696 696 vfs_file_t *file = vfs_file_get(fd); 697 697 if (!file) 698 return E NOENT;698 return EBADF; 699 699 700 700 if ((read && !file->open_read) || (!read && !file->open_write)) { … … 705 705 vfs_info_t *fs_info = fs_handle_to_info(file->node->fs_handle); 706 706 assert(fs_info); 707 708 bool rlock = read || ((fs_info->concurrent_read_write) && (fs_info->write_retains_size)); 707 709 708 710 /* … … 711 713 * write implementation does not modify the file size. 712 714 */ 713 if ((read) || 714 ((fs_info->concurrent_read_write) && (fs_info->write_retains_size))) 715 if (rlock) { 715 716 fibril_rwlock_read_lock(&file->node->contents_rwlock); 716 else717 } else { 717 718 fibril_rwlock_write_lock(&file->node->contents_rwlock); 719 } 718 720 719 721 if (file->node->type == VFS_NODE_DIRECTORY) { … … 722 724 * while we are in readdir(). 723 725 */ 724 assert(read); 726 727 if (!read) { 728 if (rlock) { 729 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 730 } else { 731 fibril_rwlock_write_unlock(&file->node->contents_rwlock); 732 } 733 vfs_file_put(file); 734 return EINVAL; 735 } 736 725 737 fibril_rwlock_read_lock(&namespace_rwlock); 726 738 } … … 746 758 747 759 /* Unlock the VFS node. */ 748 if ((read) || 749 ((fs_info->concurrent_read_write) && (fs_info->write_retains_size))) 760 if (rlock) { 750 761 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 751 else {762 } else { 752 763 /* Update the cached version of node's size. */ 753 if (rc == EOK) 764 if (rc == EOK) { 754 765 file->node->size = MERGE_LOUP32(IPC_GET_ARG2(answer), 755 766 IPC_GET_ARG3(answer)); 767 } 756 768 fibril_rwlock_write_unlock(&file->node->contents_rwlock); 757 769 } 758 770 759 771 /* Update the position pointer and unlock the open file. */ 760 if (rc == EOK) 772 if (rc == EOK) { 761 773 file->pos += bytes; 774 } 762 775 vfs_file_put(file); 763 776 … … 1354 1367 } 1355 1368 1369 void vfs_op_clone(ipc_callid_t rid, ipc_call_t *request) 1370 { 1371 int oldfd = IPC_GET_ARG1(*request); 1372 bool desc = IPC_GET_ARG2(*request); 1373 1374 /* Lookup the file structure corresponding to fd. */ 1375 vfs_file_t *oldfile = vfs_file_get(oldfd); 1376 if (!oldfile) { 1377 async_answer_0(rid, EBADF); 1378 return; 1379 } 1380 1381 vfs_file_t *newfile; 1382 int newfd = vfs_fd_alloc(&newfile, desc); 1383 if (newfd < 0) { 1384 async_answer_0(rid, newfd); 1385 vfs_file_put(oldfile); 1386 return; 1387 } 1388 1389 assert(oldfile->node != NULL); 1390 1391 newfile->node = oldfile->node; 1392 newfile->permissions = oldfile->permissions; 1393 1394 vfs_file_put(oldfile); 1395 vfs_file_put(newfile); 1396 1397 async_answer_0(rid, newfd); 1398 } 1399 1356 1400 /** 1357 1401 * @}
Note:
See TracChangeset
for help on using the changeset viewer.