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