Skip to content

Commit 3fdd866

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

File tree

4 files changed

+62
-23
lines changed

4 files changed

+62
-23
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: 55 additions & 7 deletions
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,7 +471,15 @@ impl std::os::unix::fs::MetadataExt for Metadata {
471471
fn atime(&self) -> i64 {
472472
#[cfg(target_pointer_width = "32")]
473473
{
474-
self.stat.st_atime.into()
474+
#[cfg(target_env = "musl", target_arch = "x86")]
475+
{
476+
self.stat.st_atim.into()
477+
}
478+
479+
#[cfg(not(target_env = "musl", target_arch = "x86"))]
480+
{
481+
self.stat.st_atime.into()
482+
}
475483
}
476484
#[cfg(not(target_pointer_width = "32"))]
477485
{
@@ -482,7 +490,15 @@ impl std::os::unix::fs::MetadataExt for Metadata {
482490
fn atime_nsec(&self) -> i64 {
483491
#[cfg(target_pointer_width = "32")]
484492
{
485-
self.stat.st_atime_nsec.into()
493+
#[cfg(target_env = "musl", target_arch = "x86")]
494+
{
495+
self.stat.st_atim_nsec.into()
496+
}
497+
498+
#[cfg(not(target_env = "musl", target_arch = "x86"))]
499+
{
500+
self.stat.st_atime_nsec.into()
501+
}
486502
}
487503
#[cfg(not(target_pointer_width = "32"))]
488504
{
@@ -493,7 +509,15 @@ impl std::os::unix::fs::MetadataExt for Metadata {
493509
fn mtime(&self) -> i64 {
494510
#[cfg(target_pointer_width = "32")]
495511
{
496-
self.stat.st_mtime.into()
512+
#[cfg(target_env = "musl", target_arch = "x86")]
513+
{
514+
self.stat.st_mtim.into()
515+
}
516+
517+
#[cfg(not(target_env = "musl", target_arch = "x86"))]
518+
{
519+
self.stat.st_mtime.into()
520+
}
497521
}
498522
#[cfg(not(target_pointer_width = "32"))]
499523
{
@@ -504,7 +528,15 @@ impl std::os::unix::fs::MetadataExt for Metadata {
504528
fn mtime_nsec(&self) -> i64 {
505529
#[cfg(target_pointer_width = "32")]
506530
{
507-
self.stat.st_mtime_nsec.into()
531+
#[cfg(target_env = "musl", target_arch = "x86")]
532+
{
533+
self.stat.st_mtim_nsec.into()
534+
}
535+
536+
#[cfg(not(target_env = "musl", target_arch = "x86"))]
537+
{
538+
self.stat.st_mtime_nsec.into()
539+
}
508540
}
509541
#[cfg(not(target_pointer_width = "32"))]
510542
{
@@ -515,7 +547,15 @@ impl std::os::unix::fs::MetadataExt for Metadata {
515547
fn ctime(&self) -> i64 {
516548
#[cfg(target_pointer_width = "32")]
517549
{
518-
self.stat.st_ctime.into()
550+
#[cfg(target_env = "musl", target_arch = "x86")]
551+
{
552+
self.stat.st_ctim.into()
553+
}
554+
555+
#[cfg(not(target_env = "musl", target_arch = "x86"))]
556+
{
557+
self.stat.st_ctime.into()
558+
}
519559
}
520560
#[cfg(not(target_pointer_width = "32"))]
521561
{
@@ -526,7 +566,15 @@ impl std::os::unix::fs::MetadataExt for Metadata {
526566
fn ctime_nsec(&self) -> i64 {
527567
#[cfg(target_pointer_width = "32")]
528568
{
529-
self.stat.st_ctime_nsec.into()
569+
#[cfg(target_env = "musl", target_arch = "x86")]
570+
{
571+
self.stat.st_ctim_nsec.into()
572+
}
573+
574+
#[cfg(not(target_env = "musl", target_arch = "x86"))]
575+
{
576+
self.stat.st_ctime_nsec.into()
577+
}
530578
}
531579
#[cfg(not(target_pointer_width = "32"))]
532580
{

0 commit comments

Comments
 (0)