Workaround a quirk in the OpenOptions unix impl
Setting the open option to "read only" makes the library happy, since
"not readable, not writable, not appendable" is not considered valid in
the unix implementation.
https://github.com/rust-lang/rust/blob/68b554e6af18726fe6fa8de2134c59c441e0b019/library/std/src/sys/unix/fs.rs#L761
Bug: 203251769
Test: atest AuthFsHostTest
Change-Id: Ica4a9a212e5c75dcdf559213d44e0076680d2cf9
diff --git a/authfs/tests/open_then_run.rs b/authfs/tests/open_then_run.rs
index 3e6ae71..fca8953 100644
--- a/authfs/tests/open_then_run.rs
+++ b/authfs/tests/open_then_run.rs
@@ -122,8 +122,13 @@
// them for the provided program, and are not supposed to do anything else.
OpenOptions::new()
.custom_flags(libc::O_PATH | libc::O_DIRECTORY)
+ // The custom flags above is not taken into consideration by the unix implementation of
+ // OpenOptions for flag validation. So even though the man page of open(2) says that
+ // most flags include access mode are ignored, we still need to set a "valid" mode to
+ // make the library happy. The value does not appear to matter elsewhere in the library.
+ .read(true)
.open(path)
- .with_context(|| format!("Open {} directory", path))
+ .with_context(|| format!("Open {} directory as path", path))
})?;
let cmdline_args: Vec<_> = matches.values_of("args").unwrap().map(|s| s.to_string()).collect();