unix,win: add f_frsize field to uv_statfs_t (#4984)

Fixes: https://github.com/libuv/libuv/issues/4983
This commit is contained in:
Ben Noordhuis 2026-01-01 22:33:44 +01:00 committed by GitHub
parent 8b870dab3d
commit 91ae02a63d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 2 deletions

View File

@ -129,7 +129,8 @@ Data types
uint64_t f_bavail; uint64_t f_bavail;
uint64_t f_files; uint64_t f_files;
uint64_t f_ffree; uint64_t f_ffree;
uint64_t f_spare[4]; uint64_t f_frsize;
uint64_t f_spare[3];
} uv_statfs_t; } uv_statfs_t;
.. c:enum:: uv_dirent_type_t .. c:enum:: uv_dirent_type_t

View File

@ -1262,7 +1262,8 @@ struct uv_statfs_s {
uint64_t f_bavail; uint64_t f_bavail;
uint64_t f_files; uint64_t f_files;
uint64_t f_ffree; uint64_t f_ffree;
uint64_t f_spare[4]; uint64_t f_frsize;
uint64_t f_spare[3];
}; };
typedef enum { typedef enum {

View File

@ -711,6 +711,11 @@ static int uv__fs_statfs(uv_fs_t* req) {
stat_fs->f_bavail = buf.f_bavail; stat_fs->f_bavail = buf.f_bavail;
stat_fs->f_files = buf.f_files; stat_fs->f_files = buf.f_files;
stat_fs->f_ffree = buf.f_ffree; stat_fs->f_ffree = buf.f_ffree;
#if defined(__linux__)
stat_fs->f_frsize = buf.f_frsize;
#else
stat_fs->f_frsize = buf.f_bsize;
#endif
req->ptr = stat_fs; req->ptr = stat_fs;
return 0; return 0;
} }

View File

@ -3154,6 +3154,7 @@ retry_get_full_path_name:
stat_fs->f_type = 0; stat_fs->f_type = 0;
stat_fs->f_bsize = bytes_per_sector * sectors_per_cluster; stat_fs->f_bsize = bytes_per_sector * sectors_per_cluster;
stat_fs->f_frsize = bytes_per_sector * sectors_per_cluster;
stat_fs->f_blocks = total_clusters; stat_fs->f_blocks = total_clusters;
stat_fs->f_bfree = free_clusters; stat_fs->f_bfree = free_clusters;
stat_fs->f_bavail = free_clusters; stat_fs->f_bavail = free_clusters;

View File

@ -363,6 +363,7 @@ static void statfs_cb(uv_fs_t* req) {
#endif #endif
ASSERT_GT(stats->f_bsize, 0); ASSERT_GT(stats->f_bsize, 0);
ASSERT_GT(stats->f_frsize, 0);
ASSERT_GT(stats->f_blocks, 0); ASSERT_GT(stats->f_blocks, 0);
ASSERT_LE(stats->f_bfree, stats->f_blocks); ASSERT_LE(stats->f_bfree, stats->f_blocks);
ASSERT_LE(stats->f_bavail, stats->f_bfree); ASSERT_LE(stats->f_bavail, stats->f_bfree);