Changes in uspace/srv/vfs/vfs_ops.c [b4cbef1:19f857a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_ops.c
rb4cbef1 r19f857a 38 38 #include "vfs.h" 39 39 #include <ipc/ipc.h> 40 #include <macros.h> 41 #include <limits.h> 40 42 #include <async.h> 41 43 #include <errno.h> 42 44 #include <stdio.h> 43 45 #include <stdlib.h> 44 #include <str ing.h>46 #include <str.h> 45 47 #include <bool.h> 46 48 #include <fibril_synch.h> … … 53 55 54 56 /* Forward declarations of static functions. */ 55 static int vfs_truncate_internal(fs_handle_t, dev_handle_t, fs_index_t, size_t);57 static int vfs_truncate_internal(fs_handle_t, dev_handle_t, fs_index_t, aoff64_t); 56 58 57 59 /** … … 267 269 /* We want the client to send us the mount point. */ 268 270 char *mp; 269 int rc = async_string_receive(&mp, MAX_PATH_LEN, NULL); 271 int rc = async_data_write_accept((void **) &mp, true, 0, MAX_PATH_LEN, 272 0, NULL); 270 273 if (rc != EOK) { 271 274 ipc_answer_0(rid, rc); … … 275 278 /* Now we expect to receive the mount options. */ 276 279 char *opts; 277 rc = async_string_receive(&opts, MAX_MNTOPTS_LEN, NULL); 280 rc = async_data_write_accept((void **) &opts, true, 0, MAX_MNTOPTS_LEN, 281 0, NULL); 278 282 if (rc != EOK) { 279 283 free(mp); … … 287 291 */ 288 292 char *fs_name; 289 rc = async_string_receive(&fs_name, FS_NAME_MAXLEN, NULL); 293 rc = async_data_write_accept((void **) &fs_name, true, 0, FS_NAME_MAXLEN, 294 0, NULL); 290 295 if (rc != EOK) { 291 296 free(mp); … … 350 355 vfs_lookup_res_t mp_res; 351 356 vfs_lookup_res_t mr_res; 352 vfs_node_t *mp_node;353 357 vfs_node_t *mr_node; 354 358 int phone; … … 357 361 * Receive the mount point path. 358 362 */ 359 rc = async_string_receive(&mp, MAX_PATH_LEN, NULL); 363 rc = async_data_write_accept((void **) &mp, true, 0, MAX_PATH_LEN, 364 0, NULL); 360 365 if (rc != EOK) 361 366 ipc_answer_0(rid, rc); … … 499 504 int oflag = IPC_GET_ARG2(*request); 500 505 int mode = IPC_GET_ARG3(*request); 501 size_t len;502 506 503 507 /* Ignore mode for now. */ … … 522 526 523 527 char *path; 524 int rc = async_ string_receive(&path, 0, NULL);528 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL); 525 529 if (rc != EOK) { 526 530 ipc_answer_0(rid, rc); … … 836 840 &answer); 837 841 } else { 838 rc = async_data_ forward_3_1(fs_phone, VFS_OUT_WRITE,842 rc = async_data_write_forward_3_1(fs_phone, VFS_OUT_WRITE, 839 843 file->node->dev_handle, file->node->index, file->pos, 840 844 &answer); … … 883 887 { 884 888 int fd = (int) IPC_GET_ARG1(*request); 885 off _t off = (off_t) IPC_GET_ARG2(*request);886 int whence = (int) IPC_GET_ARG3(*request);887 888 889 off64_t off = 890 (off64_t) MERGE_LOUP32(IPC_GET_ARG2(*request), IPC_GET_ARG3(*request)); 891 int whence = (int) IPC_GET_ARG4(*request); 892 889 893 /* Lookup the file structure corresponding to the file descriptor. */ 890 894 vfs_file_t *file = vfs_file_get(fd); … … 893 897 return; 894 898 } 895 896 off_t newpos; 899 897 900 fibril_mutex_lock(&file->lock); 898 if (whence == SEEK_SET) { 899 file->pos = off; 900 fibril_mutex_unlock(&file->lock); 901 ipc_answer_1(rid, EOK, off); 902 return; 903 } 904 if (whence == SEEK_CUR) { 905 if (file->pos + off < file->pos) { 901 902 off64_t newoff; 903 switch (whence) { 904 case SEEK_SET: 905 if (off >= 0) { 906 file->pos = (aoff64_t) off; 907 fibril_mutex_unlock(&file->lock); 908 ipc_answer_1(rid, EOK, off); 909 return; 910 } 911 break; 912 case SEEK_CUR: 913 if ((off >= 0) && (file->pos + off < file->pos)) { 914 fibril_mutex_unlock(&file->lock); 915 ipc_answer_0(rid, EOVERFLOW); 916 return; 917 } 918 919 if ((off < 0) && (file->pos < (aoff64_t) -off)) { 920 fibril_mutex_unlock(&file->lock); 921 ipc_answer_0(rid, EOVERFLOW); 922 return; 923 } 924 925 file->pos += off; 926 newoff = (file->pos > OFF64_MAX) ? OFF64_MAX : file->pos; 927 906 928 fibril_mutex_unlock(&file->lock); 907 ipc_answer_ 0(rid, EOVERFLOW);929 ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff)); 908 930 return; 909 } 910 file->pos += off; 911 newpos = file->pos; 912 fibril_mutex_unlock(&file->lock); 913 ipc_answer_1(rid, EOK, newpos); 914 return; 915 } 916 if (whence == SEEK_END) { 917 fibril_rwlock_read_lock(&file->node->contents_rwlock); 918 size_t size = file->node->size; 919 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 920 if (size + off < size) { 931 case SEEK_END: 932 fibril_rwlock_read_lock(&file->node->contents_rwlock); 933 aoff64_t size = file->node->size; 934 935 if ((off >= 0) && (size + off < size)) { 936 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 937 fibril_mutex_unlock(&file->lock); 938 ipc_answer_0(rid, EOVERFLOW); 939 return; 940 } 941 942 if ((off < 0) && (size < (aoff64_t) -off)) { 943 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 944 fibril_mutex_unlock(&file->lock); 945 ipc_answer_0(rid, EOVERFLOW); 946 return; 947 } 948 949 file->pos = size + off; 950 newoff = (file->pos > OFF64_MAX) ? OFF64_MAX : file->pos; 951 952 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 921 953 fibril_mutex_unlock(&file->lock); 922 ipc_answer_ 0(rid, EOVERFLOW);954 ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff)); 923 955 return; 924 } 925 newpos = size + off; 926 file->pos = newpos; 927 fibril_mutex_unlock(&file->lock); 928 ipc_answer_1(rid, EOK, newpos); 929 return; 930 } 956 } 957 931 958 fibril_mutex_unlock(&file->lock); 932 959 ipc_answer_0(rid, EINVAL); 933 960 } 934 961 935 int 936 vfs_truncate_internal(fs_handle_t fs_handle, dev_handle_t dev_handle, 937 fs_index_t index, size_t size) 962 int vfs_truncate_internal(fs_handle_t fs_handle, dev_handle_t dev_handle, 963 fs_index_t index, aoff64_t size) 938 964 { 939 965 ipcarg_t rc; … … 941 967 942 968 fs_phone = vfs_grab_phone(fs_handle); 943 rc = async_req_ 3_0(fs_phone, VFS_OUT_TRUNCATE, (ipcarg_t)dev_handle,944 (ipcarg_t) index, (ipcarg_t)size);969 rc = async_req_4_0(fs_phone, VFS_OUT_TRUNCATE, (ipcarg_t) dev_handle, 970 (ipcarg_t) index, LOWER32(size), UPPER32(size)); 945 971 vfs_release_phone(fs_phone); 946 972 return (int)rc; … … 950 976 { 951 977 int fd = IPC_GET_ARG1(*request); 952 size_t size = IPC_GET_ARG2(*request); 978 aoff64_t size = 979 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(*request), IPC_GET_ARG3(*request)); 953 980 int rc; 954 981 … … 1007 1034 { 1008 1035 char *path; 1009 int rc = async_ string_receive(&path, 0, NULL);1036 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL); 1010 1037 if (rc != EOK) { 1011 1038 ipc_answer_0(rid, rc); … … 1061 1088 1062 1089 char *path; 1063 int rc = async_ string_receive(&path, 0, NULL);1090 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL); 1064 1091 if (rc != EOK) { 1065 1092 ipc_answer_0(rid, rc); … … 1083 1110 1084 1111 char *path; 1085 int rc = async_ string_receive(&path, 0, NULL);1112 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL); 1086 1113 if (rc != EOK) { 1087 1114 ipc_answer_0(rid, rc); … … 1118 1145 /* Retrieve the old path. */ 1119 1146 char *old; 1120 int rc = async_ string_receive(&old, 0, NULL);1147 int rc = async_data_write_accept((void **) &old, true, 0, 0, 0, NULL); 1121 1148 if (rc != EOK) { 1122 1149 ipc_answer_0(rid, rc); … … 1126 1153 /* Retrieve the new path. */ 1127 1154 char *new; 1128 rc = async_ string_receive(&new, 0, NULL);1155 rc = async_data_write_accept((void **) &new, true, 0, 0, 0, NULL); 1129 1156 if (rc != EOK) { 1130 1157 free(old);
Note:
See TracChangeset
for help on using the changeset viewer.