Changeset 67e881c in mainline for uspace/srv/vfs
- Timestamp:
- 2017-03-30T20:59:36Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a56cef9
- Parents:
- 79ea5af
- Location:
- uspace/srv/vfs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs.h
r79ea5af r67e881c 211 211 extern int vfs_op_read(int fd, aoff64_t, size_t *out_bytes); 212 212 extern int vfs_op_rename(int basefd, char *old, char *new); 213 extern int vfs_op_resize(int fd, int64_t size); 213 214 extern int vfs_op_stat(int fd); 214 215 extern int vfs_op_statfs(int fd); 215 216 extern int vfs_op_sync(int fd); 216 extern int vfs_op_truncate(int fd, int64_t size);217 217 extern int vfs_op_unlink(int parentfd, int expectfd, char *path); 218 218 extern int vfs_op_unmount(int mpfd); -
uspace/srv/vfs/vfs_ipc.c
r79ea5af r67e881c 160 160 } 161 161 162 static void vfs_in_resize(ipc_callid_t rid, ipc_call_t *request) 163 { 164 int fd = IPC_GET_ARG1(*request); 165 int64_t size = MERGE_LOUP32(IPC_GET_ARG2(*request), IPC_GET_ARG3(*request)); 166 int rc = vfs_op_resize(fd, size); 167 async_answer_0(rid, rc); 168 } 169 162 170 static void vfs_in_stat(ipc_callid_t rid, ipc_call_t *request) 163 171 { … … 179 187 int fd = IPC_GET_ARG1(*request); 180 188 int rc = vfs_op_sync(fd); 181 async_answer_0(rid, rc);182 }183 184 static void vfs_in_truncate(ipc_callid_t rid, ipc_call_t *request)185 {186 int fd = IPC_GET_ARG1(*request);187 int64_t size = MERGE_LOUP32(IPC_GET_ARG2(*request), IPC_GET_ARG3(*request));188 int rc = vfs_op_truncate(fd, size);189 189 async_answer_0(rid, rc); 190 190 } … … 287 287 vfs_in_rename(callid, &call); 288 288 break; 289 case VFS_IN_RESIZE: 290 vfs_in_resize(callid, &call); 291 break; 289 292 case VFS_IN_STAT: 290 293 vfs_in_stat(callid, &call); … … 295 298 case VFS_IN_SYNC: 296 299 vfs_in_sync(callid, &call); 297 break;298 case VFS_IN_TRUNCATE:299 vfs_in_truncate(callid, &call);300 300 break; 301 301 case VFS_IN_UNLINK: -
uspace/srv/vfs/vfs_ops.c
r79ea5af r67e881c 585 585 } 586 586 587 int vfs_op_resize(int fd, int64_t size) 588 { 589 vfs_file_t *file = vfs_file_get(fd); 590 if (!file) 591 return EBADF; 592 593 fibril_rwlock_write_lock(&file->node->contents_rwlock); 594 595 int rc = vfs_truncate_internal(file->node->fs_handle, 596 file->node->service_id, file->node->index, size); 597 if (rc == EOK) 598 file->node->size = size; 599 600 fibril_rwlock_write_unlock(&file->node->contents_rwlock); 601 vfs_file_put(file); 602 return rc; 603 } 604 587 605 int vfs_op_stat(int fd) 588 606 { … … 652 670 653 671 return (int) rc; 654 }655 656 int vfs_op_truncate(int fd, int64_t size)657 {658 vfs_file_t *file = vfs_file_get(fd);659 if (!file)660 return EBADF;661 662 fibril_rwlock_write_lock(&file->node->contents_rwlock);663 664 int rc = vfs_truncate_internal(file->node->fs_handle,665 file->node->service_id, file->node->index, size);666 if (rc == EOK)667 file->node->size = size;668 669 fibril_rwlock_write_unlock(&file->node->contents_rwlock);670 vfs_file_put(file);671 return rc;672 672 } 673 673
Note:
See TracChangeset
for help on using the changeset viewer.