1use crate::backend::c;
2use bitflags::bitflags;
3
4bitflags! {
5 #[repr(transparent)]
9 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
10 pub struct Access: c::c_uint {
11 const READ_OK = linux_raw_sys::general::R_OK;
13
14 const WRITE_OK = linux_raw_sys::general::W_OK;
16
17 const EXEC_OK = linux_raw_sys::general::X_OK;
19
20 const EXISTS = linux_raw_sys::general::F_OK;
22
23 const _ = !0;
25 }
26}
27
28bitflags! {
29 #[repr(transparent)]
35 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
36 pub struct AtFlags: c::c_uint {
37 const SYMLINK_NOFOLLOW = linux_raw_sys::general::AT_SYMLINK_NOFOLLOW;
39
40 const EACCESS = linux_raw_sys::general::AT_EACCESS;
42
43 const REMOVEDIR = linux_raw_sys::general::AT_REMOVEDIR;
45
46 const SYMLINK_FOLLOW = linux_raw_sys::general::AT_SYMLINK_FOLLOW;
48
49 const NO_AUTOMOUNT = linux_raw_sys::general::AT_NO_AUTOMOUNT;
51
52 const EMPTY_PATH = linux_raw_sys::general::AT_EMPTY_PATH;
54
55 const STATX_SYNC_AS_STAT = linux_raw_sys::general::AT_STATX_SYNC_AS_STAT;
57
58 const STATX_FORCE_SYNC = linux_raw_sys::general::AT_STATX_FORCE_SYNC;
60
61 const STATX_DONT_SYNC = linux_raw_sys::general::AT_STATX_DONT_SYNC;
63
64 const _ = !0;
66 }
67}
68
69bitflags! {
70 #[repr(transparent)]
76 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
77 pub struct Mode: RawMode {
78 const RWXU = linux_raw_sys::general::S_IRWXU;
80
81 const RUSR = linux_raw_sys::general::S_IRUSR;
83
84 const WUSR = linux_raw_sys::general::S_IWUSR;
86
87 const XUSR = linux_raw_sys::general::S_IXUSR;
89
90 const RWXG = linux_raw_sys::general::S_IRWXG;
92
93 const RGRP = linux_raw_sys::general::S_IRGRP;
95
96 const WGRP = linux_raw_sys::general::S_IWGRP;
98
99 const XGRP = linux_raw_sys::general::S_IXGRP;
101
102 const RWXO = linux_raw_sys::general::S_IRWXO;
104
105 const ROTH = linux_raw_sys::general::S_IROTH;
107
108 const WOTH = linux_raw_sys::general::S_IWOTH;
110
111 const XOTH = linux_raw_sys::general::S_IXOTH;
113
114 const SUID = linux_raw_sys::general::S_ISUID;
116
117 const SGID = linux_raw_sys::general::S_ISGID;
119
120 const SVTX = linux_raw_sys::general::S_ISVTX;
122
123 const _ = !0;
125 }
126}
127
128impl Mode {
129 #[inline]
132 pub const fn from_raw_mode(st_mode: RawMode) -> Self {
133 Self::from_bits_truncate(st_mode)
134 }
135
136 #[inline]
138 pub const fn as_raw_mode(self) -> RawMode {
139 self.bits()
140 }
141}
142
143impl From<RawMode> for Mode {
144 #[inline]
151 fn from(st_mode: RawMode) -> Self {
152 Self::from_raw_mode(st_mode)
153 }
154}
155
156impl From<Mode> for RawMode {
157 #[inline]
164 fn from(mode: Mode) -> Self {
165 mode.as_raw_mode()
166 }
167}
168
169bitflags! {
170 #[repr(transparent)]
174 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
175 pub struct OFlags: c::c_uint {
176 const ACCMODE = linux_raw_sys::general::O_ACCMODE;
178
179 const RWMODE = linux_raw_sys::general::O_RDONLY |
187 linux_raw_sys::general::O_WRONLY |
188 linux_raw_sys::general::O_RDWR;
189
190 const APPEND = linux_raw_sys::general::O_APPEND;
192
193 #[doc(alias = "CREAT")]
195 const CREATE = linux_raw_sys::general::O_CREAT;
196
197 const DIRECTORY = linux_raw_sys::general::O_DIRECTORY;
199
200 const DSYNC = linux_raw_sys::general::O_SYNC;
202
203 const EXCL = linux_raw_sys::general::O_EXCL;
205
206 const FSYNC = linux_raw_sys::general::O_SYNC;
208
209 const NOFOLLOW = linux_raw_sys::general::O_NOFOLLOW;
211
212 const NONBLOCK = linux_raw_sys::general::O_NONBLOCK;
214
215 const RDONLY = linux_raw_sys::general::O_RDONLY;
217
218 const WRONLY = linux_raw_sys::general::O_WRONLY;
220
221 const RDWR = linux_raw_sys::general::O_RDWR;
225
226 const NOCTTY = linux_raw_sys::general::O_NOCTTY;
228
229 const RSYNC = linux_raw_sys::general::O_SYNC;
231
232 const SYNC = linux_raw_sys::general::O_SYNC;
234
235 const TRUNC = linux_raw_sys::general::O_TRUNC;
237
238 const PATH = linux_raw_sys::general::O_PATH;
240
241 const CLOEXEC = linux_raw_sys::general::O_CLOEXEC;
243
244 const TMPFILE = linux_raw_sys::general::O_TMPFILE;
246
247 const NOATIME = linux_raw_sys::general::O_NOATIME;
249
250 const DIRECT = linux_raw_sys::general::O_DIRECT;
252
253 const _ = !0;
255 }
256}
257
258bitflags! {
259 #[repr(transparent)]
263 #[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)]
264 pub struct ResolveFlags: u64 {
265 const NO_XDEV = linux_raw_sys::general::RESOLVE_NO_XDEV as u64;
267
268 const NO_MAGICLINKS = linux_raw_sys::general::RESOLVE_NO_MAGICLINKS as u64;
270
271 const NO_SYMLINKS = linux_raw_sys::general::RESOLVE_NO_SYMLINKS as u64;
273
274 const BENEATH = linux_raw_sys::general::RESOLVE_BENEATH as u64;
276
277 const IN_ROOT = linux_raw_sys::general::RESOLVE_IN_ROOT as u64;
279
280 const CACHED = linux_raw_sys::general::RESOLVE_CACHED as u64;
282
283 const _ = !0;
285 }
286}
287
288bitflags! {
289 #[repr(transparent)]
293 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
294 pub struct RenameFlags: c::c_uint {
295 const EXCHANGE = linux_raw_sys::general::RENAME_EXCHANGE;
297
298 const NOREPLACE = linux_raw_sys::general::RENAME_NOREPLACE;
300
301 const WHITEOUT = linux_raw_sys::general::RENAME_WHITEOUT;
303
304 const _ = !0;
306 }
307}
308
309#[derive(Clone, Copy, Debug, PartialEq, Eq)]
314pub enum FileType {
315 RegularFile = linux_raw_sys::general::S_IFREG as isize,
317
318 Directory = linux_raw_sys::general::S_IFDIR as isize,
320
321 Symlink = linux_raw_sys::general::S_IFLNK as isize,
323
324 #[doc(alias = "IFO")]
326 Fifo = linux_raw_sys::general::S_IFIFO as isize,
327
328 Socket = linux_raw_sys::general::S_IFSOCK as isize,
330
331 CharacterDevice = linux_raw_sys::general::S_IFCHR as isize,
333
334 BlockDevice = linux_raw_sys::general::S_IFBLK as isize,
336
337 Unknown,
339}
340
341impl FileType {
342 #[inline]
345 pub const fn from_raw_mode(st_mode: RawMode) -> Self {
346 match st_mode & linux_raw_sys::general::S_IFMT {
347 linux_raw_sys::general::S_IFREG => Self::RegularFile,
348 linux_raw_sys::general::S_IFDIR => Self::Directory,
349 linux_raw_sys::general::S_IFLNK => Self::Symlink,
350 linux_raw_sys::general::S_IFIFO => Self::Fifo,
351 linux_raw_sys::general::S_IFSOCK => Self::Socket,
352 linux_raw_sys::general::S_IFCHR => Self::CharacterDevice,
353 linux_raw_sys::general::S_IFBLK => Self::BlockDevice,
354 _ => Self::Unknown,
355 }
356 }
357
358 #[inline]
360 pub const fn as_raw_mode(self) -> RawMode {
361 match self {
362 Self::RegularFile => linux_raw_sys::general::S_IFREG,
363 Self::Directory => linux_raw_sys::general::S_IFDIR,
364 Self::Symlink => linux_raw_sys::general::S_IFLNK,
365 Self::Fifo => linux_raw_sys::general::S_IFIFO,
366 Self::Socket => linux_raw_sys::general::S_IFSOCK,
367 Self::CharacterDevice => linux_raw_sys::general::S_IFCHR,
368 Self::BlockDevice => linux_raw_sys::general::S_IFBLK,
369 Self::Unknown => linux_raw_sys::general::S_IFMT,
370 }
371 }
372
373 #[inline]
375 pub(crate) const fn from_dirent_d_type(d_type: u8) -> Self {
376 match d_type as u32 {
377 linux_raw_sys::general::DT_REG => Self::RegularFile,
378 linux_raw_sys::general::DT_DIR => Self::Directory,
379 linux_raw_sys::general::DT_LNK => Self::Symlink,
380 linux_raw_sys::general::DT_SOCK => Self::Socket,
381 linux_raw_sys::general::DT_FIFO => Self::Fifo,
382 linux_raw_sys::general::DT_CHR => Self::CharacterDevice,
383 linux_raw_sys::general::DT_BLK => Self::BlockDevice,
384 _ => Self::Unknown,
386 }
387 }
388}
389
390#[derive(Debug, Copy, Clone, Eq, PartialEq)]
394#[repr(u32)]
395pub enum Advice {
396 Normal = linux_raw_sys::general::POSIX_FADV_NORMAL,
398
399 Sequential = linux_raw_sys::general::POSIX_FADV_SEQUENTIAL,
401
402 Random = linux_raw_sys::general::POSIX_FADV_RANDOM,
404
405 NoReuse = linux_raw_sys::general::POSIX_FADV_NOREUSE,
407
408 WillNeed = linux_raw_sys::general::POSIX_FADV_WILLNEED,
410
411 DontNeed = linux_raw_sys::general::POSIX_FADV_DONTNEED,
413}
414
415bitflags! {
416 #[repr(transparent)]
420 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
421 pub struct MemfdFlags: c::c_uint {
422 const CLOEXEC = linux_raw_sys::general::MFD_CLOEXEC;
424
425 const ALLOW_SEALING = linux_raw_sys::general::MFD_ALLOW_SEALING;
427
428 const HUGETLB = linux_raw_sys::general::MFD_HUGETLB;
430
431 const HUGE_64KB = linux_raw_sys::general::MFD_HUGE_64KB;
433 const HUGE_512KB = linux_raw_sys::general::MFD_HUGE_512KB;
435 const HUGE_1MB = linux_raw_sys::general::MFD_HUGE_1MB;
437 const HUGE_2MB = linux_raw_sys::general::MFD_HUGE_2MB;
439 const HUGE_8MB = linux_raw_sys::general::MFD_HUGE_8MB;
441 const HUGE_16MB = linux_raw_sys::general::MFD_HUGE_16MB;
443 const HUGE_32MB = linux_raw_sys::general::MFD_HUGE_32MB;
445 const HUGE_256MB = linux_raw_sys::general::MFD_HUGE_256MB;
447 const HUGE_512MB = linux_raw_sys::general::MFD_HUGE_512MB;
449 const HUGE_1GB = linux_raw_sys::general::MFD_HUGE_1GB;
451 const HUGE_2GB = linux_raw_sys::general::MFD_HUGE_2GB;
453 const HUGE_16GB = linux_raw_sys::general::MFD_HUGE_16GB;
455
456 const _ = !0;
458 }
459}
460
461bitflags! {
462 #[repr(transparent)]
468 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
469 pub struct SealFlags: u32 {
470 const SEAL = linux_raw_sys::general::F_SEAL_SEAL;
472 const SHRINK = linux_raw_sys::general::F_SEAL_SHRINK;
474 const GROW = linux_raw_sys::general::F_SEAL_GROW;
476 const WRITE = linux_raw_sys::general::F_SEAL_WRITE;
478 const FUTURE_WRITE = linux_raw_sys::general::F_SEAL_FUTURE_WRITE;
480
481 const _ = !0;
483 }
484}
485
486bitflags! {
487 #[repr(transparent)]
491 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
492 pub struct StatxFlags: u32 {
493 const TYPE = linux_raw_sys::general::STATX_TYPE;
495
496 const MODE = linux_raw_sys::general::STATX_MODE;
498
499 const NLINK = linux_raw_sys::general::STATX_NLINK;
501
502 const UID = linux_raw_sys::general::STATX_UID;
504
505 const GID = linux_raw_sys::general::STATX_GID;
507
508 const ATIME = linux_raw_sys::general::STATX_ATIME;
510
511 const MTIME = linux_raw_sys::general::STATX_MTIME;
513
514 const CTIME = linux_raw_sys::general::STATX_CTIME;
516
517 const INO = linux_raw_sys::general::STATX_INO;
519
520 const SIZE = linux_raw_sys::general::STATX_SIZE;
522
523 const BLOCKS = linux_raw_sys::general::STATX_BLOCKS;
525
526 const BASIC_STATS = linux_raw_sys::general::STATX_BASIC_STATS;
528
529 const BTIME = linux_raw_sys::general::STATX_BTIME;
531
532 const MNT_ID = linux_raw_sys::general::STATX_MNT_ID;
534
535 const DIOALIGN = linux_raw_sys::general::STATX_DIOALIGN;
537
538 const ALL = linux_raw_sys::general::STATX_ALL;
540
541 const _ = !0;
543 }
544}
545
546bitflags! {
547 #[repr(transparent)]
551 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
552 pub struct FallocateFlags: u32 {
553 const KEEP_SIZE = linux_raw_sys::general::FALLOC_FL_KEEP_SIZE;
555 const PUNCH_HOLE = linux_raw_sys::general::FALLOC_FL_PUNCH_HOLE;
557 const NO_HIDE_STALE = linux_raw_sys::general::FALLOC_FL_NO_HIDE_STALE;
559 const COLLAPSE_RANGE = linux_raw_sys::general::FALLOC_FL_COLLAPSE_RANGE;
561 const ZERO_RANGE = linux_raw_sys::general::FALLOC_FL_ZERO_RANGE;
563 const INSERT_RANGE = linux_raw_sys::general::FALLOC_FL_INSERT_RANGE;
565 const UNSHARE_RANGE = linux_raw_sys::general::FALLOC_FL_UNSHARE_RANGE;
567
568 const _ = !0;
570 }
571}
572
573bitflags! {
574 #[repr(transparent)]
576 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
577 pub struct StatVfsMountFlags: u64 {
578 const MANDLOCK = linux_raw_sys::general::MS_MANDLOCK as u64;
580
581 const NOATIME = linux_raw_sys::general::MS_NOATIME as u64;
583
584 const NODEV = linux_raw_sys::general::MS_NODEV as u64;
586
587 const NODIRATIME = linux_raw_sys::general::MS_NODIRATIME as u64;
589
590 const NOEXEC = linux_raw_sys::general::MS_NOEXEC as u64;
592
593 const NOSUID = linux_raw_sys::general::MS_NOSUID as u64;
595
596 const RDONLY = linux_raw_sys::general::MS_RDONLY as u64;
598
599 const RELATIME = linux_raw_sys::general::MS_RELATIME as u64;
601
602 const SYNCHRONOUS = linux_raw_sys::general::MS_SYNCHRONOUS as u64;
604
605 const _ = !0;
607 }
608}
609
610#[derive(Clone, Copy, Debug, PartialEq, Eq)]
615#[repr(u32)]
616pub enum FlockOperation {
617 LockShared = linux_raw_sys::general::LOCK_SH,
619 LockExclusive = linux_raw_sys::general::LOCK_EX,
621 Unlock = linux_raw_sys::general::LOCK_UN,
623 NonBlockingLockShared = linux_raw_sys::general::LOCK_SH | linux_raw_sys::general::LOCK_NB,
625 NonBlockingLockExclusive = linux_raw_sys::general::LOCK_EX | linux_raw_sys::general::LOCK_NB,
627 NonBlockingUnlock = linux_raw_sys::general::LOCK_UN | linux_raw_sys::general::LOCK_NB,
629}
630
631#[cfg(any(
639 target_pointer_width = "32",
640 target_arch = "mips64",
641 target_arch = "mips64r6"
642))]
643#[repr(C)]
644#[derive(Debug, Copy, Clone)]
645#[allow(missing_docs)]
646pub struct Stat {
647 pub st_dev: u64,
648 pub st_mode: u32,
649 pub st_nlink: u32,
650 pub st_uid: u32,
651 pub st_gid: u32,
652 pub st_rdev: u64,
653 pub st_size: i64,
654 pub st_blksize: u32,
655 pub st_blocks: u64,
656 pub st_atime: u64,
657 pub st_atime_nsec: u32,
658 pub st_mtime: u64,
659 pub st_mtime_nsec: u32,
660 pub st_ctime: u64,
661 pub st_ctime_nsec: u32,
662 pub st_ino: u64,
663}
664
665#[cfg(all(
670 target_pointer_width = "64",
671 not(target_arch = "mips64"),
672 not(target_arch = "mips64r6")
673))]
674pub type Stat = linux_raw_sys::general::stat;
675
676#[allow(clippy::module_name_repetitions)]
681pub type StatFs = linux_raw_sys::general::statfs64;
682
683#[allow(missing_docs)]
688pub struct StatVfs {
689 pub f_bsize: u64,
690 pub f_frsize: u64,
691 pub f_blocks: u64,
692 pub f_bfree: u64,
693 pub f_bavail: u64,
694 pub f_files: u64,
695 pub f_ffree: u64,
696 pub f_favail: u64,
697 pub f_fsid: u64,
698 pub f_flag: StatVfsMountFlags,
699 pub f_namemax: u64,
700}
701
702pub type Statx = linux_raw_sys::general::statx;
706
707pub type StatxTimestamp = linux_raw_sys::general::statx_timestamp;
709
710#[cfg(not(any(
712 target_arch = "x86",
713 target_arch = "sparc",
714 target_arch = "avr",
715 target_arch = "arm",
716)))]
717pub type RawMode = linux_raw_sys::general::__kernel_mode_t;
718
719#[cfg(any(
721 target_arch = "x86",
722 target_arch = "sparc",
723 target_arch = "avr",
724 target_arch = "arm",
725))]
726pub type RawMode = c::c_uint;
728
729pub type Dev = u64;
732
733#[cfg(not(any(target_arch = "mips64", target_arch = "mips64r6")))]
735pub type FsWord = linux_raw_sys::general::__fsword_t;
736
737#[cfg(any(target_arch = "mips64", target_arch = "mips64r6"))]
739pub type FsWord = i64;