Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/uucore/src/lib/features/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ impl FileInformation {
not(target_os = "android"),
not(target_os = "freebsd"),
not(target_os = "netbsd"),
not(target_os = "openbsd"),
not(target_os = "illumos"),
not(target_os = "solaris"),
not(target_arch = "aarch64"),
Expand All @@ -130,6 +131,7 @@ impl FileInformation {
target_os = "android",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "illumos",
target_os = "solaris",
target_arch = "aarch64",
Expand All @@ -146,13 +148,14 @@ impl FileInformation {
#[cfg(unix)]
pub fn inode(&self) -> u64 {
#[cfg(all(
not(any(target_os = "freebsd", target_os = "netbsd")),
not(any(target_os = "freebsd", target_os = "netbsd", target_os = "openbsd")),
target_pointer_width = "64"
))]
return self.0.st_ino;
#[cfg(any(
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
not(target_pointer_width = "64")
))]
return self.0.st_ino.into();
Expand Down
39 changes: 34 additions & 5 deletions src/uucore/src/lib/features/fsext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,10 @@ impl FsUsage {
#[cfg(unix)]
pub fn new(statvfs: StatFs) -> Self {
{
#[cfg(all(not(target_os = "freebsd"), target_pointer_width = "64"))]
#[cfg(all(
not(any(target_os = "freebsd", target_os = "openbsd")),
target_pointer_width = "64"
))]
return Self {
blocksize: statvfs.f_bsize as u64, // or `statvfs.f_frsize` ?
blocks: statvfs.f_blocks,
Expand All @@ -507,7 +510,10 @@ impl FsUsage {
files: statvfs.f_files,
ffree: statvfs.f_ffree,
};
#[cfg(all(not(target_os = "freebsd"), not(target_pointer_width = "64")))]
#[cfg(all(
not(any(target_os = "freebsd", target_os = "openbsd")),
not(target_pointer_width = "64")
))]
return Self {
blocksize: statvfs.f_bsize as u64, // or `statvfs.f_frsize` ?
blocks: statvfs.f_blocks.into(),
Expand All @@ -530,6 +536,19 @@ impl FsUsage {
files: statvfs.f_files,
ffree: statvfs.f_ffree.try_into().unwrap(),
};
#[cfg(target_os = "openbsd")]
return Self {
blocksize: statvfs.f_bsize.into(),
blocks: statvfs.f_blocks,
bfree: statvfs.f_bfree,
bavail: statvfs.f_bavail.try_into().unwrap(),
bavail_top_bit_set: ((std::convert::TryInto::<u64>::try_into(statvfs.f_bavail)
.unwrap())
& (1u64.rotate_right(1)))
!= 0,
files: statvfs.f_files,
ffree: statvfs.f_ffree,
};
}
}
#[cfg(not(unix))]
Expand Down Expand Up @@ -617,6 +636,7 @@ impl FsMeta for StatFs {
not(target_vendor = "apple"),
not(target_os = "android"),
not(target_os = "freebsd"),
not(target_os = "openbsd"),
not(target_os = "illumos"),
not(target_os = "solaris"),
not(target_arch = "s390x"),
Expand All @@ -630,6 +650,7 @@ impl FsMeta for StatFs {
target_arch = "s390x",
target_vendor = "apple",
target_os = "android",
target_os = "openbsd",
not(target_pointer_width = "64")
)
))]
Expand All @@ -655,11 +676,19 @@ impl FsMeta for StatFs {
return self.f_bfree.into();
}
fn avail_blocks(&self) -> u64 {
#[cfg(all(not(target_os = "freebsd"), target_pointer_width = "64"))]
#[cfg(all(
not(target_os = "freebsd"),
not(target_os = "openbsd"),
target_pointer_width = "64"
))]
return self.f_bavail;
#[cfg(all(not(target_os = "freebsd"), not(target_pointer_width = "64")))]
#[cfg(all(
not(target_os = "freebsd"),
not(target_os = "openbsd"),
not(target_pointer_width = "64")
))]
return self.f_bavail.into();
#[cfg(target_os = "freebsd")]
#[cfg(any(target_os = "freebsd", target_os = "openbsd"))]
return self.f_bavail.try_into().unwrap();
}
fn total_file_nodes(&self) -> u64 {
Expand Down