Changeset ed903174 in mainline for uspace/srv/vfs/vfs_ops.c
- Timestamp:
- 2010-02-10T23:51:23Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e70edd1
- Parents:
- b32c604f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_ops.c
rb32c604f red903174 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> … … 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 /** … … 353 355 vfs_lookup_res_t mp_res; 354 356 vfs_lookup_res_t mr_res; 355 vfs_node_t *mp_node;356 357 vfs_node_t *mr_node; 357 358 int phone; … … 503 504 int oflag = IPC_GET_ARG2(*request); 504 505 int mode = IPC_GET_ARG3(*request); 505 size_t len;506 506 507 507 /* Ignore mode for now. */ … … 887 887 { 888 888 int fd = (int) IPC_GET_ARG1(*request); 889 off _t off = (off_t) IPC_GET_ARG2(*request);890 int whence = (int) IPC_GET_ARG3(*request);891 892 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 893 893 /* Lookup the file structure corresponding to the file descriptor. */ 894 894 vfs_file_t *file = vfs_file_get(fd); … … 897 897 return; 898 898 } 899 900 off_t newpos; 899 901 900 fibril_mutex_lock(&file->lock); 902 if (whence == SEEK_SET) { 903 file->pos = off; 904 fibril_mutex_unlock(&file->lock); 905 ipc_answer_1(rid, EOK, off); 906 return; 907 } 908 if (whence == SEEK_CUR) { 909 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 910 928 fibril_mutex_unlock(&file->lock); 911 ipc_answer_ 0(rid, EOVERFLOW);929 ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff)); 912 930 return; 913 } 914 file->pos += off; 915 newpos = file->pos; 916 fibril_mutex_unlock(&file->lock); 917 ipc_answer_1(rid, EOK, newpos); 918 return; 919 } 920 if (whence == SEEK_END) { 921 fibril_rwlock_read_lock(&file->node->contents_rwlock); 922 size_t size = file->node->size; 923 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 924 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); 925 953 fibril_mutex_unlock(&file->lock); 926 ipc_answer_ 0(rid, EOVERFLOW);954 ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff)); 927 955 return; 928 } 929 newpos = size + off; 930 file->pos = newpos; 931 fibril_mutex_unlock(&file->lock); 932 ipc_answer_1(rid, EOK, newpos); 933 return; 934 } 956 } 957 935 958 fibril_mutex_unlock(&file->lock); 936 959 ipc_answer_0(rid, EINVAL); 937 960 } 938 961 939 int 940 vfs_truncate_internal(fs_handle_t fs_handle, dev_handle_t dev_handle, 941 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) 942 964 { 943 965 ipcarg_t rc; … … 945 967 946 968 fs_phone = vfs_grab_phone(fs_handle); 947 rc = async_req_ 3_0(fs_phone, VFS_OUT_TRUNCATE, (ipcarg_t)dev_handle,948 (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)); 949 971 vfs_release_phone(fs_phone); 950 972 return (int)rc; … … 954 976 { 955 977 int fd = IPC_GET_ARG1(*request); 956 size_t size = IPC_GET_ARG2(*request); 978 aoff64_t size = 979 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(*request), IPC_GET_ARG3(*request)); 957 980 int rc; 958 981
Note:
See TracChangeset
for help on using the changeset viewer.