Changeset 67e881c in mainline
- Timestamp:
- 2017-03-30T20:59:36Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a56cef9
- Parents:
- 79ea5af
- Location:
- uspace
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/trace/trace.c
r79ea5af r67e881c 706 706 proto_add_oper(p, VFS_IN_WRITE, o); 707 707 o = oper_new("truncate", 5, arg_def, V_ERRNO, 0, resp_def); 708 proto_add_oper(p, VFS_IN_ TRUNCATE, o);708 proto_add_oper(p, VFS_IN_RESIZE, o); 709 709 o = oper_new("fstat", 1, arg_def, V_ERRNO, 0, resp_def); 710 710 proto_add_oper(p, VFS_IN_STAT, o); -
uspace/lib/c/generic/vfs/vfs.c
r79ea5af r67e881c 408 408 assert(!(oflag & O_APPEND)); 409 409 410 (void) ftruncate(fd, 0);410 (void) vfs_resize(fd, 0); 411 411 } 412 412 … … 620 620 * @param length Length 621 621 * 622 * @return 0 on success , -1 on error and sets errno.623 */ 624 int ftruncate(int fildes, aoff64_t length)622 * @return 0 on success or a negative erroc code otherwise. 623 */ 624 int vfs_resize(int file, aoff64_t length) 625 625 { 626 626 sysarg_t rc; 627 627 628 628 async_exch_t *exch = vfs_exchange_begin(); 629 rc = async_req_3_0(exch, VFS_IN_TRUNCATE, fildes, 630 LOWER32(length), UPPER32(length)); 631 vfs_exchange_end(exch); 632 633 if (rc != EOK) { 634 errno = rc; 635 return -1; 636 } 637 638 return 0; 629 rc = async_req_3_0(exch, VFS_IN_RESIZE, file, LOWER32(length), 630 UPPER32(length)); 631 vfs_exchange_end(exch); 632 633 return rc; 639 634 } 640 635 -
uspace/lib/c/include/ipc/vfs.h
r79ea5af r67e881c 65 65 VFS_IN_READ = IPC_FIRST_USER_METHOD, 66 66 VFS_IN_WRITE, 67 VFS_IN_ TRUNCATE,67 VFS_IN_RESIZE, 68 68 VFS_IN_STAT, 69 69 VFS_IN_CLOSE, -
uspace/lib/c/include/unistd.h
r79ea5af r67e881c 61 61 extern ssize_t read(int, aoff64_t *, void *, size_t); 62 62 63 extern int ftruncate(int, aoff64_t);64 65 63 extern int close(int); 66 64 extern int fsync(int); -
uspace/lib/c/include/vfs/vfs.h
r79ea5af r67e881c 90 90 extern int vfs_root(void); 91 91 extern void vfs_root_set(int); 92 extern int vfs_resize(int, aoff64_t); 92 93 extern int vfs_stat(int, struct stat *); 93 94 extern int vfs_stat_path(const char *, struct stat *); -
uspace/lib/posix/source/unistd.c
r79ea5af r67e881c 259 259 int posix_ftruncate(int fildes, posix_off_t length) 260 260 { 261 return negerrno(ftruncate, fildes, (aoff64_t) length); 261 if (rcerrno(vfs_resize, fildes, (aoff64_t) length) != EOK) 262 return -1; 263 else 264 return 0; 262 265 } 263 266 -
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.