vfs: add tell function

This commit is contained in:
Michael Shaw 2023-10-23 21:54:32 -04:00
commit bec327a4cc
2 changed files with 13 additions and 0 deletions

View file

@ -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);

View file

@ -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);