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