Changeset 677745a in mainline
- Timestamp:
- 2013-07-29T12:54:39Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5bcd5b7
- Parents:
- b7c62a9
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/ipc/vfs.h
rb7c62a9 r677745a 94 94 VFS_OUT_UNMOUNT, 95 95 VFS_OUT_UNMOUNTED, 96 VFS_OUT_GET_SIZE, 96 97 VFS_OUT_SYNC, 97 98 VFS_OUT_STAT, -
uspace/lib/fs/libfs.c
rb7c62a9 r677745a 238 238 } 239 239 240 static void vfs_out_get_size(ipc_callid_t rid, ipc_call_t *req) 241 { 242 service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req); 243 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*req); 244 int rc; 245 246 fs_node_t *node = NULL; 247 rc = libfs_ops->node_get(&node, service_id, index); 248 if (rc != EOK) { 249 async_answer_0(rid, rc); 250 } 251 if (node == NULL) { 252 async_answer_0(rid, EINVAL); 253 } 254 255 uint64_t size = libfs_ops->size_get(node); 256 libfs_ops->node_put(node); 257 258 async_answer_2(rid, EOK, LOWER32(size), UPPER32(size)); 259 } 260 240 261 static void vfs_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 241 262 { … … 299 320 vfs_out_sync(callid, &call); 300 321 break; 322 case VFS_OUT_GET_SIZE: 323 vfs_out_get_size(callid, &call); 324 break; 301 325 default: 302 326 async_answer_0(callid, ENOTSUP); … … 657 681 /* Find the file and its parent. */ 658 682 683 unsigned last_next = 0; 684 659 685 while (next != last) { 660 686 if (cur == NULL) { 661 as ync_answer_0(rid, ENOENT);662 LOG_EXIT(ENOENT);663 goto out;664 } 687 assert(par != NULL); 688 goto out1; 689 } 690 665 691 if (!ops->is_directory(cur)) { 666 692 async_answer_0(rid, ENOTDIR); … … 669 695 } 670 696 697 last_next = next; 671 698 /* Collect the component */ 672 699 rc = plb_get_component(component, &clen, &next, last); … … 773 800 rc = ops->unlink(par, cur, component); 774 801 if (rc == EOK) { 775 aoff64_t size = ops->size_get(cur); 802 int64_t size = ops->size_get(cur); 803 int32_t lsize = LOWER32(size); 804 if (lsize != size) { 805 lsize = -1; 806 } 807 776 808 async_answer_5(rid, fs_handle, service_id, 777 ops->index_get(cur), LOWER32(size), UPPER32(size),809 ops->index_get(cur), last, lsize, 778 810 ops->is_directory(cur) ? VFS_NODE_DIRECTORY : VFS_NODE_FILE); 779 811 LOG_EXIT(EOK); … … 819 851 820 852 /* Return. */ 821 853 out1: 822 854 if (!cur) { 855 async_answer_5(rid, fs_handle, service_id, 856 ops->index_get(par), last_next, -1, VFS_NODE_DIRECTORY); 857 LOG_EXIT(EOK); 858 /* 823 859 async_answer_0(rid, ENOENT); 824 860 LOG_EXIT(ENOENT); 861 */ 825 862 goto out; 826 863 } … … 835 872 } 836 873 837 aoff64_t size = ops->size_get(cur); 874 int64_t size = ops->size_get(cur); 875 int32_t lsize = LOWER32(size); 876 if (lsize != size) { 877 lsize = -1; 878 } 879 838 880 async_answer_5(rid, fs_handle, service_id, 839 ops->index_get(cur), LOWER32(size), UPPER32(size),881 ops->index_get(cur), last, lsize, 840 882 ops->is_directory(cur) ? VFS_NODE_DIRECTORY : VFS_NODE_FILE); 841 883 -
uspace/srv/vfs/vfs.h
rb7c62a9 r677745a 113 113 vfs_node_type_t type; /**< Partial info about the node type. */ 114 114 115 aoff64_t size; /**< Cached size if the node is a file. */115 int64_t size; /**< Cached size if the node is a file. */ 116 116 117 117 /** … … 185 185 extern unsigned vfs_nodes_refcount_sum_get(fs_handle_t, service_id_t); 186 186 187 int64_t vfs_node_get_size(vfs_node_t *node); 187 188 188 189 #define MAX_OPEN_FILES 128 -
uspace/srv/vfs/vfs_lookup.c
rb7c62a9 r677745a 270 270 } 271 271 272 unsigned last = IPC_GET_ARG3(answer); 273 if (last != first + len) { 274 /* The path wasn't processed entirely. */ 275 rc = ENOENT; 276 goto out; 277 } 278 272 279 if (!result) { 273 280 rc = EOK; … … 278 285 result->triplet.service_id = (service_id_t) IPC_GET_ARG1(answer); 279 286 result->triplet.index = (fs_index_t) IPC_GET_ARG2(answer); 280 result->size = 281 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(answer), IPC_GET_ARG4(answer)); 287 result->size = (int64_t)(int32_t) IPC_GET_ARG4(answer); 282 288 result->type = IPC_GET_ARG5(answer); 283 289 rc = EOK; -
uspace/srv/vfs/vfs_node.c
rb7c62a9 r677745a 45 45 #include <async.h> 46 46 #include <errno.h> 47 #include <macros.h> 47 48 48 49 /** Mutex protecting the VFS node hash table. */ … … 300 301 } 301 302 303 int64_t vfs_node_get_size(vfs_node_t *node) 304 { 305 if (node->size == -1) { 306 sysarg_t sz1 = 0; 307 sysarg_t sz2 = 0; 308 309 async_exch_t *exch = vfs_exchange_grab(node->fs_handle); 310 (void) async_req_2_2(exch, VFS_OUT_GET_SIZE, 311 node->service_id, node->index, &sz1, &sz2); 312 vfs_exchange_release(exch); 313 314 node->size = MERGE_LOUP32(sz1, sz2); 315 } 316 return node->size; 317 } 318 302 319 /** 303 320 * @} -
uspace/srv/vfs/vfs_ops.c
rb7c62a9 r677745a 840 840 } else { 841 841 if (file->append) 842 file->pos = file->node->size;842 file->pos = vfs_node_get_size(file->node); 843 843 844 844 rc = async_data_write_forward_4_1(fs_exch, VFS_OUT_WRITE, … … 942 942 case SEEK_END: 943 943 fibril_rwlock_read_lock(&file->node->contents_rwlock); 944 aoff64_t size = file->node->size;944 aoff64_t size = vfs_node_get_size(file->node); 945 945 946 946 if ((off >= 0) && (size + off < size)) {
Note:
See TracChangeset
for help on using the changeset viewer.