summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/backend/libc/fs/inotify.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rustix/src/backend/libc/fs/inotify.rs')
-rw-r--r--vendor/rustix/src/backend/libc/fs/inotify.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/vendor/rustix/src/backend/libc/fs/inotify.rs b/vendor/rustix/src/backend/libc/fs/inotify.rs
index 8a42e0583..05d4d904f 100644
--- a/vendor/rustix/src/backend/libc/fs/inotify.rs
+++ b/vendor/rustix/src/backend/libc/fs/inotify.rs
@@ -1,7 +1,7 @@
//! inotify support for working with inotifies
-use super::super::c;
-use super::super::conv::{borrowed_fd, c_str, ret, ret_c_int, ret_owned_fd};
+use crate::backend::c;
+use crate::backend::conv::{borrowed_fd, c_str, ret, ret_c_int, ret_owned_fd};
use crate::fd::{BorrowedFd, OwnedFd};
use crate::io;
use bitflags::bitflags;
@@ -10,11 +10,13 @@ bitflags! {
/// `IN_*` for use with [`inotify_init`].
///
/// [`inotify_init`]: crate::fs::inotify::inotify_init
- pub struct CreateFlags: c::c_int {
+ #[repr(transparent)]
+ #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+ pub struct CreateFlags: u32 {
/// `IN_CLOEXEC`
- const CLOEXEC = c::IN_CLOEXEC;
+ const CLOEXEC = bitcast!(c::IN_CLOEXEC);
/// `IN_NONBLOCK`
- const NONBLOCK = c::IN_NONBLOCK;
+ const NONBLOCK = bitcast!(c::IN_NONBLOCK);
}
}
@@ -22,7 +24,8 @@ bitflags! {
/// `IN*` for use with [`inotify_add_watch`].
///
/// [`inotify_add_watch`]: crate::fs::inotify::inotify_add_watch
- #[derive(Default)]
+ #[repr(transparent)]
+ #[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct WatchFlags: u32 {
/// `IN_ACCESS`
const ACCESS = c::IN_ACCESS;
@@ -78,7 +81,7 @@ bitflags! {
#[doc(alias = "inotify_init1")]
pub fn inotify_init(flags: CreateFlags) -> io::Result<OwnedFd> {
// SAFETY: `inotify_init1` has no safety preconditions.
- unsafe { ret_owned_fd(c::inotify_init1(flags.bits())) }
+ unsafe { ret_owned_fd(c::inotify_init1(bitflags_bits!(flags))) }
}
/// `inotify_add_watch(self, path, flags)`—Adds a watch to inotify
@@ -113,7 +116,8 @@ pub fn inotify_add_watch<P: crate::path::Arg>(
/// by [`inotify_add_watch`] and not previously have been removed.
#[doc(alias = "inotify_rm_watch")]
pub fn inotify_remove_watch(inot: BorrowedFd<'_>, wd: i32) -> io::Result<()> {
- // Android's `inotify_rm_watch` takes u32 despite `inotify_add_watch` is i32.
+ // Android's `inotify_rm_watch` takes `u32` despite that
+ // `inotify_add_watch` expects a `i32`.
#[cfg(target_os = "android")]
let wd = wd as u32;
// SAFETY: The fd is valid and closing an arbitrary wd is valid.