Skip to content

Commit

Permalink
Fix the build on OpenBSD.
Browse files Browse the repository at this point in the history
We were assuming the wrong types for f_iosize and f_ffree in struct
statfs on OpenBSD.

Fixes #1125
  • Loading branch information
asomers committed Dec 23, 2019
1 parent 1282815 commit 3327941
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased] - ReleaseDate
### Added
### Changed
### Fixed

- Fixed the build for OpenBSD
(#[1168](https://github.com/nix-rust/nix/pull/1168))

### Removed

## [0.16.0] - 1 December 2019
### Added
Expand Down
35 changes: 19 additions & 16 deletions src/sys/statfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,28 @@ impl Statfs {
}

/// Optimal transfer block size
#[cfg(any(target_os = "ios", target_os = "macos", target_os = "openbsd"))]
#[cfg(any(target_os = "ios", target_os = "macos"))]
pub fn optimal_transfer_size(&self) -> i32 {
self.0.f_iosize
}

/// Optimal transfer block size
#[cfg(target_os = "openbsd")]
pub fn optimal_transfer_size(&self) -> u32 {
self.0.f_iosize
}

/// Optimal transfer block size
#[cfg(all(target_os = "linux", target_arch = "s390x"))]
pub fn optimal_transfer_size(&self) -> u32 {
self.0.f_bsize
}

/// Optimal transfer block size
#[cfg(all(target_os = "linux", target_env = "musl"))]
#[cfg(any(
target_os = "android",
all(target_os = "linux", target_env = "musl")
))]
pub fn optimal_transfer_size(&self) -> libc::c_ulong {
self.0.f_bsize
}
Expand All @@ -129,12 +138,6 @@ impl Statfs {
self.0.f_bsize
}

/// Optimal transfer block size
#[cfg(target_os = "android")]
pub fn optimal_transfer_size(&self) -> libc::c_ulong {
self.0.f_bsize
}

/// Optimal transfer block size
#[cfg(target_os = "dragonfly")]
pub fn optimal_transfer_size(&self) -> libc::c_long {
Expand Down Expand Up @@ -375,7 +378,13 @@ impl Statfs {
}

/// Free file nodes in filesystem
#[cfg(any(target_os = "ios", target_os = "macos", target_os = "android"))]
#[cfg(any(
target_os = "android",
target_os = "ios",
all(target_os = "linux", target_env = "musl"),
target_os = "macos",
target_os = "openbsd"
))]
pub fn files_free(&self) -> u64 {
self.0.f_ffree
}
Expand All @@ -387,17 +396,11 @@ impl Statfs {
}

/// Free file nodes in filesystem
#[cfg(any(target_os = "freebsd", target_os = "openbsd"))]
#[cfg(target_os = "freebsd")]
pub fn files_free(&self) -> i64 {
self.0.f_ffree
}

/// Free file nodes in filesystem
#[cfg(all(target_os = "linux", target_env = "musl"))]
pub fn files_free(&self) -> u64 {
self.0.f_ffree
}

/// Free file nodes in filesystem
#[cfg(not(any(
target_os = "ios",
Expand Down

0 comments on commit 3327941

Please sign in to comment.