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
740 const _ = !0;
742 }
743}
744
745#[cfg(not(any(
746 netbsdlike,
747 target_os = "espidf",
748 target_os = "horizon",
749 target_os = "nto",
750 target_os = "redox",
751 target_os = "vita"
752)))]
753bitflags! {
754 #[repr(transparent)]
758 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
759 pub struct FallocateFlags: u32 {
760 #[cfg(not(any(
762 bsd,
763 solarish,
764 target_os = "aix",
765 target_os = "haiku",
766 target_os = "hurd",
767 target_os = "wasi",
768 )))]
769 const KEEP_SIZE = bitcast!(c::FALLOC_FL_KEEP_SIZE);
770 #[cfg(not(any(
772 bsd,
773 solarish,
774 target_os = "aix",
775 target_os = "haiku",
776 target_os = "hurd",
777 target_os = "wasi",
778 )))]
779 const PUNCH_HOLE = bitcast!(c::FALLOC_FL_PUNCH_HOLE);
780 #[cfg(not(any(
782 bsd,
783 solarish,
784 target_os = "aix",
785 target_os = "cygwin",
786 target_os = "emscripten",
787 target_os = "fuchsia",
788 target_os = "haiku",
789 target_os = "hurd",
790 target_os = "l4re",
791 target_os = "linux",
792 target_os = "wasi",
793 )))]
794 const NO_HIDE_STALE = bitcast!(c::FALLOC_FL_NO_HIDE_STALE);
795 #[cfg(not(any(
797 bsd,
798 solarish,
799 target_os = "aix",
800 target_os = "haiku",
801 target_os = "hurd",
802 target_os = "emscripten",
803 target_os = "wasi",
804 )))]
805 const COLLAPSE_RANGE = bitcast!(c::FALLOC_FL_COLLAPSE_RANGE);
806 #[cfg(not(any(
808 bsd,
809 solarish,
810 target_os = "aix",
811 target_os = "haiku",
812 target_os = "hurd",
813 target_os = "emscripten",
814 target_os = "wasi",
815 )))]
816 const ZERO_RANGE = bitcast!(c::FALLOC_FL_ZERO_RANGE);
817 #[cfg(not(any(
819 bsd,
820 solarish,
821 target_os = "aix",
822 target_os = "haiku",
823 target_os = "hurd",
824 target_os = "emscripten",
825 target_os = "wasi",
826 )))]
827 const INSERT_RANGE = bitcast!(c::FALLOC_FL_INSERT_RANGE);
828 #[cfg(not(any(
830 bsd,
831 solarish,
832 target_os = "aix",
833 target_os = "haiku",
834 target_os = "hurd",
835 target_os = "emscripten",
836 target_os = "wasi",
837 )))]
838 const UNSHARE_RANGE = bitcast!(c::FALLOC_FL_UNSHARE_RANGE);
839
840 const _ = !0;
842 }
843}
844
845#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))]
846bitflags! {
847 #[repr(transparent)]
849 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
850 pub struct StatVfsMountFlags: u64 {
851 #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))]
853 const MANDLOCK = c::ST_MANDLOCK as u64;
854
855 #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))]
857 const NOATIME = c::ST_NOATIME as u64;
858
859 #[cfg(any(
861 linux_kernel,
862 target_os = "aix",
863 target_os = "emscripten",
864 target_os = "fuchsia"
865 ))]
866 const NODEV = c::ST_NODEV as u64;
867
868 #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))]
870 const NODIRATIME = c::ST_NODIRATIME as u64;
871
872 #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))]
874 const NOEXEC = c::ST_NOEXEC as u64;
875
876 #[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
878 const NOSUID = c::ST_NOSUID as u64;
879
880 #[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
882 const RDONLY = c::ST_RDONLY as u64;
883
884 #[cfg(any(target_os = "android", all(target_os = "linux", target_env = "gnu")))]
886 const RELATIME = c::ST_RELATIME as u64;
887
888 #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))]
890 const SYNCHRONOUS = c::ST_SYNCHRONOUS as u64;
891
892 const _ = !0;
894 }
895}
896
897#[cfg(not(any(
905 target_os = "espidf",
906 target_os = "horizon",
907 target_os = "vita",
908 target_os = "wasi"
909)))]
910#[derive(Clone, Copy, Debug, PartialEq, Eq)]
911#[repr(u32)]
912pub enum FlockOperation {
913 #[cfg(not(target_os = "solaris"))]
915 LockShared = bitcast!(c::LOCK_SH),
916 #[cfg(target_os = "solaris")]
918 LockShared = bitcast!(1),
919 #[cfg(not(target_os = "solaris"))]
921 LockExclusive = bitcast!(c::LOCK_EX),
922 #[cfg(target_os = "solaris")]
924 LockExclusive = bitcast!(2),
925 #[cfg(not(target_os = "solaris"))]
927 Unlock = bitcast!(c::LOCK_UN),
928 #[cfg(target_os = "solaris")]
930 Unlock = bitcast!(8),
931 #[cfg(not(target_os = "solaris"))]
933 NonBlockingLockShared = bitcast!(c::LOCK_SH | c::LOCK_NB),
934 #[cfg(target_os = "solaris")]
936 NonBlockingLockShared = bitcast!(1 | 4),
937 #[cfg(not(target_os = "solaris"))]
939 NonBlockingLockExclusive = bitcast!(c::LOCK_EX | c::LOCK_NB),
940 #[cfg(target_os = "solaris")]
942 NonBlockingLockExclusive = bitcast!(2 | 4),
943 #[cfg(not(target_os = "solaris"))]
945 NonBlockingUnlock = bitcast!(c::LOCK_UN | c::LOCK_NB),
946 #[cfg(target_os = "solaris")]
948 NonBlockingUnlock = bitcast!(8 | 4),
949}
950
951#[cfg(not(any(linux_like, target_os = "hurd", target_os = "netbsd")))]
956pub type Stat = c::stat;
957
958#[cfg(any(
963 all(linux_kernel, target_pointer_width = "64"),
964 target_os = "hurd",
965 target_os = "emscripten",
966 target_os = "l4re",
967))]
968pub type Stat = c::stat64;
969
970#[cfg(all(linux_kernel, target_pointer_width = "32"))]
978#[derive(Debug, Copy, Clone)]
979#[allow(missing_docs)]
980pub struct Stat {
981 pub st_dev: u64,
982 pub st_mode: u32,
983 pub st_nlink: u64,
984 pub st_uid: u32,
985 pub st_gid: u32,
986 pub st_rdev: u64,
987 pub st_size: i64,
988 pub st_blksize: u32,
989 pub st_blocks: u64,
990 pub st_atime: i64,
991 pub st_atime_nsec: u32,
992 pub st_mtime: i64,
993 pub st_mtime_nsec: u32,
994 pub st_ctime: i64,
995 pub st_ctime_nsec: u32,
996 pub st_ino: u64,
997}
998
999#[cfg(target_os = "netbsd")]
1006#[derive(Debug, Copy, Clone)]
1007#[allow(missing_docs)]
1008#[repr(C)]
1009pub struct Stat {
1010 pub st_dev: c::dev_t,
1011 pub st_mode: c::mode_t,
1012 pub st_ino: c::ino_t,
1013 pub st_nlink: c::nlink_t,
1014 pub st_uid: c::uid_t,
1015 pub st_gid: c::gid_t,
1016 pub st_rdev: c::dev_t,
1017 pub st_atime: c::time_t,
1018 pub st_atime_nsec: c::c_long,
1019 pub st_mtime: c::time_t,
1020 pub st_mtime_nsec: c::c_long,
1021 pub st_ctime: c::time_t,
1022 pub st_ctime_nsec: c::c_long,
1023 pub st_birthtime: c::time_t,
1024 pub st_birthtime_nsec: c::c_long,
1025 pub st_size: c::off_t,
1026 pub st_blocks: c::blkcnt_t,
1027 pub st_blksize: c::blksize_t,
1028 pub st_flags: u32,
1029 pub st_gen: u32,
1030 pub st_spare: [u32; 2],
1031}
1032
1033#[cfg(not(any(
1038 linux_like,
1039 solarish,
1040 target_os = "espidf",
1041 target_os = "haiku",
1042 target_os = "horizon",
1043 target_os = "netbsd",
1044 target_os = "nto",
1045 target_os = "redox",
1046 target_os = "vita",
1047 target_os = "wasi",
1048)))]
1049#[allow(clippy::module_name_repetitions)]
1050pub type StatFs = c::statfs;
1051
1052#[cfg(linux_like)]
1057pub type StatFs = c::statfs64;
1058
1059#[cfg(not(any(
1061 solarish,
1062 target_os = "cygwin",
1063 target_os = "espidf",
1064 target_os = "haiku",
1065 target_os = "horizon",
1066 target_os = "nto",
1067 target_os = "redox",
1068 target_os = "vita",
1069 target_os = "wasi",
1070)))]
1071pub type Fsid = c::fsid_t;
1072
1073#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))]
1078#[allow(missing_docs)]
1079pub struct StatVfs {
1080 pub f_bsize: u64,
1081 pub f_frsize: u64,
1082 pub f_blocks: u64,
1083 pub f_bfree: u64,
1084 pub f_bavail: u64,
1085 pub f_files: u64,
1086 pub f_ffree: u64,
1087 pub f_favail: u64,
1088 pub f_fsid: u64,
1089 pub f_flag: StatVfsMountFlags,
1090 pub f_namemax: u64,
1091}
1092
1093#[cfg(not(all(target_os = "android", target_pointer_width = "32")))]
1095pub type RawMode = c::mode_t;
1096
1097#[cfg(all(target_os = "android", target_pointer_width = "32"))]
1099pub type RawMode = ffi::c_uint;
1100
1101#[cfg(not(all(target_os = "android", target_pointer_width = "32")))]
1103pub type Dev = c::dev_t;
1104
1105#[cfg(all(target_os = "android", target_pointer_width = "32"))]
1107pub type Dev = ffi::c_ulonglong;
1108
1109#[cfg(all(
1111 target_os = "linux",
1112 not(target_env = "musl"),
1113 not(target_arch = "s390x"),
1114))]
1115pub type FsWord = c::__fsword_t;
1116
1117#[cfg(all(
1119 any(target_os = "android", all(target_os = "linux", target_env = "musl")),
1120 target_pointer_width = "32",
1121))]
1122pub type FsWord = u32;
1123
1124#[cfg(all(
1126 any(target_os = "android", all(target_os = "linux", target_env = "musl")),
1127 not(target_arch = "s390x"),
1128 target_pointer_width = "64",
1129))]
1130pub type FsWord = u64;
1131
1132#[cfg(all(target_os = "linux", target_arch = "s390x", target_env = "gnu"))]
1136pub type FsWord = u32;
1137
1138#[cfg(all(target_os = "linux", target_arch = "s390x", target_env = "musl"))]
1141pub type FsWord = u64;
1142
1143#[cfg(apple)]
1147#[allow(non_camel_case_types)]
1148#[repr(transparent)]
1149#[derive(Copy, Clone)]
1150pub struct copyfile_state_t(pub(crate) *mut c::c_void);