Skip to content

Commit 4f5646f

Browse files
author
oech3
committed
stty: Fix stty panic for standard bauds
1 parent 8cf88cd commit 4f5646f

File tree

4 files changed

+32
-17
lines changed

4 files changed

+32
-17
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uucore/src/lib/features/fs.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ impl FileInformation {
138138
any(
139139
target_vendor = "apple",
140140
target_os = "android",
141-
target_os = "freebsd",
142141
target_os = "netbsd",
143142
target_os = "openbsd",
144143
target_os = "illumos",
@@ -152,6 +151,8 @@ impl FileInformation {
152151
)
153152
))]
154153
return self.0.st_nlink.into();
154+
#[cfg(target_os = "freebsd")]
155+
return self.0.st_nlink;
155156
#[cfg(target_os = "aix")]
156157
return self.0.st_nlink.try_into().unwrap();
157158
#[cfg(windows)]
@@ -160,16 +161,9 @@ impl FileInformation {
160161

161162
#[cfg(unix)]
162163
pub fn inode(&self) -> u64 {
163-
#[cfg(all(
164-
not(any(target_os = "freebsd", target_os = "netbsd")),
165-
target_pointer_width = "64"
166-
))]
164+
#[cfg(all(not(any(target_os = "netbsd")), target_pointer_width = "64"))]
167165
return self.0.st_ino;
168-
#[cfg(any(
169-
target_os = "freebsd",
170-
target_os = "netbsd",
171-
not(target_pointer_width = "64")
172-
))]
166+
#[cfg(any(target_os = "netbsd", not(target_pointer_width = "64")))]
173167
return self.0.st_ino.into();
174168
}
175169
}

src/uucore/src/lib/features/fsext.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,8 @@ unsafe extern "C" {
446446
#[link_name = "getmntinfo"]
447447
fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int;
448448

449-
// Rust on FreeBSD uses 11.x ABI for filesystem metadata syscalls.
450-
// Call the right version of the symbol for getmntinfo() result to
451-
// match libc StatFS layout.
452449
#[cfg(target_os = "freebsd")]
453-
#[link_name = "getmntinfo@FBSD_1.0"]
450+
#[link_name = "getmntinfo"]
454451
fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int;
455452
}
456453

src/uucore/src/lib/features/safe_traversal.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// Only available on Linux
1010
//
1111
// spell-checker:ignore CLOEXEC RDONLY TOCTOU closedir dirp fdopendir fstatat openat REMOVEDIR unlinkat smallfile
12-
// spell-checker:ignore RAII dirfd fchownat fchown FchmodatFlags fchmodat fchmod
12+
// spell-checker:ignore RAII dirfd fchownat fchown FchmodatFlags fchmodat fchmod atim mtim ctim
1313

1414
#[cfg(test)]
1515
use std::os::unix::ffi::OsStringExt;
@@ -471,6 +471,10 @@ impl std::os::unix::fs::MetadataExt for Metadata {
471471
fn atime(&self) -> i64 {
472472
#[cfg(target_pointer_width = "32")]
473473
{
474+
#[cfg(target_env = "musl", target_arch = "x86")]
475+
self.stat.st_atim.into()
476+
477+
#[cfg(not(target_env = "musl", target_arch = "x86"))]
474478
self.stat.st_atime.into()
475479
}
476480
#[cfg(not(target_pointer_width = "32"))]
@@ -482,6 +486,10 @@ impl std::os::unix::fs::MetadataExt for Metadata {
482486
fn atime_nsec(&self) -> i64 {
483487
#[cfg(target_pointer_width = "32")]
484488
{
489+
#[cfg(target_env = "musl", target_arch = "x86")]
490+
self.stat.st_atim_nsec.into()
491+
492+
#[cfg(not(target_env = "musl", target_arch = "x86"))]
485493
self.stat.st_atime_nsec.into()
486494
}
487495
#[cfg(not(target_pointer_width = "32"))]
@@ -493,6 +501,10 @@ impl std::os::unix::fs::MetadataExt for Metadata {
493501
fn mtime(&self) -> i64 {
494502
#[cfg(target_pointer_width = "32")]
495503
{
504+
#[cfg(target_env = "musl", target_arch = "x86")]
505+
self.stat.st_mtim.into()
506+
507+
#[cfg(not(target_env = "musl", target_arch = "x86"))]
496508
self.stat.st_mtime.into()
497509
}
498510
#[cfg(not(target_pointer_width = "32"))]
@@ -504,6 +516,10 @@ impl std::os::unix::fs::MetadataExt for Metadata {
504516
fn mtime_nsec(&self) -> i64 {
505517
#[cfg(target_pointer_width = "32")]
506518
{
519+
#[cfg(target_env = "musl", target_arch = "x86")]
520+
self.stat.st_mtim_nsec.into()
521+
522+
#[cfg(not(target_env = "musl", target_arch = "x86"))]
507523
self.stat.st_mtime_nsec.into()
508524
}
509525
#[cfg(not(target_pointer_width = "32"))]
@@ -515,6 +531,10 @@ impl std::os::unix::fs::MetadataExt for Metadata {
515531
fn ctime(&self) -> i64 {
516532
#[cfg(target_pointer_width = "32")]
517533
{
534+
#[cfg(target_env = "musl", target_arch = "x86")]
535+
self.stat.st_ctim.into()
536+
537+
#[cfg(not(target_env = "musl", target_arch = "x86"))]
518538
self.stat.st_ctime.into()
519539
}
520540
#[cfg(not(target_pointer_width = "32"))]
@@ -526,6 +546,10 @@ impl std::os::unix::fs::MetadataExt for Metadata {
526546
fn ctime_nsec(&self) -> i64 {
527547
#[cfg(target_pointer_width = "32")]
528548
{
549+
#[cfg(target_env = "musl", target_arch = "x86")]
550+
self.stat.st_ctim_nsec.into()
551+
552+
#[cfg(not(target_env = "musl", target_arch = "x86"))]
529553
self.stat.st_ctime_nsec.into()
530554
}
531555
#[cfg(not(target_pointer_width = "32"))]

0 commit comments

Comments
 (0)