Skip to content

Commit af67939

Browse files
authored
Use 64-bit fields for fsblkcnt_t and fsfilcnt_t (#24769)
We were running into issues where some of our bots were reporting numbers larger than 2^32 when calling statfs on the underlying filesystem.
1 parent 322634f commit af67939

File tree

7 files changed

+33
-31
lines changed

7 files changed

+33
-31
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ See docs/process.md for more on how version tagging works.
2020

2121
4.0.12 (in development)
2222
-----------------------
23+
- The `fsblkcnt_t` and `fsfilcnt_t` types used by `statfs`/`statvfs` were
24+
changed from 32-bit to 64-bit. (#24769)
2325
- Support for `-sTEXT_DECODER=0` was removed, due to widespread support for
2426
`TextDecoder`. The remaining valid values for this setting are `=1`
2527
(conditional use of `TextDecoder` with fallback) and `=2` (unconditional use

src/lib/libsyscall.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ var SyscallsLibrary = {
6666
writeStatFs(buf, stats) {
6767
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_bsize, 'stats.bsize', 'i32') }}};
6868
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_frsize, 'stats.bsize', 'i32') }}};
69-
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_blocks, 'stats.blocks', 'i32') }}};
70-
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_bfree, 'stats.bfree', 'i32') }}};
71-
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_bavail, 'stats.bavail', 'i32') }}};
72-
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_files, 'stats.files', 'i32') }}};
73-
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_ffree, 'stats.ffree', 'i32') }}};
69+
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_blocks, 'stats.blocks', 'i64') }}};
70+
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_bfree, 'stats.bfree', 'i64') }}};
71+
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_bavail, 'stats.bavail', 'i64') }}};
72+
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_files, 'stats.files', 'i64') }}};
73+
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_ffree, 'stats.ffree', 'i64') }}};
7474
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_fsid, 'stats.fsid', 'i32') }}};
7575
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_flags, 'stats.flags', 'i32') }}}; // ST_NOSUID
7676
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_namelen, 'stats.namelen', 'i32') }}};

src/struct_info_generated.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,17 +1699,17 @@
16991699
"st_uid": 12
17001700
},
17011701
"statfs": {
1702-
"__size__": 64,
1703-
"f_bavail": 16,
1704-
"f_bfree": 12,
1702+
"__size__": 88,
1703+
"f_bavail": 24,
1704+
"f_bfree": 16,
17051705
"f_blocks": 8,
17061706
"f_bsize": 4,
1707-
"f_ffree": 24,
1708-
"f_files": 20,
1709-
"f_flags": 44,
1710-
"f_frsize": 40,
1711-
"f_fsid": 28,
1712-
"f_namelen": 36
1707+
"f_ffree": 40,
1708+
"f_files": 32,
1709+
"f_flags": 64,
1710+
"f_frsize": 60,
1711+
"f_fsid": 48,
1712+
"f_namelen": 56
17131713
},
17141714
"termios": {
17151715
"__c_ispeed": 52,

src/struct_info_generated_wasm64.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,17 +1699,17 @@
16991699
"st_uid": 16
17001700
},
17011701
"statfs": {
1702-
"__size__": 104,
1703-
"f_bavail": 24,
1704-
"f_bfree": 20,
1702+
"__size__": 120,
1703+
"f_bavail": 32,
1704+
"f_bfree": 24,
17051705
"f_blocks": 16,
17061706
"f_bsize": 8,
1707-
"f_ffree": 32,
1708-
"f_files": 28,
1709-
"f_flags": 64,
1710-
"f_frsize": 56,
1711-
"f_fsid": 36,
1712-
"f_namelen": 48
1707+
"f_ffree": 48,
1708+
"f_files": 40,
1709+
"f_flags": 80,
1710+
"f_frsize": 72,
1711+
"f_fsid": 56,
1712+
"f_namelen": 64
17131713
},
17141714
"termios": {
17151715
"__c_ispeed": 52,

system/lib/libc/musl/arch/emscripten/bits/alltypes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,12 @@ typedef int blkcnt_t;
265265
#endif
266266

267267
#if defined(__NEED_fsblkcnt_t) && !defined(__DEFINED_fsblkcnt_t)
268-
typedef unsigned int fsblkcnt_t;
268+
typedef unsigned _Int64 fsblkcnt_t;
269269
#define __DEFINED_fsblkcnt_t
270270
#endif
271271

272272
#if defined(__NEED_fsfilcnt_t) && !defined(__DEFINED_fsfilcnt_t)
273-
typedef unsigned int fsfilcnt_t;
273+
typedef unsigned _Int64 fsfilcnt_t;
274274
#define __DEFINED_fsfilcnt_t
275275
#endif
276276

test/code_size/test_codesize_hello_dylink_all.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"a.out.js": 246743,
3-
"a.out.nodebug.wasm": 597771,
4-
"total": 844514,
2+
"a.out.js": 246788,
3+
"a.out.nodebug.wasm": 597789,
4+
"total": 844577,
55
"sent": [
66
"IMG_Init",
77
"IMG_Load",

test/core/test_statvfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ int main() {
2020

2121
printf("f_bsize: %lu\n", s.f_bsize);
2222
printf("f_frsize: %lu\n", s.f_frsize);
23-
printf("f_blocks: %u\n", s.f_blocks);
24-
printf("f_bfree: %u\n", s.f_bfree);
25-
printf("f_bavail: %u\n", s.f_bavail);
23+
printf("f_blocks: %llu\n", s.f_blocks);
24+
printf("f_bfree: %llu\n", s.f_bfree);
25+
printf("f_bavail: %llu\n", s.f_bavail);
2626
printf("f_files: %d\n", s.f_files > 5);
2727
printf("f_ffree: %u\n", s.f_ffree <= s.f_files && s.f_ffree > 0);
2828
printf("f_favail: %u\n", s.f_favail <= s.f_files && s.f_favail > 0);

0 commit comments

Comments
 (0)