Skip to content

Commit 5e4acde

Browse files
committed
fs: introduce AT_ filehandle constants for name_to_handle_at(2)
1 parent 5245b81 commit 5e4acde

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

src/backend/libc/fs/types.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,34 @@ bitflags! {
527527
}
528528
}
529529

530+
#[cfg(target_os = "linux")]
531+
bitflags! {
532+
/// `AT_*` constants for use with [`name_to_handle_at`]
533+
///
534+
/// [`name_to_handle_at`]: crate::fs::name_to_handle_at
535+
#[repr(transparent)]
536+
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
537+
pub struct HandleFlags: u32 {
538+
/// `AT_HANDLE_FID`
539+
const FID = linux_raw_sys::general::AT_HANDLE_FID;
540+
541+
/// `AT_HANDLE_MNT_ID_UNIQUE`
542+
const MNT_ID_UNIQUE = linux_raw_sys::general::AT_HANDLE_MNT_ID_UNIQUE;
543+
544+
/// `AT_HANDLE_CONNECTABLE`
545+
const CONNECTABLE = linux_raw_sys::general::AT_HANDLE_CONNECTABLE;
546+
547+
/// `AT_SYMLINK_FOLLOW`
548+
const SYMLINK_FOLLOW = linux_raw_sys::general::AT_SYMLINK_FOLLOW;
549+
550+
/// `AT_EMPTY_PATH`
551+
const EMPTY_PATH = linux_raw_sys::general::AT_EMPTY_PATH;
552+
553+
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
554+
const _ = !0;
555+
}
556+
}
557+
530558
/// `S_IF*` constants for use with [`mknodat`] and [`Stat`]'s `st_mode` field.
531559
///
532560
/// [`mknodat`]: crate::fs::mknodat

src/backend/linux_raw/conv.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,13 @@ pub(crate) mod fs {
333333
}
334334
}
335335

336+
impl<'a, Num: ArgNumber> From<crate::fs::HandleFlags> for ArgReg<'a, Num> {
337+
#[inline]
338+
fn from(flags: crate::fs::HandleFlags) -> Self {
339+
c_uint(flags.bits())
340+
}
341+
}
342+
336343
impl<'a, Num: ArgNumber> From<crate::fs::XattrFlags> for ArgReg<'a, Num> {
337344
#[inline]
338345
fn from(flags: crate::fs::XattrFlags) -> Self {

src/backend/linux_raw/fs/types.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,34 @@ bitflags! {
320320
}
321321
}
322322

323+
#[cfg(target_os = "linux")]
324+
bitflags! {
325+
/// `AT_*` constants for use with [`name_to_handle_at`]
326+
///
327+
/// [`name_to_handle_at`]: crate::fs::name_to_handle_at
328+
#[repr(transparent)]
329+
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
330+
pub struct HandleFlags: ffi::c_uint {
331+
/// `AT_HANDLE_FID`
332+
const FID = linux_raw_sys::general::AT_HANDLE_FID;
333+
334+
/// `AT_HANDLE_MNT_ID_UNIQUE`
335+
const MNT_ID_UNIQUE = linux_raw_sys::general::AT_HANDLE_MNT_ID_UNIQUE;
336+
337+
/// `AT_HANDLE_CONNECTABLE`
338+
const CONNECTABLE = linux_raw_sys::general::AT_HANDLE_CONNECTABLE;
339+
340+
/// `AT_SYMLINK_FOLLOW`
341+
const SYMLINK_FOLLOW = linux_raw_sys::general::AT_SYMLINK_FOLLOW;
342+
343+
/// `AT_EMPTY_PATH`
344+
const EMPTY_PATH = linux_raw_sys::general::AT_EMPTY_PATH;
345+
346+
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
347+
const _ = !0;
348+
}
349+
}
350+
323351
/// `S_IF*` constants for use with [`mknodat`] and [`Stat`]'s `st_mode` field.
324352
///
325353
/// [`mknodat`]: crate::fs::mknodat

0 commit comments

Comments
 (0)