Changeset ed903174 in mainline for uspace/srv/vfs
- 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
- Location:
- uspace/srv/vfs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs.h
rb32c604f red903174 42 42 #include <ipc/vfs.h> 43 43 44 // FIXME: according to CONFIG_DEBUG 45 // #define dprintf(...) printf(__VA_ARGS__) 46 47 #define dprintf(...) 44 #ifndef dprintf 45 #define dprintf(...) 46 #endif 48 47 49 48 /** … … 93 92 vfs_triplet_t triplet; 94 93 vfs_node_type_t type; 95 size_t size;96 unsigned lnkcnt;94 aoff64_t size; 95 unsigned int lnkcnt; 97 96 } vfs_lookup_res_t; 98 97 … … 117 116 vfs_node_type_t type; /**< Partial info about the node type. */ 118 117 119 size_t size; /**< Cached size if the node is a file. */118 aoff64_t size; /**< Cached size if the node is a file. */ 120 119 121 120 /** … … 141 140 bool append; 142 141 143 /** Current position in the file. */144 off_t pos;142 /** Current absolute position in the file. */ 143 aoff64_t pos; 145 144 } vfs_file_t; 146 145 … … 214 213 extern void vfs_truncate(ipc_callid_t, ipc_call_t *); 215 214 extern void vfs_fstat(ipc_callid_t, ipc_call_t *); 216 extern void vfs_fstat(ipc_callid_t, ipc_call_t *);217 215 extern void vfs_stat(ipc_callid_t, ipc_call_t *); 218 216 extern void vfs_mkdir(ipc_callid_t, ipc_call_t *); -
uspace/srv/vfs/vfs_lookup.c
rb32c604f red903174 38 38 #include "vfs.h" 39 39 #include <ipc/ipc.h> 40 #include <macros.h> 40 41 #include <async.h> 41 42 #include <errno.h> … … 99 100 entry.len = len; 100 101 101 off_t first; /* the first free index */102 off_t last; /* the last free index */102 size_t first; /* the first free index */ 103 size_t last; /* the last free index */ 103 104 104 105 if (list_empty(&plb_head)) { … … 177 178 memset(plb, 0, cnt2); 178 179 fibril_mutex_unlock(&plb_mutex); 179 180 if ((rc == EOK) && (result)) { 181 result->triplet.fs_handle = (fs_handle_t) IPC_GET_ARG1(answer); 182 result->triplet.dev_handle = (dev_handle_t) IPC_GET_ARG2(answer); 183 result->triplet.index = (fs_index_t) IPC_GET_ARG3(answer); 184 result->size = (size_t) IPC_GET_ARG4(answer); 185 result->lnkcnt = (unsigned) IPC_GET_ARG5(answer); 186 if (lflag & L_FILE) 187 result->type = VFS_NODE_FILE; 188 else if (lflag & L_DIRECTORY) 189 result->type = VFS_NODE_DIRECTORY; 190 else 191 result->type = VFS_NODE_UNKNOWN; 192 } 193 194 return rc; 180 181 if (((int) rc < EOK) || (!result)) 182 return (int) rc; 183 184 result->triplet.fs_handle = (fs_handle_t) rc; 185 result->triplet.dev_handle = (dev_handle_t) IPC_GET_ARG1(answer); 186 result->triplet.index = (fs_index_t) IPC_GET_ARG2(answer); 187 result->size = 188 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(answer), IPC_GET_ARG4(answer)); 189 result->lnkcnt = (unsigned int) IPC_GET_ARG5(answer); 190 191 if (lflag & L_FILE) 192 result->type = VFS_NODE_FILE; 193 else if (lflag & L_DIRECTORY) 194 result->type = VFS_NODE_DIRECTORY; 195 else 196 result->type = VFS_NODE_UNKNOWN; 197 198 return EOK; 195 199 } 196 200 … … 214 218 215 219 if (rc == EOK) { 216 result->size = (size_t) IPC_GET_ARG1(answer); 217 result->lnkcnt = (unsigned) IPC_GET_ARG2(answer); 218 if (IPC_GET_ARG3(answer) & L_FILE) 220 result->size = 221 MERGE_LOUP32(IPC_GET_ARG1(answer), IPC_GET_ARG2(answer)); 222 result->lnkcnt = (unsigned int) IPC_GET_ARG3(answer); 223 if (IPC_GET_ARG4(answer) & L_FILE) 219 224 result->type = VFS_NODE_FILE; 220 else if (IPC_GET_ARG 3(answer) & L_DIRECTORY)225 else if (IPC_GET_ARG4(answer) & L_DIRECTORY) 221 226 result->type = VFS_NODE_DIRECTORY; 222 227 else -
uspace/srv/vfs/vfs_node.c
rb32c604f red903174 242 242 { 243 243 vfs_node_t *node = hash_table_get_instance(item, vfs_node_t, nh_link); 244 return (node->fs_handle == key[KEY_FS_HANDLE]) &&244 return (node->fs_handle == (fs_handle_t) key[KEY_FS_HANDLE]) && 245 245 (node->dev_handle == key[KEY_DEV_HANDLE]) && 246 246 (node->index == key[KEY_INDEX]); -
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.