diff --git a/sys/include/vfs.h b/sys/include/vfs.h index 5600094451..dc444dcdff 100644 --- a/sys/include/vfs.h +++ b/sys/include/vfs.h @@ -715,6 +715,17 @@ int vfs_fstat(int fd, struct stat *buf); */ int vfs_fstatvfs(int fd, struct statvfs *buf); +/** + * @brief Get file system status of the file system containing an open directory + * + * @param[in] dirp pointer to open directory + * @param[out] buf pointer to statvfs struct to fill + * + * @return 0 on success + * @return <0 on error + */ +int vfs_dstatvfs(vfs_DIR *dirp, struct statvfs *buf); + /** * @brief Seek to position in file * diff --git a/sys/vfs/vfs.c b/sys/vfs/vfs.c index c8fed3c4ab..227e087b88 100644 --- a/sys/vfs/vfs.c +++ b/sys/vfs/vfs.c @@ -223,6 +223,20 @@ int vfs_fstatvfs(int fd, struct statvfs *buf) return filp->mp->fs->fs_op->statvfs(filp->mp, "/", buf); } +int vfs_dstatvfs(vfs_DIR *dirp, struct statvfs *buf) +{ + DEBUG("vfs_dstatvfs: %p, %p\n", (void*)dirp, (void *)buf); + if (buf == NULL) { + return -EFAULT; + } + memset(buf, 0, sizeof(*buf)); + if (dirp->mp->fs->fs_op->statvfs == NULL) { + /* file system driver does not implement statvfs() */ + return -EINVAL; + } + return dirp->mp->fs->fs_op->statvfs(dirp->mp, "/", buf); +} + off_t vfs_lseek(int fd, off_t off, int whence) { DEBUG("vfs_lseek: %d, %ld, %d\n", fd, (long)off, whence);