Changes in uspace/srv/vfs/vfs_ops.c [991f645:228e490] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_ops.c
r991f645 r228e490 55 55 56 56 /* Forward declarations of static functions. */ 57 static int vfs_truncate_internal(fs_handle_t, devmap_handle_t, fs_index_t, aoff64_t); 57 static int vfs_truncate_internal(fs_handle_t, devmap_handle_t, fs_index_t, 58 aoff64_t); 58 59 59 60 /** … … 78 79 size_t rsize; 79 80 unsigned rlnkcnt; 80 ipcarg_t rc;81 sysarg_t rc; 81 82 int phone; 82 83 aid_t msg; … … 125 126 phone = vfs_grab_phone(fs_handle); 126 127 msg = async_send_1(phone, VFS_OUT_MOUNTED, 127 ( ipcarg_t) devmap_handle, &answer);128 (sysarg_t) devmap_handle, &answer); 128 129 /* send the mount options */ 129 130 rc = async_data_write_start(phone, (void *)opts, … … 187 188 phone = vfs_grab_phone(mp_res.triplet.fs_handle); 188 189 msg = async_send_4(phone, VFS_OUT_MOUNT, 189 ( ipcarg_t) mp_res.triplet.devmap_handle,190 ( ipcarg_t) mp_res.triplet.index,191 ( ipcarg_t) fs_handle,192 ( ipcarg_t) devmap_handle, &answer);190 (sysarg_t) mp_res.triplet.devmap_handle, 191 (sysarg_t) mp_res.triplet.index, 192 (sysarg_t) fs_handle, 193 (sysarg_t) devmap_handle, &answer); 193 194 194 195 /* send connection */ … … 250 251 void vfs_mount(ipc_callid_t rid, ipc_call_t *request) 251 252 { 253 devmap_handle_t devmap_handle; 254 252 255 /* 253 256 * We expect the library to do the device-name to device-handle … … 255 258 * in the request. 256 259 */ 257 devmap_handle _t devmap_handle= (devmap_handle_t) IPC_GET_ARG1(*request);260 devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 258 261 259 262 /* … … 291 294 */ 292 295 char *fs_name; 293 rc = async_data_write_accept((void **) &fs_name, true, 0, FS_NAME_MAXLEN,294 0, NULL);296 rc = async_data_write_accept((void **) &fs_name, true, 0, 297 FS_NAME_MAXLEN, 0, NULL); 295 298 if (rc != EOK) { 296 299 free(mp); … … 306 309 ipc_call_t data; 307 310 ipc_callid_t callid = async_get_call(&data); 308 if (IPC_GET_ METHOD(data) != IPC_M_PING) {311 if (IPC_GET_IMETHOD(data) != IPC_M_PING) { 309 312 ipc_answer_0(callid, ENOTSUP); 310 313 ipc_answer_0(rid, ENOTSUP); … … 458 461 459 462 phone = vfs_grab_phone(mp_node->fs_handle); 460 rc = async_req_2_0(phone, VFS_OUT_UNMOUNT, mp_node->devmap_handle,461 mp_node-> index);463 rc = async_req_2_0(phone, VFS_OUT_UNMOUNT, 464 mp_node->devmap_handle, mp_node->index); 462 465 vfs_release_phone(mp_node->fs_handle, phone); 463 466 if (rc != EOK) { … … 713 716 714 717 /* Wait for reply from the FS server. */ 715 ipcarg_t rc;718 sysarg_t rc; 716 719 async_wait_for(msg, &rc); 717 720 … … 740 743 aid_t msg; 741 744 ipc_call_t answer; 742 msg = async_send_2(fs_phone, VFS_OUT_CLOSE, file->node->devmap_handle,743 file->node-> index, &answer);745 msg = async_send_2(fs_phone, VFS_OUT_CLOSE, 746 file->node->devmap_handle, file->node->index, &answer); 744 747 745 748 /* Wait for reply from the FS server. */ 746 ipcarg_t rc;749 sysarg_t rc; 747 750 async_wait_for(msg, &rc); 748 751 … … 778 781 static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read) 779 782 { 783 vfs_info_t *vi; 780 784 781 785 /* … … 804 808 fibril_mutex_lock(&file->lock); 805 809 810 vi = fs_handle_to_info(file->node->fs_handle); 811 assert(vi); 812 806 813 /* 807 814 * Lock the file's node so that no other client can read/write to it at 808 * the same time. 809 */ 810 if (read) 815 * the same time unless the FS supports concurrent reads/writes and its 816 * write implementation does not modify the file size. 817 */ 818 if (read || (vi->concurrent_read_write && vi->write_retains_size)) 811 819 fibril_rwlock_read_lock(&file->node->contents_rwlock); 812 820 else … … 831 839 * don't have to bother. 832 840 */ 833 ipcarg_t rc;841 sysarg_t rc; 834 842 ipc_call_t answer; 835 843 if (read) { 836 if (file->append)837 file->pos = file->node->size;838 839 844 rc = async_data_read_forward_3_1(fs_phone, VFS_OUT_READ, 840 845 file->node->devmap_handle, file->node->index, file->pos, 841 846 &answer); 842 847 } else { 848 if (file->append) 849 file->pos = file->node->size; 850 843 851 rc = async_data_write_forward_3_1(fs_phone, VFS_OUT_WRITE, 844 852 file->node->devmap_handle, file->node->index, file->pos, … … 854 862 855 863 /* Unlock the VFS node. */ 856 if (read )864 if (read || (vi->concurrent_read_write && vi->write_retains_size)) 857 865 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 858 866 else { … … 888 896 { 889 897 int fd = (int) IPC_GET_ARG1(*request); 890 off64_t off = 891 (off64_t) MERGE_LOUP32(IPC_GET_ARG2(*request),IPC_GET_ARG3(*request));898 off64_t off = (off64_t) MERGE_LOUP32(IPC_GET_ARG2(*request), 899 IPC_GET_ARG3(*request)); 892 900 int whence = (int) IPC_GET_ARG4(*request); 893 901 … … 903 911 off64_t newoff; 904 912 switch (whence) { 905 case SEEK_SET: 906 if (off >= 0) { 907 file->pos = (aoff64_t) off; 908 fibril_mutex_unlock(&file->lock); 909 ipc_answer_1(rid, EOK, off); 910 return; 911 } 912 break; 913 case SEEK_CUR: 914 if ((off >= 0) && (file->pos + off < file->pos)) { 915 fibril_mutex_unlock(&file->lock); 916 ipc_answer_0(rid, EOVERFLOW); 917 return; 918 } 919 920 if ((off < 0) && (file->pos < (aoff64_t) -off)) { 921 fibril_mutex_unlock(&file->lock); 922 ipc_answer_0(rid, EOVERFLOW); 923 return; 924 } 925 926 file->pos += off; 927 newoff = (file->pos > OFF64_MAX) ? OFF64_MAX : file->pos; 928 913 case SEEK_SET: 914 if (off >= 0) { 915 file->pos = (aoff64_t) off; 929 916 fibril_mutex_unlock(&file->lock); 930 ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff)); 931 return; 932 case SEEK_END: 933 fibril_rwlock_read_lock(&file->node->contents_rwlock); 934 aoff64_t size = file->node->size; 935 936 if ((off >= 0) && (size + off < size)) { 937 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 938 fibril_mutex_unlock(&file->lock); 939 ipc_answer_0(rid, EOVERFLOW); 940 return; 941 } 942 943 if ((off < 0) && (size < (aoff64_t) -off)) { 944 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 945 fibril_mutex_unlock(&file->lock); 946 ipc_answer_0(rid, EOVERFLOW); 947 return; 948 } 949 950 file->pos = size + off; 951 newoff = (file->pos > OFF64_MAX) ? OFF64_MAX : file->pos; 952 917 ipc_answer_1(rid, EOK, off); 918 return; 919 } 920 break; 921 case SEEK_CUR: 922 if ((off >= 0) && (file->pos + off < file->pos)) { 923 fibril_mutex_unlock(&file->lock); 924 ipc_answer_0(rid, EOVERFLOW); 925 return; 926 } 927 928 if ((off < 0) && (file->pos < (aoff64_t) -off)) { 929 fibril_mutex_unlock(&file->lock); 930 ipc_answer_0(rid, EOVERFLOW); 931 return; 932 } 933 934 file->pos += off; 935 newoff = (file->pos > OFF64_MAX) ? OFF64_MAX : file->pos; 936 937 fibril_mutex_unlock(&file->lock); 938 ipc_answer_2(rid, EOK, LOWER32(newoff), 939 UPPER32(newoff)); 940 return; 941 case SEEK_END: 942 fibril_rwlock_read_lock(&file->node->contents_rwlock); 943 aoff64_t size = file->node->size; 944 945 if ((off >= 0) && (size + off < size)) { 953 946 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 954 947 fibril_mutex_unlock(&file->lock); 955 ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff)); 956 return; 948 ipc_answer_0(rid, EOVERFLOW); 949 return; 950 } 951 952 if ((off < 0) && (size < (aoff64_t) -off)) { 953 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 954 fibril_mutex_unlock(&file->lock); 955 ipc_answer_0(rid, EOVERFLOW); 956 return; 957 } 958 959 file->pos = size + off; 960 newoff = (file->pos > OFF64_MAX) ? OFF64_MAX : file->pos; 961 962 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 963 fibril_mutex_unlock(&file->lock); 964 ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff)); 965 return; 957 966 } 958 967 … … 964 973 fs_index_t index, aoff64_t size) 965 974 { 966 ipcarg_t rc;975 sysarg_t rc; 967 976 int fs_phone; 968 977 969 978 fs_phone = vfs_grab_phone(fs_handle); 970 rc = async_req_4_0(fs_phone, VFS_OUT_TRUNCATE, ( ipcarg_t) devmap_handle,971 ( ipcarg_t) index, LOWER32(size), UPPER32(size));979 rc = async_req_4_0(fs_phone, VFS_OUT_TRUNCATE, (sysarg_t) devmap_handle, 980 (sysarg_t) index, LOWER32(size), UPPER32(size)); 972 981 vfs_release_phone(fs_handle, fs_phone); 973 982 return (int)rc; … … 977 986 { 978 987 int fd = IPC_GET_ARG1(*request); 979 aoff64_t size = 980 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(*request),IPC_GET_ARG3(*request));988 aoff64_t size = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(*request), 989 IPC_GET_ARG3(*request)); 981 990 int rc; 982 991 … … 996 1005 997 1006 fibril_mutex_unlock(&file->lock); 998 ipc_answer_0(rid, ( ipcarg_t)rc);1007 ipc_answer_0(rid, (sysarg_t)rc); 999 1008 } 1000 1009 … … 1002 1011 { 1003 1012 int fd = IPC_GET_ARG1(*request); 1004 ipcarg_t rc;1013 sysarg_t rc; 1005 1014 1006 1015 vfs_file_t *file = vfs_file_get(fd); … … 1075 1084 ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 1076 1085 1077 ipcarg_t rv;1086 sysarg_t rv; 1078 1087 async_wait_for(msg, &rv); 1079 1088 vfs_release_phone(node->fs_handle, fs_phone);
Note:
See TracChangeset
for help on using the changeset viewer.