Skip to content

Commit ba63b05

Browse files
bors[bot]asomers
andauthored
Merge #1168
1168: Fix the build on OpenBSD. r=asomers a=asomers We were assuming the wrong types for f_iosize and f_ffree in struct statfs on OpenBSD. Fixes #1125 Co-authored-by: Alan Somers <[email protected]>
2 parents a78ddbc + 7a1e861 commit ba63b05

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55

66
## [Unreleased] - ReleaseDate
7+
### Added
8+
### Changed
9+
### Fixed
10+
11+
- Fixed the build for OpenBSD
12+
(#[1168](https://github.com/nix-rust/nix/pull/1168))
13+
14+
### Removed
715

816
## [0.16.0] - 1 December 2019
917
### Added

src/sys/statfs.rs

+19-16
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,28 @@ impl Statfs {
106106
}
107107

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

114+
/// Optimal transfer block size
115+
#[cfg(target_os = "openbsd")]
116+
pub fn optimal_transfer_size(&self) -> u32 {
117+
self.0.f_iosize
118+
}
119+
114120
/// Optimal transfer block size
115121
#[cfg(all(target_os = "linux", target_arch = "s390x"))]
116122
pub fn optimal_transfer_size(&self) -> u32 {
117123
self.0.f_bsize
118124
}
119125

120126
/// Optimal transfer block size
121-
#[cfg(all(target_os = "linux", target_env = "musl"))]
127+
#[cfg(any(
128+
target_os = "android",
129+
all(target_os = "linux", target_env = "musl")
130+
))]
122131
pub fn optimal_transfer_size(&self) -> libc::c_ulong {
123132
self.0.f_bsize
124133
}
@@ -129,12 +138,6 @@ impl Statfs {
129138
self.0.f_bsize
130139
}
131140

132-
/// Optimal transfer block size
133-
#[cfg(target_os = "android")]
134-
pub fn optimal_transfer_size(&self) -> libc::c_ulong {
135-
self.0.f_bsize
136-
}
137-
138141
/// Optimal transfer block size
139142
#[cfg(target_os = "dragonfly")]
140143
pub fn optimal_transfer_size(&self) -> libc::c_long {
@@ -375,7 +378,13 @@ impl Statfs {
375378
}
376379

377380
/// Free file nodes in filesystem
378-
#[cfg(any(target_os = "ios", target_os = "macos", target_os = "android"))]
381+
#[cfg(any(
382+
target_os = "android",
383+
target_os = "ios",
384+
all(target_os = "linux", target_env = "musl"),
385+
target_os = "macos",
386+
target_os = "openbsd"
387+
))]
379388
pub fn files_free(&self) -> u64 {
380389
self.0.f_ffree
381390
}
@@ -387,17 +396,11 @@ impl Statfs {
387396
}
388397

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

395-
/// Free file nodes in filesystem
396-
#[cfg(all(target_os = "linux", target_env = "musl"))]
397-
pub fn files_free(&self) -> u64 {
398-
self.0.f_ffree
399-
}
400-
401404
/// Free file nodes in filesystem
402405
#[cfg(not(any(
403406
target_os = "ios",

0 commit comments

Comments
 (0)