From ff1f81aac8fa692f21d412e87af7cc0570ca8795 Mon Sep 17 00:00:00 2001 From: chrysn Date: Tue, 15 Feb 2022 11:42:18 +0100 Subject: [PATCH] sys/vfs: Drop per-filesystem fstatvfs No current file system implements it, there is no defined semantic difference between running fstatfs and the fallback currently implemented, and there is practically no optimization gained from not just running it through a single statvfs. --- sys/include/vfs.h | 17 ----------------- sys/vfs/vfs.c | 10 +++------- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/sys/include/vfs.h b/sys/include/vfs.h index 9ecec3057a..5600094451 100644 --- a/sys/include/vfs.h +++ b/sys/include/vfs.h @@ -660,23 +660,6 @@ struct vfs_file_system_ops { * @return <0 on error */ int (*statvfs) (vfs_mount_t *mountp, const char *restrict path, struct statvfs *restrict buf); - - /** - * @brief Get file system status of an open file - * - * @p path is only passed for consistency against the POSIX statvfs function. - * @c vfs_statvfs calls this function only when it has determined that - * @p path belongs to this file system. @p path is a file system relative - * path and does not necessarily name an existing file. - * - * @param[in] mountp file system mount to operate on - * @param[in] filp pointer to an open file on the file system being queried - * @param[out] buf pointer to statvfs struct to fill - * - * @return 0 on success - * @return <0 on error - */ - int (*fstatvfs) (vfs_mount_t *mountp, vfs_file_t *filp, struct statvfs *buf); }; /** diff --git a/sys/vfs/vfs.c b/sys/vfs/vfs.c index bb81cf71bc..c8fed3c4ab 100644 --- a/sys/vfs/vfs.c +++ b/sys/vfs/vfs.c @@ -216,15 +216,11 @@ int vfs_fstatvfs(int fd, struct statvfs *buf) } vfs_file_t *filp = &_vfs_open_files[fd]; memset(buf, 0, sizeof(*buf)); - if (filp->mp->fs->fs_op->fstatvfs == NULL) { - /* file system driver does not implement fstatvfs() */ - if (filp->mp->fs->fs_op->statvfs != NULL) { - /* Fall back to statvfs */ - return filp->mp->fs->fs_op->statvfs(filp->mp, "/", buf); - } + if (filp->mp->fs->fs_op->statvfs == NULL) { + /* file system driver does not implement statvfs() */ return -EINVAL; } - return filp->mp->fs->fs_op->fstatvfs(filp->mp, filp, buf); + return filp->mp->fs->fs_op->statvfs(filp->mp, "/", buf); } off_t vfs_lseek(int fd, off_t off, int whence)