Skip to content

Commit

Permalink
Auto merge of #3396 - fsavy-tehtris:ioctl-flags, r=JohnTitor
Browse files Browse the repository at this point in the history
Add ioctl FS_IOC_* version and flag constants

This is a tentative to fix #3089 because the original author is unlikely to revisit it.

I've added the missing architectures for the constants on Linux, I think they should all be covered now.
  • Loading branch information
bors committed Nov 14, 2023
2 parents 8d6393e + e76c2be commit 78a3d13
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libc-test/semver/android.txt
Expand Up @@ -613,6 +613,14 @@ FIONCLEX
FIONREAD
FLUSHO
FOPEN_MAX
FS_IOC_GETFLAGS
FS_IOC_SETFLAGS
FS_IOC_GETVERSION
FS_IOC_SETVERSION
FS_IOC32_GETFLAGS
FS_IOC32_SETFLAGS
FS_IOC32_GETVERSION
FS_IOC32_SETVERSION
FUTEX_CLOCK_REALTIME
FUTEX_CMD_MASK
FUTEX_CMP_REQUEUE
Expand Down
8 changes: 8 additions & 0 deletions libc-test/semver/linux.txt
Expand Up @@ -794,6 +794,14 @@ FIONCLEX
FIONREAD
FLUSHO
FOPEN_MAX
FS_IOC_GETFLAGS
FS_IOC_SETFLAGS
FS_IOC_GETVERSION
FS_IOC_SETVERSION
FS_IOC32_GETFLAGS
FS_IOC32_SETFLAGS
FS_IOC32_GETVERSION
FS_IOC32_SETVERSION
FUTEX_BITSET_MATCH_ANY
FUTEX_CLOCK_REALTIME
FUTEX_CMD_MASK
Expand Down
28 changes: 28 additions & 0 deletions src/unix/linux_like/android/mod.rs
Expand Up @@ -1802,6 +1802,34 @@ pub const BLKIOOPT: ::c_int = 0x1279;
pub const BLKSSZGET: ::c_int = 0x1268;
pub const BLKPBSZGET: ::c_int = 0x127B;

cfg_if! {
// Those type are constructed using the _IOC macro
// DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN
// where D stands for direction (either None (00), Read (01) or Write (11))
// where S stands for size (int, long, struct...)
// where T stands for type ('f','v','X'...)
// where N stands for NR (NumbeR)
if #[cfg(any(target_arch = "x86", target_arch = "arm"))] {
pub const FS_IOC_GETFLAGS: ::c_int = 0x80046601;
pub const FS_IOC_SETFLAGS: ::c_int = 0x40046602;
pub const FS_IOC_GETVERSION: ::c_int = 0x80047601;
pub const FS_IOC_SETVERSION: ::c_int = 0x40047602;
pub const FS_IOC32_GETFLAGS: ::c_int = 0x80046601;
pub const FS_IOC32_SETFLAGS: ::c_int = 0x40046602;
pub const FS_IOC32_GETVERSION: ::c_int = 0x80047601;
pub const FS_IOC32_SETVERSION: ::c_int = 0x40047602;
} else if #[cfg(any(target_arch = "x86_64", target_arch = "riscv64", target_arch = "aarch64"))] {
pub const FS_IOC_GETFLAGS: ::c_int = 0x80086601;
pub const FS_IOC_SETFLAGS: ::c_int = 0x40086602;
pub const FS_IOC_GETVERSION: ::c_int = 0x80087601;
pub const FS_IOC_SETVERSION: ::c_int = 0x40087602;
pub const FS_IOC32_GETFLAGS: ::c_int = 0x80046601;
pub const FS_IOC32_SETFLAGS: ::c_int = 0x40046602;
pub const FS_IOC32_GETVERSION: ::c_int = 0x80047601;
pub const FS_IOC32_SETVERSION: ::c_int = 0x40047602;
}
}

pub const EAI_AGAIN: ::c_int = 2;
pub const EAI_BADFLAGS: ::c_int = 3;
pub const EAI_FAIL: ::c_int = 4;
Expand Down
28 changes: 28 additions & 0 deletions src/unix/linux_like/linux/arch/generic/mod.rs
Expand Up @@ -211,6 +211,34 @@ pub const BLKIOOPT: ::Ioctl = 0x1279;
pub const BLKSSZGET: ::Ioctl = 0x1268;
pub const BLKPBSZGET: ::Ioctl = 0x127B;

cfg_if! {
// Those type are constructed using the _IOC macro
// DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN
// where D stands for direction (either None (00), Read (01) or Write (11))
// where S stands for size (int, long, struct...)
// where T stands for type ('f','v','X'...)
// where N stands for NR (NumbeR)
if #[cfg(any(target_arch = "x86", target_arch = "arm"))] {
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x80046601;
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x40046602;
pub const FS_IOC_GETVERSION: ::Ioctl = 0x80047601;
pub const FS_IOC_SETVERSION: ::Ioctl = 0x40047602;
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x80046601;
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x40046602;
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x80047601;
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x40047602;
} else if #[cfg(any(target_arch = "x86_64", target_arch = "riscv64", target_arch = "aarch64", target_arch = "s390x"))] {
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x80086601;
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x40086602;
pub const FS_IOC_GETVERSION: ::Ioctl = 0x80087601;
pub const FS_IOC_SETVERSION: ::Ioctl = 0x40087602;
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x80046601;
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x40046602;
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x80047601;
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x40047602;
}
}

cfg_if! {
if #[cfg(any(target_arch = "arm",
target_arch = "s390x"))] {
Expand Down
28 changes: 28 additions & 0 deletions src/unix/linux_like/linux/arch/mips/mod.rs
Expand Up @@ -193,6 +193,34 @@ pub const BLKIOOPT: ::Ioctl = 0x20001279;
pub const BLKSSZGET: ::Ioctl = 0x20001268;
pub const BLKPBSZGET: ::Ioctl = 0x2000127B;

cfg_if! {
// Those type are constructed using the _IOC macro
// DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN
// where D stands for direction (either None (00), Read (01) or Write (11))
// where S stands for size (int, long, struct...)
// where T stands for type ('f','v','X'...)
// where N stands for NR (NumbeR)
if #[cfg(target_arch = "mips")] {
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40046601;
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80046602;
pub const FS_IOC_GETVERSION: ::Ioctl = 0x40047601;
pub const FS_IOC_SETVERSION: ::Ioctl = 0x80047602;
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x40046601;
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
} else if #[cfg(target_arch = "mips64")] {
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40086601;
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80086602;
pub const FS_IOC_GETVERSION: ::Ioctl = 0x40087601;
pub const FS_IOC_SETVERSION: ::Ioctl = 0x80087602;
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x40046601;
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
}
}

cfg_if! {
if #[cfg(target_env = "musl")] {
pub const TIOCGRS485: ::Ioctl = 0x4020542e;
Expand Down
28 changes: 28 additions & 0 deletions src/unix/linux_like/linux/arch/powerpc/mod.rs
Expand Up @@ -179,6 +179,34 @@ pub const BLKSSZGET: ::Ioctl = 0x20001268;
pub const BLKPBSZGET: ::Ioctl = 0x2000127B;
//pub const FIOQSIZE: ::Ioctl = 0x40086680;

cfg_if! {
// Those type are constructed using the _IOC macro
// DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN
// where D stands for direction (either None (00), Read (01) or Write (11))
// where S stands for size (int, long, struct...)
// where T stands for type ('f','v','X'...)
// where N stands for NR (NumbeR)
if #[cfg(target_arch = "powerpc")] {
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40046601;
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80046602;
pub const FS_IOC_GETVERSION: ::Ioctl = 0x40047601;
pub const FS_IOC_SETVERSION: ::Ioctl = 0x80047602;
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x40046601;
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
} else if #[cfg(target_arch = "powerpc64")] {
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40086601;
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80086602;
pub const FS_IOC_GETVERSION: ::Ioctl = 0x40087601;
pub const FS_IOC_SETVERSION: ::Ioctl = 0x80087602;
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x40046601;
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
}
}

pub const TIOCM_LE: ::c_int = 0x001;
pub const TIOCM_DTR: ::c_int = 0x002;
pub const TIOCM_RTS: ::c_int = 0x004;
Expand Down
28 changes: 28 additions & 0 deletions src/unix/linux_like/linux/arch/sparc/mod.rs
Expand Up @@ -229,3 +229,31 @@ cfg_if! {
pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff;
}
}

cfg_if! {
// Those type are constructed using the _IOC macro
// DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN
// where D stands for direction (either None (00), Read (01) or Write (11))
// where S stands for size (int, long, struct...)
// where T stands for type ('f','v','X'...)
// where N stands for NR (NumbeR)
if #[cfg(target_arch = "sparc")] {
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40046601;
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80046602;
pub const FS_IOC_GETVERSION: ::Ioctl = 0x40047601;
pub const FS_IOC_SETVERSION: ::Ioctl = 0x80047602;
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x40046601;
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
} else if #[cfg(target_arch = "sparc64")] {
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40086601;
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80086602;
pub const FS_IOC_GETVERSION: ::Ioctl = 0x40087601;
pub const FS_IOC_SETVERSION: ::Ioctl = 0x80087602;
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x40046601;
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
}
}

0 comments on commit 78a3d13

Please sign in to comment.