diff --git a/fs/vfs.c b/fs/vfs.c index 228dcb6..8f635d4 100644 --- a/fs/vfs.c +++ b/fs/vfs.c @@ -152,6 +152,18 @@ int seek(int fd, size_t offset, int whence) return fdesc->pos; } +size_t tell(int fd) +{ + struct rbnode *fdnode = rbt_search(kfd, fd); + + if (!fdnode) + return -EBADF; + + struct file_descriptor *fdesc = (struct file_descriptor *)fdnode->value; + + return fdesc->pos; +} + int mkdir(const char *pathname) { return rootfs->ops.mkdir(rootfs, pathname); diff --git a/include/fs/vfs.h b/include/fs/vfs.h index 8b6d653..d8a7eed 100644 --- a/include/fs/vfs.h +++ b/include/fs/vfs.h @@ -120,6 +120,7 @@ int read(int fd, void *buf, size_t count); int open(const char *pathname, int flags); int close(int fd); int seek(int fd, size_t offset, int whence); +size_t tell(int fd); int statfd(int fd, struct statbuf *statbuf); int mkdir(const char *pathname);