Changeset 354b642 in mainline for uspace/srv/vfs/vfs_ops.c
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.