1use crate::backend::c;
2#[cfg(not(target_os = "horizon"))]
3use crate::ffi;
4use bitflags::bitflags;
5
6#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
7bitflags! {
8 #[repr(transparent)]
12 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
13 pub struct Access: ffi::c_int {
14 const READ_OK = c::R_OK;
16
17 const WRITE_OK = c::W_OK;
19
20 const EXEC_OK = c::X_OK;
22
23 const EXISTS = c::F_OK;
25
26 const _ = !0;
28 }
29}
30
31#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "redox")))]
32bitflags! {
33 #[repr(transparent)]
39 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
40 pub struct AtFlags: u32 {
41 const SYMLINK_NOFOLLOW = bitcast!(c::AT_SYMLINK_NOFOLLOW);
43
44 #[cfg(not(target_os = "android"))]
46 const EACCESS = bitcast!(c::AT_EACCESS);
47
48 const REMOVEDIR = bitcast!(c::AT_REMOVEDIR);
50
51 const SYMLINK_FOLLOW = bitcast!(c::AT_SYMLINK_FOLLOW);
53
54 #[cfg(any(linux_like, target_os = "fuchsia"))]
56 const NO_AUTOMOUNT = bitcast!(c::AT_NO_AUTOMOUNT);
57
58 #[cfg(any(
60 linux_kernel,
61 target_os = "freebsd",
62 target_os = "fuchsia",
63 ))]
64 const EMPTY_PATH = bitcast!(c::AT_EMPTY_PATH);
65
66 #[cfg(target_os = "freebsd")]
68 const RESOLVE_BENEATH = bitcast!(c::AT_RESOLVE_BENEATH);
69
70 #[cfg(all(target_os = "linux", target_env = "gnu"))]
72 const STATX_SYNC_AS_STAT = bitcast!(c::AT_STATX_SYNC_AS_STAT);
73
74 #[cfg(all(target_os = "linux", target_env = "gnu"))]
76 const STATX_FORCE_SYNC = bitcast!(c::AT_STATX_FORCE_SYNC);
77
78 #[cfg(all(target_os = "linux", target_env = "gnu"))]
80 const STATX_DONT_SYNC = bitcast!(c::AT_STATX_DONT_SYNC);
81
82 const _ = !0;
84 }
85}
86
87#[cfg(target_os = "horizon")]
88bitflags! {
89 #[repr(transparent)]
95 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
96 pub struct AtFlags: u32 {
97 const _ = !0;
99 }
100}
101
102#[cfg(not(target_os = "horizon"))]
103bitflags! {
104 #[repr(transparent)]
110 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
111 pub struct Mode: RawMode {
112 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
114 const RWXU = c::S_IRWXU as RawMode;
115
116 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
118 const RUSR = c::S_IRUSR as RawMode;
119
120 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
122 const WUSR = c::S_IWUSR as RawMode;
123
124 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
126 const XUSR = c::S_IXUSR as RawMode;
127
128 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
130 const RWXG = c::S_IRWXG as RawMode;
131
132 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
134 const RGRP = c::S_IRGRP as RawMode;
135
136 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
138 const WGRP = c::S_IWGRP as RawMode;
139
140 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
142 const XGRP = c::S_IXGRP as RawMode;
143
144 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
146 const RWXO = c::S_IRWXO as RawMode;
147
148 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
150 const ROTH = c::S_IROTH as RawMode;
151
152 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
154 const WOTH = c::S_IWOTH as RawMode;
155
156 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
158 const XOTH = c::S_IXOTH as RawMode;
159
160 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
162 const SUID = c::S_ISUID as RawMode;
163
164 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
166 const SGID = c::S_ISGID as RawMode;
167
168 #[cfg(not(any(target_os = "espidf", target_os = "vita")))]
170 const SVTX = c::S_ISVTX as RawMode;
171
172 const _ = !0;
174 }
175}
176
177#[cfg(target_os = "horizon")]
178bitflags! {
179 #[repr(transparent)]
185 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
186 pub struct Mode: RawMode {
187 const _ = !0;
189 }
190}
191
192#[cfg(not(target_os = "espidf"))]
193impl Mode {
194 #[inline]
197 pub const fn from_raw_mode(st_mode: RawMode) -> Self {
198 Self::from_bits_truncate(st_mode & !c::S_IFMT as RawMode)
199 }
200
201 #[inline]
203 pub const fn as_raw_mode(self) -> RawMode {
204 self.bits()
205 }
206}
207
208#[cfg(not(target_os = "espidf"))]
209impl From<RawMode> for Mode {
210 #[inline]
217 fn from(st_mode: RawMode) -> Self {
218 Self::from_raw_mode(st_mode)
219 }
220}
221
222#[cfg(not(target_os = "espidf"))]
223impl From<Mode> for RawMode {
224 #[inline]
231 fn from(mode: Mode) -> Self {
232 mode.as_raw_mode()
233 }
234}
235
236bitflags! {
237 #[repr(transparent)]
241 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
242 pub struct OFlags: u32 {
243 const ACCMODE = bitcast!(c::O_ACCMODE);
245
246 const RWMODE = bitcast!(c::O_RDONLY | c::O_WRONLY | c::O_RDWR);
254
255 const APPEND = bitcast!(c::O_APPEND);
257
258 #[doc(alias = "CREAT")]
260 const CREATE = bitcast!(c::O_CREAT);
261
262 #[cfg(not(any(target_os = "espidf", target_os = "horizon")))]
264 const DIRECTORY = bitcast!(c::O_DIRECTORY);
265
266 #[cfg(not(any(target_os = "dragonfly", target_os = "espidf", target_os = "horizon", target_os = "l4re", target_os = "redox", target_os = "vita")))]
268 const DSYNC = bitcast!(c::O_DSYNC);
269
270 const EXCL = bitcast!(c::O_EXCL);
272
273 #[cfg(any(
275 bsd,
276 all(target_os = "linux", not(target_env = "musl")),
277 ))]
278 const FSYNC = bitcast!(c::O_FSYNC);
279
280 #[cfg(not(any(target_os = "espidf", target_os = "horizon")))]
282 const NOFOLLOW = bitcast!(c::O_NOFOLLOW);
283
284 const NONBLOCK = bitcast!(c::O_NONBLOCK);
286
287 const RDONLY = bitcast!(c::O_RDONLY);
289
290 const WRONLY = bitcast!(c::O_WRONLY);
292
293 const RDWR = bitcast!(c::O_RDWR);
297
298 #[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "l4re", target_os = "redox", target_os = "vita")))]
300 const NOCTTY = bitcast!(c::O_NOCTTY);
301
302 #[cfg(any(
304 linux_kernel,
305 netbsdlike,
306 solarish,
307 target_os = "emscripten",
308 target_os = "wasi",
309 ))]
310 const RSYNC = bitcast!(c::O_RSYNC);
311
312 #[cfg(not(any(target_os = "l4re", target_os = "redox")))]
314 const SYNC = bitcast!(c::O_SYNC);
315
316 const TRUNC = bitcast!(c::O_TRUNC);
318
319 #[cfg(any(
321 linux_kernel,
322 target_os = "emscripten",
323 target_os = "freebsd",
324 target_os = "fuchsia",
325 target_os = "redox",
326 ))]
327 const PATH = bitcast!(c::O_PATH);
328
329 const CLOEXEC = bitcast!(c::O_CLOEXEC);
331
332 #[cfg(any(
334 linux_kernel,
335 target_os = "emscripten",
336 target_os = "fuchsia",
337 ))]
338 const TMPFILE = bitcast!(c::O_TMPFILE);
339
340 #[cfg(any(
342 linux_kernel,
343 target_os = "fuchsia",
344 ))]
345 const NOATIME = bitcast!(c::O_NOATIME);
346
347 #[cfg(any(
349 linux_kernel,
350 target_os = "emscripten",
351 target_os = "freebsd",
352 target_os = "fuchsia",
353 target_os = "netbsd",
354 ))]
355 const DIRECT = bitcast!(c::O_DIRECT);
356
357 #[cfg(target_os = "freebsd")]
359 const RESOLVE_BENEATH = bitcast!(c::O_RESOLVE_BENEATH);
360
361 #[cfg(target_os = "freebsd")]
363 const EMPTY_PATH = bitcast!(c::O_EMPTY_PATH);
364
365 #[cfg(any(apple, target_os = "redox"))]
367 const SYMLINK = bitcast!(c::O_SYMLINK);
368
369 #[cfg(apple)]
371 const NOFOLLOW_ANY = bitcast!(c::O_NOFOLLOW_ANY);
372
373 #[cfg(any(linux_kernel, solarish))]
380 const LARGEFILE = bitcast!(c::O_LARGEFILE);
381
382 #[cfg(not(any(
387 target_os = "aix",
388 target_os = "cygwin",
389 target_os = "espidf",
390 target_os = "haiku",
391 target_os = "horizon",
392 target_os = "wasi",
393 target_os = "vita",
394 solarish
395 )))]
396 const ASYNC = bitcast!(c::O_ASYNC);
397
398 const _ = !0;
400 }
401}
402
403#[cfg(apple)]
404bitflags! {
405 #[repr(transparent)]
409 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
410 pub struct CloneFlags: u32 {
411 const NOFOLLOW = 1;
413
414 const NOOWNERCOPY = 2;
416
417 const _ = !0;
419 }
420}
421
422#[cfg(apple)]
423mod copyfile {
424 pub(super) const ACL: u32 = 1 << 0;
425 pub(super) const STAT: u32 = 1 << 1;
426 pub(super) const XATTR: u32 = 1 << 2;
427 pub(super) const DATA: u32 = 1 << 3;
428 pub(super) const SECURITY: u32 = STAT | ACL;
429 pub(super) const METADATA: u32 = SECURITY | XATTR;
430 pub(super) const ALL: u32 = METADATA | DATA;
431}
432
433#[cfg(apple)]
434bitflags! {
435 #[repr(transparent)]
439 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
440 pub struct CopyfileFlags: ffi::c_uint {
441 const ACL = copyfile::ACL;
443
444 const STAT = copyfile::STAT;
446
447 const XATTR = copyfile::XATTR;
449
450 const DATA = copyfile::DATA;
452
453 const SECURITY = copyfile::SECURITY;
455
456 const METADATA = copyfile::METADATA;
458
459 const ALL = copyfile::ALL;
461
462 const _ = !0;
464 }
465}
466
467#[cfg(linux_kernel)]
468bitflags! {
469 #[repr(transparent)]
473 #[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)]
474 pub struct ResolveFlags: u64 {
475 const NO_XDEV = 0x01;
477
478 const NO_MAGICLINKS = 0x02;
480
481 const NO_SYMLINKS = 0x04;
483
484 const BENEATH = 0x08;
486
487 const IN_ROOT = 0x10;
489
490 const CACHED = 0x20;
492
493 const _ = !0;
495 }
496}
497
498#[cfg(linux_kernel)]
499bitflags! {
500 #[repr(transparent)]
504 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
505 pub struct RenameFlags: ffi::c_uint {
506 const EXCHANGE = bitcast!(c::RENAME_EXCHANGE);
508
509 const NOREPLACE = bitcast!(c::RENAME_NOREPLACE);
511
512 const WHITEOUT = bitcast!(c::RENAME_WHITEOUT);
514
515 const _ = !0;
517 }
518}
519
520#[cfg(target_os = "redox")]
521bitflags! {
522 #[repr(transparent)]
526 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
527 pub struct RenameFlags: ffi::c_uint {
528 const NOREPLACE = bitcast!(c::RENAME_NOREPLACE);
530
531 const _ = !0;
533 }
534}
535
536#[cfg(apple)]
537bitflags! {
538 #[repr(transparent)]
542 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
543 pub struct RenameFlags: ffi::c_uint {
544 const EXCHANGE = bitcast!(c::RENAME_SWAP);
546
547 const NOREPLACE = bitcast!(c::RENAME_EXCL);
549
550 const _ = !0;
552 }
553}
554
555#[derive(Clone, Copy, Debug, PartialEq, Eq)]
560pub enum FileType {
561 RegularFile = c::S_IFREG as isize,
563
564 Directory = c::S_IFDIR as isize,
566
567 Symlink = c::S_IFLNK as isize,
569
570 #[cfg(not(target_os = "wasi"))] #[doc(alias = "IFO")]
573 Fifo = c::S_IFIFO as isize,
574
575 #[cfg(not(target_os = "wasi"))] Socket = c::S_IFSOCK as isize,
578
579 CharacterDevice = c::S_IFCHR as isize,
581
582 BlockDevice = c::S_IFBLK as isize,
584
585 Unknown,
587}
588
589impl FileType {
590 #[inline]
593 pub const fn from_raw_mode(st_mode: RawMode) -> Self {
594 match (st_mode as c::mode_t) & c::S_IFMT {
595 c::S_IFREG => Self::RegularFile,
596 c::S_IFDIR => Self::Directory,
597 c::S_IFLNK => Self::Symlink,
598 #[cfg(not(target_os = "wasi"))] c::S_IFIFO => Self::Fifo,
600 #[cfg(not(target_os = "wasi"))] c::S_IFSOCK => Self::Socket,
602 c::S_IFCHR => Self::CharacterDevice,
603 c::S_IFBLK => Self::BlockDevice,
604 _ => Self::Unknown,
605 }
606 }
607
608 #[inline]
610 pub const fn as_raw_mode(self) -> RawMode {
611 match self {
612 Self::RegularFile => c::S_IFREG as RawMode,
613 Self::Directory => c::S_IFDIR as RawMode,
614 Self::Symlink => c::S_IFLNK as RawMode,
615 #[cfg(not(target_os = "wasi"))] Self::Fifo => c::S_IFIFO as RawMode,
617 #[cfg(not(target_os = "wasi"))] Self::Socket => c::S_IFSOCK as RawMode,
619 Self::CharacterDevice => c::S_IFCHR as RawMode,
620 Self::BlockDevice => c::S_IFBLK as RawMode,
621 Self::Unknown => c::S_IFMT as RawMode,
622 }
623 }
624
625 #[cfg(not(any(
627 solarish,
628 target_os = "aix",
629 target_os = "espidf",
630 target_os = "haiku",
631 target_os = "horizon",
632 target_os = "nto",
633 target_os = "redox",
634 target_os = "vita"
635 )))]
636 #[inline]
637 pub(crate) const fn from_dirent_d_type(d_type: u8) -> Self {
638 match d_type {
639 c::DT_REG => Self::RegularFile,
640 c::DT_DIR => Self::Directory,
641 c::DT_LNK => Self::Symlink,
642 #[cfg(not(target_os = "wasi"))] c::DT_SOCK => Self::Socket,
644 #[cfg(not(target_os = "wasi"))] c::DT_FIFO => Self::Fifo,
646 c::DT_CHR => Self::CharacterDevice,
647 c::DT_BLK => Self::BlockDevice,
648 _ => Self::Unknown,
650 }
651 }
652}
653
654#[cfg(not(any(
658 apple,
659 netbsdlike,
660 target_os = "dragonfly",
661 target_os = "espidf",
662 target_os = "horizon",
663 target_os = "haiku",
664 target_os = "redox",
665 target_os = "solaris",
666 target_os = "vita",
667)))]
668#[derive(Debug, Copy, Clone, Eq, PartialEq)]
669#[repr(u32)]
670pub enum Advice {
671 Normal = c::POSIX_FADV_NORMAL as c::c_uint,
673
674 Sequential = c::POSIX_FADV_SEQUENTIAL as c::c_uint,
676
677 Random = c::POSIX_FADV_RANDOM as c::c_uint,
679
680 NoReuse = c::POSIX_FADV_NOREUSE as c::c_uint,
682
683 WillNeed = c::POSIX_FADV_WILLNEED as c::c_uint,
685
686 DontNeed = c::POSIX_FADV_DONTNEED as c::c_uint,
688}
689
690#[cfg(any(linux_kernel, target_os = "freebsd"))]
691bitflags! {
692 #[repr(transparent)]
696 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
697 pub struct MemfdFlags: ffi::c_uint {
698 const CLOEXEC = c::MFD_CLOEXEC;
700
701 const ALLOW_SEALING = c::MFD_ALLOW_SEALING;
703
704 const HUGETLB = c::MFD_HUGETLB;
706
707 #[cfg(linux_kernel)]
709 const NOEXEC_SEAL = c::MFD_NOEXEC_SEAL;
710 #[cfg(linux_kernel)]
712 const EXEC = c::MFD_EXEC;
713
714 const HUGE_64KB = c::MFD_HUGE_64KB;
716 const HUGE_512KB = c::MFD_HUGE_512KB;
718 const HUGE_1MB = c::MFD_HUGE_1MB;
720 const HUGE_2MB = c::MFD_HUGE_2MB;
722 const HUGE_8MB = c::MFD_HUGE_8MB;
724 const HUGE_16MB = c::MFD_HUGE_16MB;
726 const HUGE_32MB = c::MFD_HUGE_32MB;
728 const HUGE_256MB = c::MFD_HUGE_256MB;
730 const HUGE_512MB = c::MFD_HUGE_512MB;
732 const HUGE_1GB = c::MFD_HUGE_1GB;
734 const HUGE_2GB = c::MFD_HUGE_2GB;
736 const HUGE_16GB = c::MFD_HUGE_16GB;
738
739 const _ = !0;
741 }
742}
743
744#[cfg(any(linux_kernel, target_os = "freebsd", target_os = "fuchsia"))]
745bitflags! {
746 #[repr(transparent)]
752 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
753 pub struct SealFlags: u32 {
754 const SEAL = bitcast!(c::F_SEAL_SEAL);
756 const SHRINK = bitcast!(c::F_SEAL_SHRINK);
758 const GROW = bitcast!(c::F_SEAL_GROW);
760 const WRITE = bitcast!(c::F_SEAL_WRITE);
762 #[cfg(linux_kernel)]
764 const FUTURE_WRITE = bitcast!(c::F_SEAL_FUTURE_WRITE);
765 #[cfg(linux_kernel)]
767 const EXEC = bitcast!(c::F_SEAL_EXEC);
768
769 const _ = !0;
771 }
772}
773
774#[cfg(not(any(
775 netbsdlike,
776 target_os = "espidf",
777 target_os = "horizon",
778 target_os = "nto",
779 target_os = "redox",
780 target_os = "vita"
781)))]
782bitflags! {
783 #[repr(transparent)]
787 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
788 pub struct FallocateFlags: u32 {
789 #[cfg(not(any(
791 bsd,
792 solarish,
793 target_os = "aix",
794 target_os = "haiku",
795 target_os = "hurd",
796 target_os = "wasi",
797 )))]
798 const KEEP_SIZE = bitcast!(c::FALLOC_FL_KEEP_SIZE);
799 #[cfg(not(any(
801 bsd,
802 solarish,
803 target_os = "aix",
804 target_os = "haiku",
805 target_os = "hurd",
806 target_os = "wasi",
807 )))]
808 const PUNCH_HOLE = bitcast!(c::FALLOC_FL_PUNCH_HOLE);
809 #[cfg(not(any(
811 bsd,
812 solarish,
813 target_os = "aix",
814 target_os = "cygwin",
815 target_os = "emscripten",
816 target_os = "fuchsia",
817 target_os = "haiku",
818 target_os = "hurd",
819 target_os = "l4re",
820 target_os = "linux",
821 target_os = "wasi",
822 )))]
823 const NO_HIDE_STALE = bitcast!(c::FALLOC_FL_NO_HIDE_STALE);
824 #[cfg(not(any(
826 bsd,
827 solarish,
828 target_os = "aix",
829 target_os = "haiku",
830 target_os = "hurd",
831 target_os = "emscripten",
832 target_os = "wasi",
833 )))]
834 const COLLAPSE_RANGE = bitcast!(c::FALLOC_FL_COLLAPSE_RANGE);
835 #[cfg(not(any(
837 bsd,
838 solarish,
839 target_os = "aix",
840 target_os = "haiku",
841 target_os = "hurd",
842 target_os = "emscripten",
843 target_os = "wasi",
844 )))]
845 const ZERO_RANGE = bitcast!(c::FALLOC_FL_ZERO_RANGE);
846 #[cfg(not(any(
848 bsd,
849 solarish,
850 target_os = "aix",
851 target_os = "haiku",
852 target_os = "hurd",
853 target_os = "emscripten",
854 target_os = "wasi",
855 )))]
856 const INSERT_RANGE = bitcast!(c::FALLOC_FL_INSERT_RANGE);
857 #[cfg(not(any(
859 bsd,
860 solarish,
861 target_os = "aix",
862 target_os = "haiku",
863 target_os = "hurd",
864 target_os = "emscripten",
865 target_os = "wasi",
866 )))]
867 const UNSHARE_RANGE = bitcast!(c::FALLOC_FL_UNSHARE_RANGE);
868
869 const _ = !0;
871 }
872}
873
874#[cfg(not(target_os = "wasi"))]
875bitflags! {
876 #[repr(transparent)]
878 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
879 pub struct StatVfsMountFlags: u64 {
880 #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))]
882 const MANDLOCK = c::ST_MANDLOCK as u64;
883
884 #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))]
886 const NOATIME = c::ST_NOATIME as u64;
887
888 #[cfg(any(
890 linux_kernel,
891 target_os = "aix",
892 target_os = "emscripten",
893 target_os = "fuchsia"
894 ))]
895 const NODEV = c::ST_NODEV as u64;
896
897 #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))]
899 const NODIRATIME = c::ST_NODIRATIME as u64;
900
901 #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))]
903 const NOEXEC = c::ST_NOEXEC as u64;
904
905 #[cfg(not(any(target_os = "espidf", target_os = "haiku", target_os = "horizon", target_os = "redox", target_os = "vita")))]
907 const NOSUID = c::ST_NOSUID as u64;
908
909 #[cfg(not(any(target_os = "espidf", target_os = "haiku", target_os = "horizon", target_os = "redox", target_os = "vita")))]
911 const RDONLY = c::ST_RDONLY as u64;
912
913 #[cfg(any(target_os = "android", all(target_os = "linux", target_env = "gnu")))]
915 const RELATIME = c::ST_RELATIME as u64;
916
917 #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))]
919 const SYNCHRONOUS = c::ST_SYNCHRONOUS as u64;
920
921 const _ = !0;
923 }
924}
925
926#[cfg(not(any(
934 target_os = "espidf",
935 target_os = "horizon",
936 target_os = "vita",
937 target_os = "wasi"
938)))]
939#[derive(Clone, Copy, Debug, PartialEq, Eq)]
940#[repr(u32)]
941pub enum FlockOperation {
942 #[cfg(not(target_os = "solaris"))]
944 LockShared = bitcast!(c::LOCK_SH),
945 #[cfg(target_os = "solaris")]
947 LockShared = bitcast!(1),
948 #[cfg(not(target_os = "solaris"))]
950 LockExclusive = bitcast!(c::LOCK_EX),
951 #[cfg(target_os = "solaris")]
953 LockExclusive = bitcast!(2),
954 #[cfg(not(target_os = "solaris"))]
956 Unlock = bitcast!(c::LOCK_UN),
957 #[cfg(target_os = "solaris")]
959 Unlock = bitcast!(8),
960 #[cfg(not(target_os = "solaris"))]
962 NonBlockingLockShared = bitcast!(c::LOCK_SH | c::LOCK_NB),
963 #[cfg(target_os = "solaris")]
965 NonBlockingLockShared = bitcast!(1 | 4),
966 #[cfg(not(target_os = "solaris"))]
968 NonBlockingLockExclusive = bitcast!(c::LOCK_EX | c::LOCK_NB),
969 #[cfg(target_os = "solaris")]
971 NonBlockingLockExclusive = bitcast!(2 | 4),
972 #[cfg(not(target_os = "solaris"))]
974 NonBlockingUnlock = bitcast!(c::LOCK_UN | c::LOCK_NB),
975 #[cfg(target_os = "solaris")]
977 NonBlockingUnlock = bitcast!(8 | 4),
978}
979
980#[cfg(not(any(linux_like, target_os = "hurd", target_os = "netbsd")))]
985pub type Stat = c::stat;
986
987#[cfg(any(
992 all(linux_kernel, target_pointer_width = "64"),
993 target_os = "hurd",
994 target_os = "emscripten",
995 target_os = "l4re",
996))]
997pub type Stat = c::stat64;
998
999#[cfg(all(linux_kernel, target_pointer_width = "32"))]
1007#[derive(Debug, Copy, Clone)]
1008#[allow(missing_docs)]
1009pub struct Stat {
1010 pub st_dev: u64,
1011 pub st_mode: u32,
1012 pub st_nlink: u64,
1013 pub st_uid: u32,
1014 pub st_gid: u32,
1015 pub st_rdev: u64,
1016 pub st_size: i64,
1017 pub st_blksize: u32,
1018 pub st_blocks: u64,
1019 pub st_atime: i64,
1020 pub st_atime_nsec: u32,
1021 pub st_mtime: i64,
1022 pub st_mtime_nsec: u32,
1023 pub st_ctime: i64,
1024 pub st_ctime_nsec: u32,
1025 pub st_ino: u64,
1026}
1027
1028#[cfg(target_os = "netbsd")]
1035#[derive(Debug, Copy, Clone)]
1036#[allow(missing_docs)]
1037#[repr(C)]
1038pub struct Stat {
1039 pub st_dev: c::dev_t,
1040 pub st_mode: c::mode_t,
1041 pub st_ino: c::ino_t,
1042 pub st_nlink: c::nlink_t,
1043 pub st_uid: c::uid_t,
1044 pub st_gid: c::gid_t,
1045 pub st_rdev: c::dev_t,
1046 pub st_atime: c::time_t,
1047 pub st_atime_nsec: c::c_long,
1048 pub st_mtime: c::time_t,
1049 pub st_mtime_nsec: c::c_long,
1050 pub st_ctime: c::time_t,
1051 pub st_ctime_nsec: c::c_long,
1052 pub st_birthtime: c::time_t,
1053 pub st_birthtime_nsec: c::c_long,
1054 pub st_size: c::off_t,
1055 pub st_blocks: c::blkcnt_t,
1056 pub st_blksize: c::blksize_t,
1057 pub st_flags: u32,
1058 pub st_gen: u32,
1059 pub st_spare: [u32; 2],
1060}
1061
1062#[cfg(not(any(
1067 linux_like,
1068 solarish,
1069 target_os = "espidf",
1070 target_os = "haiku",
1071 target_os = "horizon",
1072 target_os = "netbsd",
1073 target_os = "nto",
1074 target_os = "redox",
1075 target_os = "vita",
1076 target_os = "wasi",
1077)))]
1078#[allow(clippy::module_name_repetitions)]
1079pub type StatFs = c::statfs;
1080
1081#[cfg(linux_like)]
1086pub type StatFs = c::statfs64;
1087
1088#[cfg(not(any(
1090 solarish,
1091 target_os = "cygwin",
1092 target_os = "espidf",
1093 target_os = "haiku",
1094 target_os = "horizon",
1095 target_os = "nto",
1096 target_os = "redox",
1097 target_os = "vita",
1098 target_os = "wasi",
1099)))]
1100pub type Fsid = c::fsid_t;
1101
1102#[cfg(not(target_os = "wasi"))]
1107#[allow(missing_docs)]
1108pub struct StatVfs {
1109 pub f_bsize: u64,
1110 pub f_frsize: u64,
1111 pub f_blocks: u64,
1112 pub f_bfree: u64,
1113 pub f_bavail: u64,
1114 pub f_files: u64,
1115 pub f_ffree: u64,
1116 pub f_favail: u64,
1117 pub f_fsid: u64,
1118 pub f_flag: StatVfsMountFlags,
1119 pub f_namemax: u64,
1120}
1121
1122#[cfg(not(all(target_os = "android", target_pointer_width = "32")))]
1124pub type RawMode = c::mode_t;
1125
1126#[cfg(all(target_os = "android", target_pointer_width = "32"))]
1128pub type RawMode = ffi::c_uint;
1129
1130#[cfg(not(all(target_os = "android", target_pointer_width = "32")))]
1132pub type Dev = c::dev_t;
1133
1134#[cfg(all(target_os = "android", target_pointer_width = "32"))]
1136pub type Dev = ffi::c_ulonglong;
1137
1138#[cfg(all(
1140 target_os = "linux",
1141 not(target_env = "musl"),
1142 not(target_arch = "s390x"),
1143))]
1144pub type FsWord = c::__fsword_t;
1145
1146#[cfg(all(
1148 any(target_os = "android", all(target_os = "linux", target_env = "musl")),
1149 target_pointer_width = "32",
1150))]
1151pub type FsWord = u32;
1152
1153#[cfg(all(
1155 any(target_os = "android", all(target_os = "linux", target_env = "musl")),
1156 not(target_arch = "s390x"),
1157 target_pointer_width = "64",
1158))]
1159pub type FsWord = u64;
1160
1161#[cfg(all(target_os = "linux", target_arch = "s390x", target_env = "gnu"))]
1165pub type FsWord = u32;
1166
1167#[cfg(all(target_os = "linux", target_arch = "s390x", target_env = "musl"))]
1170pub type FsWord = u64;
1171
1172#[cfg(apple)]
1176#[allow(non_camel_case_types)]
1177#[repr(transparent)]
1178#[derive(Copy, Clone)]
1179pub struct copyfile_state_t(pub(crate) *mut c::c_void);