Currently statvfs64 on riscv32 layout seems inconsistent with it neighboring statvfs, and the source in glibc. It creates different layout that may be expected, so may cause UB because of shifted bytes on the struct.
|
// Mirrors `_STATVFSBUF_F_UNUSED` in the header. x32 is excluded because |
|
// its `__SYSCALL_WORDSIZE` is 64, aarch64 because glibc always sets |
|
// `__WORDSIZE` to 64. |
|
#[cfg(all( |
|
target_pointer_width = "32", |
|
not(any(target_arch = "x86_64", target_arch = "aarch64")) |
|
))] |
|
__f_unused: Padding<c_int>, |
|
// FIXME(riscv32): glibc declares this field on riscv32 too, but we have |
|
// never declared it here. |
|
#[cfg(all( |
|
target_pointer_width = "32", |
|
not(any( |
|
target_arch = "x86_64", |
|
target_arch = "aarch64", |
|
target_arch = "riscv32" |
|
)) |
|
))] |
|
__f_unused: Padding<c_int>, |
In glibc, both of them have __f_unused for 32-bit targets.
https://github.com/bminor/glibc/blob/04e750e75b73957cf1c791535a3f4319534a52fc/sysdeps/unix/sysv/linux/bits/statvfs.h#L49-L51
https://github.com/bminor/glibc/blob/04e750e75b73957cf1c791535a3f4319534a52fc/sysdeps/unix/sysv/linux/bits/statvfs.h#L70-L72
https://github.com/bminor/glibc/blob/04e750e75b73957cf1c791535a3f4319534a52fc/sysdeps/unix/sysv/linux/bits/statvfs.h#L24-L27
It was found when working on #5434, during the migration and deduplication to new, the missing field of statvfs64 on riscv32 was deliberately left out as it was before to not change layout of it , but based on the source it should have that field, or are there any specific reason it didn't get that field?
Currently
statvfs64on riscv32 layout seems inconsistent with it neighboringstatvfs, and the source in glibc. It creates different layout that may be expected, so may cause UB because of shifted bytes on the struct.libc/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs
Lines 16 to 23 in 008f905
libc/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs
Lines 40 to 50 in 008f905
In glibc, both of them have __f_unused for 32-bit targets.
https://github.com/bminor/glibc/blob/04e750e75b73957cf1c791535a3f4319534a52fc/sysdeps/unix/sysv/linux/bits/statvfs.h#L49-L51
https://github.com/bminor/glibc/blob/04e750e75b73957cf1c791535a3f4319534a52fc/sysdeps/unix/sysv/linux/bits/statvfs.h#L70-L72
https://github.com/bminor/glibc/blob/04e750e75b73957cf1c791535a3f4319534a52fc/sysdeps/unix/sysv/linux/bits/statvfs.h#L24-L27
It was found when working on #5434, during the migration and deduplication to
new, the missing field ofstatvfs64on riscv32 was deliberately left out as it was before to not change layout of it , but based on the source it should have that field, or are there any specific reason it didn't get that field?