Changeset 7bdcc45 in mainline for uspace/srv/vfs
- Timestamp:
- 2010-12-16T16:38:49Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7837101
- Parents:
- 8e58f94 (diff), eb221e5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/srv/vfs
- Files:
-
- 6 edited
-
vfs.c (modified) (2 diffs)
-
vfs.h (modified) (2 diffs)
-
vfs_lookup.c (modified) (2 diffs)
-
vfs_node.c (modified) (1 diff)
-
vfs_ops.c (modified) (22 diffs)
-
vfs_register.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs.c
r8e58f94 r7bdcc45 73 73 ipc_callid_t callid = async_get_call(&call); 74 74 75 switch (IPC_GET_ METHOD(call)) {75 switch (IPC_GET_IMETHOD(call)) { 76 76 case IPC_M_PHONE_HUNGUP: 77 77 keep_on_going = false; … … 173 173 * Register at the naming service. 174 174 */ 175 ipcarg_t phonead;175 sysarg_t phonead; 176 176 ipc_connect_to_me(PHONE_NS, SERVICE_VFS, 0, 0, &phonead); 177 177 -
uspace/srv/vfs/vfs.h
r8e58f94 r7bdcc45 54 54 fs_handle_t fs_handle; 55 55 fibril_mutex_t phone_lock; 56 ipcarg_t phone;56 sysarg_t phone; 57 57 } fs_info_t; 58 58 … … 172 172 173 173 extern fs_handle_t fs_name_to_handle(char *, bool); 174 extern vfs_info_t *fs_handle_to_info(fs_handle_t); 174 175 175 176 extern int vfs_lookup_internal(char *, int, vfs_lookup_res_t *, -
uspace/srv/vfs/vfs_lookup.c
r8e58f94 r7bdcc45 161 161 ipc_call_t answer; 162 162 int phone = vfs_grab_phone(root->fs_handle); 163 aid_t req = async_send_5(phone, VFS_OUT_LOOKUP, ( ipcarg_t) first,164 ( ipcarg_t) (first + len - 1) % PLB_SIZE,165 ( ipcarg_t) root->devmap_handle, (ipcarg_t) lflag, (ipcarg_t) index,163 aid_t req = async_send_5(phone, VFS_OUT_LOOKUP, (sysarg_t) first, 164 (sysarg_t) (first + len - 1) % PLB_SIZE, 165 (sysarg_t) root->devmap_handle, (sysarg_t) lflag, (sysarg_t) index, 166 166 &answer); 167 167 168 ipcarg_t rc;168 sysarg_t rc; 169 169 async_wait_for(req, &rc); 170 170 vfs_release_phone(root->fs_handle, phone); … … 210 210 ipc_call_t answer; 211 211 aid_t req = async_send_2(phone, VFS_OUT_OPEN_NODE, 212 ( ipcarg_t) result->triplet.devmap_handle,213 ( ipcarg_t) result->triplet.index, &answer);214 215 ipcarg_t rc;212 (sysarg_t) result->triplet.devmap_handle, 213 (sysarg_t) result->triplet.index, &answer); 214 215 sysarg_t rc; 216 216 async_wait_for(req, &rc); 217 217 vfs_release_phone(result->triplet.fs_handle, phone); -
uspace/srv/vfs/vfs_node.c
r8e58f94 r7bdcc45 129 129 */ 130 130 int phone = vfs_grab_phone(node->fs_handle); 131 ipcarg_t rc;131 sysarg_t rc; 132 132 rc = async_req_2_0(phone, VFS_OUT_DESTROY, 133 ( ipcarg_t)node->devmap_handle, (ipcarg_t)node->index);133 (sysarg_t)node->devmap_handle, (sysarg_t)node->index); 134 134 assert(rc == EOK); 135 135 vfs_release_phone(node->fs_handle, phone); -
uspace/srv/vfs/vfs_ops.c
r8e58f94 r7bdcc45 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); -
uspace/srv/vfs/vfs_register.c
r8e58f94 r7bdcc45 177 177 ipc_call_t call; 178 178 ipc_callid_t callid = async_get_call(&call); 179 if (IPC_GET_ METHOD(call) != IPC_M_CONNECT_TO_ME) {180 dprintf("Unexpected call, method = %d\n", IPC_GET_ METHOD(call));179 if (IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) { 180 dprintf("Unexpected call, method = %d\n", IPC_GET_IMETHOD(call)); 181 181 list_remove(&fs_info->fs_link); 182 182 fibril_mutex_unlock(&fs_head_lock); … … 197 197 size_t size; 198 198 if (!async_share_in_receive(&callid, &size)) { 199 dprintf("Unexpected call, method = %d\n", IPC_GET_ METHOD(call));199 dprintf("Unexpected call, method = %d\n", IPC_GET_IMETHOD(call)); 200 200 list_remove(&fs_info->fs_link); 201 201 fibril_mutex_unlock(&fs_head_lock); … … 235 235 */ 236 236 fs_info->fs_handle = (fs_handle_t) atomic_postinc(&fs_handle_next); 237 ipc_answer_1(rid, EOK, ( ipcarg_t) fs_info->fs_handle);237 ipc_answer_1(rid, EOK, (sysarg_t) fs_info->fs_handle); 238 238 239 239 fibril_condvar_broadcast(&fs_head_cv); … … 333 333 } 334 334 335 /** Find the VFS info structure. 336 * 337 * @param handle FS handle for which the VFS info structure is sought. 338 * @return VFS info structure on success or NULL otherwise. 339 */ 340 vfs_info_t *fs_handle_to_info(fs_handle_t handle) 341 { 342 vfs_info_t *info = NULL; 343 link_t *cur; 344 345 fibril_mutex_lock(&fs_head_lock); 346 for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { 347 fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link); 348 if (fs->fs_handle == handle) { 349 info = &fs->vfs_info; 350 break; 351 } 352 } 353 fibril_mutex_unlock(&fs_head_lock); 354 355 return info; 356 } 357 335 358 /** 336 359 * @}
Note:
See TracChangeset
for help on using the changeset viewer.
