(path: &CStr, oflags: OFlags, mode: Mode)
| 144 | } |
| 145 | |
| 146 | pub(crate) fn open(path: &CStr, oflags: OFlags, mode: Mode) -> io::Result<OwnedFd> { |
| 147 | // Work around <https://sourceware.org/bugzilla/show_bug.cgi?id=17523>. |
| 148 | // glibc versions before 2.25 don't handle `O_TMPFILE` correctly. |
| 149 | #[cfg(all( |
| 150 | unix, |
| 151 | target_env = "gnu", |
| 152 | not(target_os = "hurd"), |
| 153 | not(target_os = "freebsd") |
| 154 | ))] |
| 155 | if oflags.contains(OFlags::TMPFILE) && crate::backend::if_glibc_is_less_than_2_25() { |
| 156 | return open_via_syscall(path, oflags, mode); |
| 157 | } |
| 158 | |
| 159 | // On these platforms, `mode_t` is `u16` and can't be passed directly to a |
| 160 | // variadic function. |
| 161 | #[cfg(any( |
| 162 | apple, |
| 163 | freebsdlike, |
| 164 | all(target_os = "android", target_pointer_width = "32") |
| 165 | ))] |
| 166 | let mode: c::c_uint = mode.bits().into(); |
| 167 | |
| 168 | // Otherwise, cast to `mode_t` as that's what `open` is documented to take. |
| 169 | #[cfg(not(any( |
| 170 | apple, |
| 171 | freebsdlike, |
| 172 | all(target_os = "android", target_pointer_width = "32") |
| 173 | )))] |
| 174 | let mode: c::mode_t = mode.bits() as _; |
| 175 | |
| 176 | unsafe { ret_owned_fd(c::open(c_str(path), bitflags_bits!(oflags), mode)) } |
| 177 | } |
| 178 | |
| 179 | /// Use a direct syscall (via libc) for `openat`. |
| 180 | /// |
no test coverage detected