Skip to content

Commit f4698ea

Browse files
committed
Skip the OFD locks tests on OverlayFS and musl
OFD lock functions don't work as expected on overlayfs, which is a type of union file system. And OVERLAYFS_SUPER_MAGIC isn't defined on musl, at least not yet.
1 parent d57326e commit f4698ea

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ exclude = [
1717
]
1818

1919
[dependencies]
20-
libc = { git = "https://github.com/rust-lang/libc/", features = [ "extra_traits" ] }
20+
libc = { git = "https://github.com/rust-lang/libc/", rev = "fdc5cf4a1ba362aec989bd3dc7ec88bcd371a23a", features = [ "extra_traits" ] }
2121
bitflags = "1.1"
2222
cfg-if = "0.1.10"
2323

src/sys/statfs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ pub const NFS_SUPER_MAGIC: FsType = FsType(libc::NFS_SUPER_MAGIC);
7272
#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))]
7373
pub const OPENPROM_SUPER_MAGIC: FsType = FsType(libc::OPENPROM_SUPER_MAGIC);
7474
#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))]
75+
pub const OVERLAYFS_SUPER_MAGIC: FsType = FsType(libc::OVERLAYFS_SUPER_MAGIC);
76+
#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))]
7577
pub const PROC_SUPER_MAGIC: FsType = FsType(libc::PROC_SUPER_MAGIC);
7678
#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))]
7779
pub const QNX4_SUPER_MAGIC: FsType = FsType(libc::QNX4_SUPER_MAGIC);

test/test_fcntl.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,19 @@ mod linux_android {
228228
target_arch = "mips64",
229229
target_arch = "mips64el",
230230
target_arch = "powerpc64",
231-
target_arch = "powerpc64le")))]
231+
target_arch = "powerpc64le",
232+
target_env = "musl")))]
232233
fn test_ofd_write_lock() {
233234
let tmp = NamedTempFile::new().unwrap();
234235

235236
let fd = tmp.as_raw_fd();
237+
let statfs = nix::sys::statfs::fstatfs(&tmp).unwrap();
238+
if statfs.filesystem_type() == nix::sys::statfs::OVERLAYFS_SUPER_MAGIC {
239+
// OverlayFS is a union file system. It returns one inode value in
240+
// stat(2), but a different one shows up in /proc/locks. So we must
241+
// skip the test.
242+
skip!("/proc/locks does not work on overlayfs");
243+
}
236244
let inode = fstat(fd).expect("fstat failed").st_ino as usize;
237245

238246
let mut flock = libc::flock {
@@ -262,11 +270,19 @@ mod linux_android {
262270
target_arch = "mips64",
263271
target_arch = "mips64el",
264272
target_arch = "powerpc64",
265-
target_arch = "powerpc64le")))]
273+
target_arch = "powerpc64le",
274+
target_env = "musl")))]
266275
fn test_ofd_read_lock() {
267276
let tmp = NamedTempFile::new().unwrap();
268277

269278
let fd = tmp.as_raw_fd();
279+
let statfs = nix::sys::statfs::fstatfs(&tmp).unwrap();
280+
if statfs.filesystem_type() == nix::sys::statfs::OVERLAYFS_SUPER_MAGIC {
281+
// OverlayFS is a union file system. It returns one inode value in
282+
// stat(2), but a different one shows up in /proc/locks. So we must
283+
// skip the test.
284+
skip!("/proc/locks does not work on overlayfs");
285+
}
270286
let inode = fstat(fd).expect("fstat failed").st_ino as usize;
271287

272288
let mut flock = libc::flock {

0 commit comments

Comments
 (0)