From 6747f9407a061684c2fba837541c254f48bfcff0 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Wed, 15 Nov 2023 02:43:03 +0100 Subject: VFS: Add stat --- kernel/scalls/stat.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'kernel/scalls/stat.c') diff --git a/kernel/scalls/stat.c b/kernel/scalls/stat.c index 0850151..9fc115b 100644 --- a/kernel/scalls/stat.c +++ b/kernel/scalls/stat.c @@ -5,9 +5,8 @@ int syscall_stat(SYS_STAT_PARAMS *args) { const char *pathname = copy_and_allocate_user_string(args->pathname); struct stat *statbuf = args->statbuf; - vfs_inode_t *i = vfs_internal_open(pathname); - if (!i) - return -ENOENT; - statbuf->st_size = i->file_size; - return 0; + int fd = vfs_open(pathname, O_READ, 0); + int rc = vfs_fstat(fd, statbuf); + vfs_close(fd); + return rc; } -- cgit v1.2.3