1use crate::backend::c;
2use crate::ffi;
3use bitflags::bitflags;
4
5#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
6bitflags! {
7 #[repr(transparent)]
11 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
12 pub struct Access: ffi::c_int {
13 const READ_OK = c::R_OK;
15
16 const WRITE_OK = c::W_OK;
18
19 const EXEC_OK = c::X_OK;
21
22 const EXISTS = c::F_OK;
24
25 const _ = !0;
27 }
28}
29
30#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "redox")))]
31bitflags! {
32 #[repr(transparent)]
38 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
39 pub struct AtFlags: u32 {
40 const SYMLINK_NOFOLLOW = bitcast!(c::AT_SYMLINK_NOFOLLOW);
42
43 #[cfg(not(target_os = "android"))]
45 const EACCESS = bitcast!(c::AT_EACCESS);
46
47 const REMOVEDIR = bitcast!(c::AT_REMOVEDIR);
49
50 const SYMLINK_FOLLOW = bitcast!(c::AT_SYMLINK_FOLLOW);
52
53 #[cfg(any(linux_like, target_os = "fuchsia"))]
55 const NO_AUTOMOUNT = bitcast!(c::AT_NO_AUTOMOUNT);
56
57 #[cfg(any(
59 linux_kernel,
60 target_os = "freebsd",
61 target_os = "fuchsia",
62 ))]
63 const EMPTY_PATH = bitcast!(c::AT_EMPTY_PATH);
64
65 #[cfg(target_os = "freebsd")]
67 const RESOLVE_BENEATH = bitcast!(c::AT_RESOLVE_BENEATH);
68
69 #[cfg(all(target_os = "linux", target_env = "gnu"))]
71 const STATX_SYNC_AS_STAT = bitcast!(c::AT_STATX_SYNC_AS_STAT);
72
73 #[cfg(all(target_os = "linux", target_env = "gnu"))]
75 const STATX_FORCE_SYNC = bitcast!(c::AT_STATX_FORCE_SYNC);
76
77 #[cfg(all(target_os = "linux", target_env = "gnu"))]
79 const STATX_DONT_SYNC = bitcast!(c::AT_STATX_DONT_SYNC);
80
81 const _ = !0;
83 }
84}
85
86#[cfg(target_os = "horizon")]
87bitflags! {
88 #[repr(transparent)]
94 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
95 pub struct AtFlags: u32 {
96 const _ = !0;
98 }
99}
100
101#[cfg(not(target_os = "horizon"))]
102bitflags! {
103 #[repr(transparent)]
109 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
110 pub struct Mode: RawMode {
111 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
113 const RWXU = c::S_IRWXU as RawMode;
114
115 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
117 const RUSR = c::S_IRUSR as RawMode;
118
119 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
121 const WUSR = c::S_IWUSR as RawMode;
122
123 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
125 const XUSR = c::S_IXUSR as RawMode;
126
127 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
129 const RWXG = c::S_IRWXG as RawMode;
130
131 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
133 const RGRP = c::S_IRGRP as RawMode;
134
135 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
137 const WGRP = c::S_IWGRP as RawMode;
138
139 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
141 const XGRP = c::S_IXGRP as RawMode;
142
143 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
145 const RWXO = c::S_IRWXO as RawMode;
146
147 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
149 const ROTH = c::S_IROTH as RawMode;
150
151 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
153 const WOTH = c::S_IWOTH as RawMode;
154
155 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
157 const XOTH = c::S_IXOTH as RawMode;
158
159 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
161 const SUID = c::S_ISUID as RawMode;
162
163 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
165 const SGID = c::S_ISGID as RawMode;
166
167 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
169 const SVTX = c::S_ISVTX as RawMode;
170
171 const _ = !0;
173 }
174}
175
176#[cfg(target_os = "horizon")]
177bitflags! {
178 #[repr(transparent)]
184 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
185 pub struct Mode: RawMode {
186 const _ = !0;
188 }
189}
190
191#[cfg(not(target_os = "espidf"))]
192impl Mode {
193 #[inline]
196 pub const fn from_raw_mode(st_mode: RawMode) -> Self {
197 Self::from_bits_truncate(st_mode & !c::S_IFMT as RawMode)
198 }
199
200 #[inline]
202 pub const fn as_raw_mode(self) -> RawMode {
203 self.bits()
204 }
205}
206
207#[cfg(not(target_os = "espidf"))]
208impl From<RawMode> for Mode {
209 #[inline]
216 fn from(st_mode: RawMode) -> Self {
217 Self::from_raw_mode(st_mode)
218 }
219}
220
221#[cfg(not(target_os = "espidf"))]
222impl From<Mode> for RawMode {
223 #[inline]
230 fn from(mode: Mode) -> Self {
231 mode.as_raw_mode()
232 }
233}
234
235bitflags! {
236 #[repr(transparent)]
240 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
241 pub struct OFlags: u32 {
242 const ACCMODE = bitcast!(c::O_ACCMODE);
244
245 const RWMODE = bitcast!(c::O_RDONLY | c::O_WRONLY | c::O_RDWR);
253
254 const APPEND = bitcast!(c::O_APPEND);
256
257 #[doc(alias = "CREAT")]
259 const CREATE = bitcast!(c::O_CREAT);
260
261 #[cfg(not(any(target_os = "espidf", target_os = "horizon")))]
263 const DIRECTORY = bitcast!(c::O_DIRECTORY);
264
265 #[cfg(not(any(target_os = "dragonfly", target_os = "espidf", target_os = "horizon", target_os = "l4re", target_os = "redox", target_os = "vita")))]
267 const DSYNC = bitcast!(c::O_DSYNC);
268
269 const EXCL = bitcast!(c::O_EXCL);
271
272 #[cfg(any(
274 bsd,
275 all(target_os = "linux", not(target_env = "musl")),
276 ))]
277 const FSYNC = bitcast!(c::O_FSYNC);
278
279 #[cfg(not(any(target_os = "espidf", target_os = "horizon")))]
281 const NOFOLLOW = bitcast!(c::O_NOFOLLOW);
282
283 const NONBLOCK = bitcast!(c::O_NONBLOCK);
285
286 const RDONLY = bitcast!(c::O_RDONLY);
288
289 const WRONLY = bitcast!(c::O_WRONLY);
291
292 const RDWR = bitcast!(c::O_RDWR);
296
297 #[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "l4re", target_os = "redox", target_os = "vita")))]
299 const NOCTTY = bitcast!(c::O_NOCTTY);
300
301 #[cfg(any(
303 linux_kernel,
304 netbsdlike,
305 solarish,
306 target_os = "emscripten",
307 target_os = "wasi",
308 ))]
309 const RSYNC = bitcast!(c::O_RSYNC);
310
311 #[cfg(not(any(target_os = "l4re", target_os = "redox")))]
313 const SYNC = bitcast!(c::O_SYNC);
314
315 const TRUNC = bitcast!(c::O_TRUNC);
317
318 #[cfg(any(
320 linux_kernel,
321 target_os = "emscripten",
322 target_os = "freebsd",
323 target_os = "fuchsia",
324 target_os = "redox",
325 ))]
326 const PATH = bitcast!(c::O_PATH);
327
328 const CLOEXEC = bitcast!(c::O_CLOEXEC);
330
331 #[cfg(any(
333 linux_kernel,
334 target_os = "emscripten",
335 target_os = "fuchsia",
336 ))]
337 const TMPFILE = bitcast!(c::O_TMPFILE);
338
339 #[cfg(any(
341 linux_kernel,
342 target_os = "fuchsia",
343 ))]
344 const NOATIME = bitcast!(c::O_NOATIME);
345
346 #[cfg(any(
348 linux_kernel,
349 target_os = "emscripten",
350 target_os = "freebsd",
351 target_os = "fuchsia",
352 target_os = "netbsd",
353 ))]
354 const DIRECT = bitcast!(c::O_DIRECT);
355
356 #[cfg(target_os = "freebsd")]
358 const RESOLVE_BENEATH = bitcast!(c::O_RESOLVE_BENEATH);
359
360 #[cfg(target_os = "freebsd")]
362 const EMPTY_PATH = bitcast!(c::O_EMPTY_PATH);
363
364 #[cfg(any(linux_kernel, solarish))]
371 const LARGEFILE = bitcast!(c::O_LARGEFILE);
372
373 #[cfg(not(any(
378 target_os = "aix",
379 target_os = "cygwin",
380 target_os = "espidf",
381 target_os = "haiku",
382 target_os = "horizon",
383 target_os = "wasi",
384 target_os = "vita",
385 solarish
386 )))]
387 const ASYNC = bitcast!(c::O_ASYNC);
388
389 const _ = !0;
391 }
392}
393
394#[cfg(apple)]
395bitflags! {
396 #[repr(transparent)]
400 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
401 pub struct CloneFlags: u32 {
402 const NOFOLLOW = 1;
404
405 const NOOWNERCOPY = 2;
407
408 const _ = !0;
410 }
411}
412
413#[cfg(apple)]
414mod copyfile {
415 pub(super) const ACL: u32 = 1 << 0;
416 pub(super) const STAT: u32 = 1 << 1;
417 pub(super) const XATTR: u32 = 1 << 2;
418 pub(super) const DATA: u32 = 1 << 3;
419 pub(super) const SECURITY: u32 = STAT | ACL;
420 pub(super) const METADATA: u32 = SECURITY | XATTR;
421 pub(super) const ALL: u32 = METADATA | DATA;
422}
423
424#[cfg(apple)]
425bitflags! {
426 #[repr(transparent)]
430 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
431 pub struct CopyfileFlags: ffi::c_uint {
432 const ACL = copyfile::ACL;
434
435 const STAT = copyfile::STAT;
437
438 const XATTR = copyfile::XATTR;
440
441 const DATA = copyfile::DATA;
443
444 const SECURITY = copyfile::SECURITY;
446
447 const METADATA = copyfile::METADATA;
449
450 const ALL = copyfile::ALL;
452
453 const _ = !0;
455 }
456}
457
458#[cfg(linux_kernel)]
459bitflags! {
460 #[repr(transparent)]
464 #[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)]
465 pub struct ResolveFlags: u64 {
466 const NO_XDEV = 0x01;
468
469 const NO_MAGICLINKS = 0x02;
471
472 const NO_SYMLINKS = 0x04;
474
475 const BENEATH = 0x08;
477
478 const IN_ROOT = 0x10;
480
481 const CACHED = 0x20;
483
484 const _ = !0;
486 }
487}
488
489#[cfg(linux_kernel)]
490bitflags! {
491 #[repr(transparent)]
495 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
496 pub struct RenameFlags: ffi::c_uint {
497 const EXCHANGE = bitcast!(c::RENAME_EXCHANGE);
499
500 const NOREPLACE = bitcast!(c::RENAME_NOREPLACE);
502
503 const WHITEOUT = bitcast!(c::RENAME_WHITEOUT);
505
506 const _ = !0;
508 }
509}
510
511#[cfg(apple)]
512bitflags! {
513 #[repr(transparent)]
517 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
518 pub struct RenameFlags: ffi::c_uint {
519 const EXCHANGE = bitcast!(c::RENAME_SWAP);
521
522 const NOREPLACE = bitcast!(c::RENAME_EXCL);
524
525 const _ = !0;
527 }
528}
529
530#[derive(Clone, Copy, Debug, PartialEq, Eq)]
535pub enum FileType {
536 RegularFile = c::S_IFREG as isize,
538
539 Directory = c::S_IFDIR as isize,
541
542 Symlink = c::S_IFLNK as isize,
544
545 #[cfg(not(target_os = "wasi"))] #[doc(alias = "IFO")]
548 Fifo = c::S_IFIFO as isize,
549
550 #[cfg(not(target_os = "wasi"))] Socket = c::S_IFSOCK as isize,
553
554 CharacterDevice = c::S_IFCHR as isize,
556
557 BlockDevice = c::S_IFBLK as isize,
559
560 Unknown,
562}
563
564impl FileType {
565 #[inline]
568 pub const fn from_raw_mode(st_mode: RawMode) -> Self {
569 match (st_mode as c::mode_t) & c::S_IFMT {
570 c::S_IFREG => Self::RegularFile,
571 c::S_IFDIR => Self::Directory,
572 c::S_IFLNK => Self::Symlink,
573 #[cfg(not(target_os = "wasi"))] c::S_IFIFO => Self::Fifo,
575 #[cfg(not(target_os = "wasi"))] c::S_IFSOCK => Self::Socket,
577 c::S_IFCHR => Self::CharacterDevice,
578 c::S_IFBLK => Self::BlockDevice,
579 _ => Self::Unknown,
580 }
581 }
582
583 #[inline]
585 pub const fn as_raw_mode(self) -> RawMode {
586 match self {
587 Self::RegularFile => c::S_IFREG as RawMode,
588 Self::Directory => c::S_IFDIR as RawMode,
589 Self::Symlink => c::S_IFLNK as RawMode,
590 #[cfg(not(target_os = "wasi"))] Self::Fifo => c::S_IFIFO as RawMode,
592 #[cfg(not(target_os = "wasi"))] Self::Socket => c::S_IFSOCK as RawMode,
594 Self::CharacterDevice => c::S_IFCHR as RawMode,
595 Self::BlockDevice => c::S_IFBLK as RawMode,
596 Self::Unknown => c::S_IFMT as RawMode,
597 }
598 }
599
600 #[cfg(not(any(
602 solarish,
603 target_os = "aix",
604 target_os = "espidf",
605 target_os = "haiku",
606 target_os = "nto",
607 target_os = "redox",
608 target_os = "vita"
609 )))]
610 #[inline]
611 pub(crate) const fn from_dirent_d_type(d_type: u8) -> Self {
612 match d_type {
613 c::DT_REG => Self::RegularFile,
614 c::DT_DIR => Self::Directory,
615 c::DT_LNK => Self::Symlink,
616 #[cfg(not(target_os = "wasi"))] c::DT_SOCK => Self::Socket,
618 #[cfg(not(target_os = "wasi"))] c::DT_FIFO => Self::Fifo,
620 c::DT_CHR => Self::CharacterDevice,
621 c::DT_BLK => Self::BlockDevice,
622 _ => Self::Unknown,
624 }
625 }
626}
627
628#[cfg(not(any(
632 apple,
633 netbsdlike,
634 target_os = "dragonfly",
635 target_os = "espidf",
636 target_os = "horizon",
637 target_os = "haiku",
638 target_os = "redox",
639 target_os = "solaris",
640 target_os = "vita",
641)))]
642#[derive(Debug, Copy, Clone, Eq, PartialEq)]
643#[repr(u32)]
644pub enum Advice {
645 Normal = c::POSIX_FADV_NORMAL as c::c_uint,
647
648 Sequential = c::POSIX_FADV_SEQUENTIAL as c::c_uint,
650
651 Random = c::POSIX_FADV_RANDOM as c::c_uint,
653
654 NoReuse = c::POSIX_FADV_NOREUSE as c::c_uint,
656
657 WillNeed = c::POSIX_FADV_WILLNEED as c::c_uint,
659
660 DontNeed = c::POSIX_FADV_DONTNEED as c::c_uint,
662}
663
664#[cfg(any(linux_kernel, target_os = "freebsd"))]
665bitflags! {
666 #[repr(transparent)]
670 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
671 pub struct MemfdFlags: ffi::c_uint {
672 const CLOEXEC = c::MFD_CLOEXEC;
674
675 const ALLOW_SEALING = c::MFD_ALLOW_SEALING;
677
678 const HUGETLB = c::MFD_HUGETLB;
680
681 #[cfg(linux_kernel)]
683 const NOEXEC_SEAL = c::MFD_NOEXEC_SEAL;
684 #[cfg(linux_kernel)]
686 const EXEC = c::MFD_EXEC;
687
688 const HUGE_64KB = c::MFD_HUGE_64KB;
690 const HUGE_512KB = c::MFD_HUGE_512KB;
692 const HUGE_1MB = c::MFD_HUGE_1MB;
694 const HUGE_2MB = c::MFD_HUGE_2MB;
696 const HUGE_8MB = c::MFD_HUGE_8MB;
698 const HUGE_16MB = c::MFD_HUGE_16MB;
700 const HUGE_32MB = c::MFD_HUGE_32MB;
702 const HUGE_256MB = c::MFD_HUGE_256MB;
704 const HUGE_512MB = c::MFD_HUGE_512MB;
706 const HUGE_1GB = c::MFD_HUGE_1GB;
708 const HUGE_2GB = c::MFD_HUGE_2GB;
710 const HUGE_16GB = c::MFD_HUGE_16GB;
712
713 const _ = !0;
715 }
716}
717
718#[cfg(any(linux_kernel, target_os = "freebsd", target_os = "fuchsia"))]
719bitflags! {
720 #[repr(transparent)]
726 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
727 pub struct SealFlags: u32 {
728 const SEAL = bitcast!(c::F_SEAL_SEAL);
730 const SHRINK = bitcast!(c::F_SEAL_SHRINK);
732 const GROW = bitcast!(c::F_SEAL_GROW);
734 const WRITE = bitcast!(c::F_SEAL_WRITE);
736 #[cfg(linux_kernel)]
738 const FUTURE_WRITE = bitcast!(c::F_SEAL_FUTURE_WRITE);
739 #[cfg(linux_kernel)]
741 const EXEC = bitcast!(c::F_SEAL_EXEC);
742
743 const _ = !0;
745 }
746}
747
748#[cfg(not(any(
749 netbsdlike,
750 target_os = "espidf",
751 target_os = "horizon",
752 target_os = "nto",
753 target_os = "redox",
754 target_os = "vita"
755)))]
756bitflags! {
757 #[repr(transparent)]
761 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
762 pub struct FallocateFlags: u32 {
763 #[cfg(not(any(
765 bsd,
766 solarish,
767 target_os = "aix",
768 target_os = "haiku",
769 target_os = "hurd",
770 target_os = "wasi",
771 )))]
772 const KEEP_SIZE = bitcast!(c::FALLOC_FL_KEEP_SIZE);
773 #[cfg(not(any(
775 bsd,
776 solarish,
777 target_os = "aix",
778 target_os = "haiku",
779 target_os = "hurd",
780 target_os = "wasi",
781 )))]
782 const PUNCH_HOLE = bitcast!(c::FALLOC_FL_PUNCH_HOLE);
783 #[cfg(not(any(
785 bsd,
786 solarish,
787 target_os = "aix",
788 target_os = "cygwin",
789 target_os = "emscripten",
790 target_os = "fuchsia",
791 target_os = "haiku",
792 target_os = "hurd",
793 target_os = "l4re",
794 target_os = "linux",
795 target_os = "wasi",
796 )))]
797 const NO_HIDE_STALE = bitcast!(c::FALLOC_FL_NO_HIDE_STALE);
798 #[cfg(not(any(
800 bsd,
801 solarish,
802 target_os = "aix",
803 target_os = "haiku",
804 target_os = "hurd",
805 target_os = "emscripten",
806 target_os = "wasi",
807 )))]
808 const COLLAPSE_RANGE = bitcast!(c::FALLOC_FL_COLLAPSE_RANGE);
809 #[cfg(not(any(
811 bsd,
812 solarish,
813 target_os = "aix",
814 target_os = "haiku",
815 target_os = "hurd",
816 target_os = "emscripten",
817 target_os = "wasi",
818 )))]
819 const ZERO_RANGE = bitcast!(c::FALLOC_FL_ZERO_RANGE);
820 #[cfg(not(any(
822 bsd,
823 solarish,
824 target_os = "aix",
825 target_os = "haiku",
826 target_os = "hurd",
827 target_os = "emscripten",
828 target_os = "wasi",
829 )))]
830 const INSERT_RANGE = bitcast!(c::FALLOC_FL_INSERT_RANGE);
831 #[cfg(not(any(
833 bsd,
834 solarish,
835 target_os = "aix",
836 target_os = "haiku",
837 target_os = "hurd",
838 target_os = "emscripten",
839 target_os = "wasi",
840 )))]
841 const UNSHARE_RANGE = bitcast!(c::FALLOC_FL_UNSHARE_RANGE);
842
843 const _ = !0;
845 }
846}
847
848#[cfg(not(target_os = "wasi"))]
849bitflags! {
850 #[repr(transparent)]
852 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
853 pub struct StatVfsMountFlags: u64 {
854 #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))]
856 const MANDLOCK = c::ST_MANDLOCK as u64;
857
858 #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))]
860 const NOATIME = c::ST_NOATIME as u64;
861
862 #[cfg(any(
864 linux_kernel,
865 target_os = "aix",
866 target_os = "emscripten",
867 target_os = "fuchsia"
868 ))]
869 const NODEV = c::ST_NODEV as u64;
870
871 #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))]
873 const NODIRATIME = c::ST_NODIRATIME as u64;
874
875 #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))]
877 const NOEXEC = c::ST_NOEXEC as u64;
878
879 #[cfg(not(any(target_os = "espidf", target_os = "haiku", target_os = "horizon", target_os = "redox", target_os = "vita")))]
881 const NOSUID = c::ST_NOSUID as u64;
882
883 #[cfg(not(any(target_os = "espidf", target_os = "haiku", target_os = "horizon", target_os = "redox", target_os = "vita")))]
885 const RDONLY = c::ST_RDONLY as u64;
886
887 #[cfg(any(target_os = "android", all(target_os = "linux", target_env = "gnu")))]
889 const RELATIME = c::ST_RELATIME as u64;
890
891 #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))]
893 const SYNCHRONOUS = c::ST_SYNCHRONOUS as u64;
894
895 const _ = !0;
897 }
898}
899
900#[cfg(not(any(
908 target_os = "espidf",
909 target_os = "horizon",
910 target_os = "vita",
911 target_os = "wasi"
912)))]
913#[derive(Clone, Copy, Debug, PartialEq, Eq)]
914#[repr(u32)]
915pub enum FlockOperation {
916 #[cfg(not(target_os = "solaris"))]
918 LockShared = bitcast!(c::LOCK_SH),
919 #[cfg(target_os = "solaris")]
921 LockShared = bitcast!(1),
922 #[cfg(not(target_os = "solaris"))]
924 LockExclusive = bitcast!(c::LOCK_EX),
925 #[cfg(target_os = "solaris")]
927 LockExclusive = bitcast!(2),
928 #[cfg(not(target_os = "solaris"))]
930 Unlock = bitcast!(c::LOCK_UN),
931 #[cfg(target_os = "solaris")]
933 Unlock = bitcast!(8),
934 #[cfg(not(target_os = "solaris"))]
936 NonBlockingLockShared = bitcast!(c::LOCK_SH | c::LOCK_NB),
937 #[cfg(target_os = "solaris")]
939 NonBlockingLockShared = bitcast!(1 | 4),
940 #[cfg(not(target_os = "solaris"))]
942 NonBlockingLockExclusive = bitcast!(c::LOCK_EX | c::LOCK_NB),
943 #[cfg(target_os = "solaris")]
945 NonBlockingLockExclusive = bitcast!(2 | 4),
946 #[cfg(not(target_os = "solaris"))]
948 NonBlockingUnlock = bitcast!(c::LOCK_UN | c::LOCK_NB),
949 #[cfg(target_os = "solaris")]
951 NonBlockingUnlock = bitcast!(8 | 4),
952}
953
954#[cfg(not(any(linux_like, target_os = "hurd", target_os = "netbsd")))]
959pub type Stat = c::stat;
960
961#[cfg(any(
966 all(linux_kernel, target_pointer_width = "64"),
967 target_os = "hurd",
968 target_os = "emscripten",
969 target_os = "l4re",
970))]
971pub type Stat = c::stat64;
972
973#[cfg(all(linux_kernel, target_pointer_width = "32"))]
981#[derive(Debug, Copy, Clone)]
982#[allow(missing_docs)]
983pub struct Stat {
984 pub st_dev: u64,
985 pub st_mode: u32,
986 pub st_nlink: u64,
987 pub st_uid: u32,
988 pub st_gid: u32,
989 pub st_rdev: u64,
990 pub st_size: i64,
991 pub st_blksize: u32,
992 pub st_blocks: u64,
993 pub st_atime: i64,
994 pub st_atime_nsec: u32,
995 pub st_mtime: i64,
996 pub st_mtime_nsec: u32,
997 pub st_ctime: i64,
998 pub st_ctime_nsec: u32,
999 pub st_ino: u64,
1000}
1001
1002#[cfg(target_os = "netbsd")]
1009#[derive(Debug, Copy, Clone)]
1010#[allow(missing_docs)]
1011#[repr(C)]
1012pub struct Stat {
1013 pub st_dev: c::dev_t,
1014 pub st_mode: c::mode_t,
1015 pub st_ino: c::ino_t,
1016 pub st_nlink: c::nlink_t,
1017 pub st_uid: c::uid_t,
1018 pub st_gid: c::gid_t,
1019 pub st_rdev: c::dev_t,
1020 pub st_atime: c::time_t,
1021 pub st_atime_nsec: c::c_long,
1022 pub st_mtime: c::time_t,
1023 pub st_mtime_nsec: c::c_long,
1024 pub st_ctime: c::time_t,
1025 pub st_ctime_nsec: c::c_long,
1026 pub st_birthtime: c::time_t,
1027 pub st_birthtime_nsec: c::c_long,
1028 pub st_size: c::off_t,
1029 pub st_blocks: c::blkcnt_t,
1030 pub st_blksize: c::blksize_t,
1031 pub st_flags: u32,
1032 pub st_gen: u32,
1033 pub st_spare: [u32; 2],
1034}
1035
1036#[cfg(not(any(
1041 linux_like,
1042 solarish,
1043 target_os = "espidf",
1044 target_os = "haiku",
1045 target_os = "horizon",
1046 target_os = "netbsd",
1047 target_os = "nto",
1048 target_os = "redox",
1049 target_os = "vita",
1050 target_os = "wasi",
1051)))]
1052#[allow(clippy::module_name_repetitions)]
1053pub type StatFs = c::statfs;
1054
1055#[cfg(linux_like)]
1060pub type StatFs = c::statfs64;
1061
1062#[cfg(not(any(
1064 solarish,
1065 target_os = "cygwin",
1066 target_os = "espidf",
1067 target_os = "haiku",
1068 target_os = "horizon",
1069 target_os = "nto",
1070 target_os = "redox",
1071 target_os = "vita",
1072 target_os = "wasi",
1073)))]
1074pub type Fsid = c::fsid_t;
1075
1076#[cfg(not(target_os = "wasi"))]
1081#[allow(missing_docs)]
1082pub struct StatVfs {
1083 pub f_bsize: u64,
1084 pub f_frsize: u64,
1085 pub f_blocks: u64,
1086 pub f_bfree: u64,
1087 pub f_bavail: u64,
1088 pub f_files: u64,
1089 pub f_ffree: u64,
1090 pub f_favail: u64,
1091 pub f_fsid: u64,
1092 pub f_flag: StatVfsMountFlags,
1093 pub f_namemax: u64,
1094}
1095
1096#[cfg(not(all(target_os = "android", target_pointer_width = "32")))]
1098pub type RawMode = c::mode_t;
1099
1100#[cfg(all(target_os = "android", target_pointer_width = "32"))]
1102pub type RawMode = ffi::c_uint;
1103
1104#[cfg(not(all(target_os = "android", target_pointer_width = "32")))]
1106pub type Dev = c::dev_t;
1107
1108#[cfg(all(target_os = "android", target_pointer_width = "32"))]
1110pub type Dev = ffi::c_ulonglong;
1111
1112#[cfg(all(
1114 target_os = "linux",
1115 not(target_env = "musl"),
1116 not(target_arch = "s390x"),
1117))]
1118pub type FsWord = c::__fsword_t;
1119
1120#[cfg(all(
1122 any(target_os = "android", all(target_os = "linux", target_env = "musl")),
1123 target_pointer_width = "32",
1124))]
1125pub type FsWord = u32;
1126
1127#[cfg(all(
1129 any(target_os = "android", all(target_os = "linux", target_env = "musl")),
1130 not(target_arch = "s390x"),
1131 target_pointer_width = "64",
1132))]
1133pub type FsWord = u64;
1134
1135#[cfg(all(target_os = "linux", target_arch = "s390x", target_env = "gnu"))]
1139pub type FsWord = u32;
1140
1141#[cfg(all(target_os = "linux", target_arch = "s390x", target_env = "musl"))]
1144pub type FsWord = u64;
1145
1146#[cfg(apple)]
1150#[allow(non_camel_case_types)]
1151#[repr(transparent)]
1152#[derive(Copy, Clone)]
1153pub struct copyfile_state_t(pub(crate) *mut c::c_void);