Skip to content

Commit 2c24ce4

Browse files
authored
aosp: fix musl_statvfs layout (#11216)
aosp: fix musl_statvfs layout musl's fsblkcnt_t/fsfilcnt_t are 64-bit on all arch, but bionic defines them as 32-bit unsigned long on 32-bit targets. On 32-bit arch, the values can land in wrong offsets in the musl layer. Fixes the PosixStatvfsTest NPLB tests (SunnyDay, UsageChanges), which read misaligned fields: posix_sys_statvfs_test.cc:46 f_namemax == 0 (expected > 0) Bug: 532068409
1 parent 0a4dde4 commit 2c24ce4

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

starboard/shared/modular/starboard_layer_posix_statvfs_abi_wrappers.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,21 @@
2525
extern "C" {
2626
#endif
2727

28+
// musl's fsblkcnt_t/fsfilcnt_t are 64-bit on every arch but bionic defines them
29+
// as 32-bit `unsigned long` on 32-bit targets. Use fixed-width 64-bit types so
30+
// this struct matches musl's layout.
31+
typedef uint64_t musl_fsblkcnt_t;
32+
typedef uint64_t musl_fsfilcnt_t;
33+
2834
struct musl_statvfs {
2935
unsigned long f_bsize;
3036
unsigned long f_frsize;
31-
fsblkcnt_t f_blocks;
32-
fsblkcnt_t f_bfree;
33-
fsblkcnt_t f_bavail;
34-
fsfilcnt_t f_files;
35-
fsfilcnt_t f_ffree;
36-
fsfilcnt_t f_favail;
37+
musl_fsblkcnt_t f_blocks;
38+
musl_fsblkcnt_t f_bfree;
39+
musl_fsblkcnt_t f_bavail;
40+
musl_fsfilcnt_t f_files;
41+
musl_fsfilcnt_t f_ffree;
42+
musl_fsfilcnt_t f_favail;
3743
unsigned long f_fsid;
3844
unsigned : 8 * (2 * sizeof(int) - sizeof(long));
3945
unsigned long f_flag;

0 commit comments

Comments
 (0)