Skip to content

Commit

Permalink
Fix "struct stat" on 32-bit FreeBSD 12+ (rust-lang#3939)
Browse files Browse the repository at this point in the history
* Fix the definition of ino_t on 32-bit FreeBSD 12+

Commit 7437d0a erroneously defined it as "ulong" instead of u64.
Nobody noticed the mistake, probably because it was only tested on
64-bit architectures, where those are equivalent.  But it's a problem
now, after rust-lang#3723 , which switched the standard library to a FreeBSD 12
ABI.

Issue rust-lang/rust#130677

* Fix the definition of "struct stat" on 32-bit FreeBSD 12+

The original definitions were never correct.  But nobody noticed because
we don't do CI on 32-bit FreeBSD.  The problem is apparent now due to
 rust-lang#3723 , which caused the nightly toolchain to switch to a FreeBSD 12
ABI.

Fixes rust-lang/rust#130677

* fixup: fix build on powerpc, powerpc64, and arm
  • Loading branch information
asomers authored and AkhilTThomas committed Feb 5, 2025
1 parent 2c19b86 commit 31c3cd4
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,40 @@ s! {
pub st_gen: u64,
pub st_spare: [u64; 10],
}

pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_nlink: ::nlink_t,
pub st_mode: ::mode_t,
st_padding0: i16,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
st_padding1: i32,
pub st_rdev: ::dev_t,
#[cfg(target_arch = "x86")]
st_atim_ext: i32,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_mtim_ext: i32,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_ctim_ext: i32,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_btim_ext: i32,
pub st_birthtime: ::time_t,
pub st_birthtime_nsec: ::c_long,
pub st_size: ::off_t,
pub st_blocks: ::blkcnt_t,
pub st_blksize: ::blksize_t,
pub st_flags: ::fflags_t,
pub st_gen: u64,
pub st_spare: [u64; 10],
}
}

s_no_extra_traits! {
Expand Down
34 changes: 34 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,40 @@ s! {
pub st_gen: u64,
pub st_spare: [u64; 10],
}

pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_nlink: ::nlink_t,
pub st_mode: ::mode_t,
st_padding0: i16,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
st_padding1: i32,
pub st_rdev: ::dev_t,
#[cfg(target_arch = "x86")]
st_atim_ext: i32,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_mtim_ext: i32,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_ctim_ext: i32,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_btim_ext: i32,
pub st_birthtime: ::time_t,
pub st_birthtime_nsec: ::c_long,
pub st_size: ::off_t,
pub st_blocks: ::blkcnt_t,
pub st_blksize: ::blksize_t,
pub st_flags: ::fflags_t,
pub st_gen: u64,
pub st_spare: [u64; 10],
}
}

s_no_extra_traits! {
Expand Down
34 changes: 34 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,40 @@ s! {
pub st_gen: u64,
pub st_spare: [u64; 10],
}

pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_nlink: ::nlink_t,
pub st_mode: ::mode_t,
st_padding0: i16,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
st_padding1: i32,
pub st_rdev: ::dev_t,
#[cfg(target_arch = "x86")]
st_atim_ext: i32,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_mtim_ext: i32,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_ctim_ext: i32,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_btim_ext: i32,
pub st_birthtime: ::time_t,
pub st_birthtime_nsec: ::c_long,
pub st_size: ::off_t,
pub st_blocks: ::blkcnt_t,
pub st_blksize: ::blksize_t,
pub st_flags: ::fflags_t,
pub st_gen: u64,
pub st_spare: [u64; 10],
}
}

s_no_extra_traits! {
Expand Down
34 changes: 34 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,40 @@ s! {
pub st_filerev: u64,
pub st_spare: [u64; 9],
}

pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_nlink: ::nlink_t,
pub st_mode: ::mode_t,
st_padding0: i16,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
st_padding1: i32,
pub st_rdev: ::dev_t,
#[cfg(target_arch = "x86")]
st_atim_ext: i32,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_mtim_ext: i32,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_ctim_ext: i32,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_btim_ext: i32,
pub st_birthtime: ::time_t,
pub st_birthtime_nsec: ::c_long,
pub st_size: ::off_t,
pub st_blocks: ::blkcnt_t,
pub st_blksize: ::blksize_t,
pub st_flags: ::fflags_t,
pub st_gen: u64,
pub st_spare: [u64; 10],
}
}

s_no_extra_traits! {
Expand Down

0 comments on commit 31c3cd4

Please sign in to comment.