Skip to content

Commit 78a3d13

Browse files
committed
Auto merge of #3396 - fsavy-tehtris:ioctl-flags, r=JohnTitor
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.
2 parents 8d6393e + e76c2be commit 78a3d13

File tree

7 files changed

+156
-0
lines changed

7 files changed

+156
-0
lines changed

libc-test/semver/android.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,14 @@ FIONCLEX
613613
FIONREAD
614614
FLUSHO
615615
FOPEN_MAX
616+
FS_IOC_GETFLAGS
617+
FS_IOC_SETFLAGS
618+
FS_IOC_GETVERSION
619+
FS_IOC_SETVERSION
620+
FS_IOC32_GETFLAGS
621+
FS_IOC32_SETFLAGS
622+
FS_IOC32_GETVERSION
623+
FS_IOC32_SETVERSION
616624
FUTEX_CLOCK_REALTIME
617625
FUTEX_CMD_MASK
618626
FUTEX_CMP_REQUEUE

libc-test/semver/linux.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,14 @@ FIONCLEX
794794
FIONREAD
795795
FLUSHO
796796
FOPEN_MAX
797+
FS_IOC_GETFLAGS
798+
FS_IOC_SETFLAGS
799+
FS_IOC_GETVERSION
800+
FS_IOC_SETVERSION
801+
FS_IOC32_GETFLAGS
802+
FS_IOC32_SETFLAGS
803+
FS_IOC32_GETVERSION
804+
FS_IOC32_SETVERSION
797805
FUTEX_BITSET_MATCH_ANY
798806
FUTEX_CLOCK_REALTIME
799807
FUTEX_CMD_MASK

src/unix/linux_like/android/mod.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,6 +1802,34 @@ pub const BLKIOOPT: ::c_int = 0x1279;
18021802
pub const BLKSSZGET: ::c_int = 0x1268;
18031803
pub const BLKPBSZGET: ::c_int = 0x127B;
18041804

1805+
cfg_if! {
1806+
// Those type are constructed using the _IOC macro
1807+
// DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN
1808+
// where D stands for direction (either None (00), Read (01) or Write (11))
1809+
// where S stands for size (int, long, struct...)
1810+
// where T stands for type ('f','v','X'...)
1811+
// where N stands for NR (NumbeR)
1812+
if #[cfg(any(target_arch = "x86", target_arch = "arm"))] {
1813+
pub const FS_IOC_GETFLAGS: ::c_int = 0x80046601;
1814+
pub const FS_IOC_SETFLAGS: ::c_int = 0x40046602;
1815+
pub const FS_IOC_GETVERSION: ::c_int = 0x80047601;
1816+
pub const FS_IOC_SETVERSION: ::c_int = 0x40047602;
1817+
pub const FS_IOC32_GETFLAGS: ::c_int = 0x80046601;
1818+
pub const FS_IOC32_SETFLAGS: ::c_int = 0x40046602;
1819+
pub const FS_IOC32_GETVERSION: ::c_int = 0x80047601;
1820+
pub const FS_IOC32_SETVERSION: ::c_int = 0x40047602;
1821+
} else if #[cfg(any(target_arch = "x86_64", target_arch = "riscv64", target_arch = "aarch64"))] {
1822+
pub const FS_IOC_GETFLAGS: ::c_int = 0x80086601;
1823+
pub const FS_IOC_SETFLAGS: ::c_int = 0x40086602;
1824+
pub const FS_IOC_GETVERSION: ::c_int = 0x80087601;
1825+
pub const FS_IOC_SETVERSION: ::c_int = 0x40087602;
1826+
pub const FS_IOC32_GETFLAGS: ::c_int = 0x80046601;
1827+
pub const FS_IOC32_SETFLAGS: ::c_int = 0x40046602;
1828+
pub const FS_IOC32_GETVERSION: ::c_int = 0x80047601;
1829+
pub const FS_IOC32_SETVERSION: ::c_int = 0x40047602;
1830+
}
1831+
}
1832+
18051833
pub const EAI_AGAIN: ::c_int = 2;
18061834
pub const EAI_BADFLAGS: ::c_int = 3;
18071835
pub const EAI_FAIL: ::c_int = 4;

src/unix/linux_like/linux/arch/generic/mod.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,34 @@ pub const BLKIOOPT: ::Ioctl = 0x1279;
211211
pub const BLKSSZGET: ::Ioctl = 0x1268;
212212
pub const BLKPBSZGET: ::Ioctl = 0x127B;
213213

214+
cfg_if! {
215+
// Those type are constructed using the _IOC macro
216+
// DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN
217+
// where D stands for direction (either None (00), Read (01) or Write (11))
218+
// where S stands for size (int, long, struct...)
219+
// where T stands for type ('f','v','X'...)
220+
// where N stands for NR (NumbeR)
221+
if #[cfg(any(target_arch = "x86", target_arch = "arm"))] {
222+
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x80046601;
223+
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x40046602;
224+
pub const FS_IOC_GETVERSION: ::Ioctl = 0x80047601;
225+
pub const FS_IOC_SETVERSION: ::Ioctl = 0x40047602;
226+
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x80046601;
227+
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x40046602;
228+
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x80047601;
229+
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x40047602;
230+
} else if #[cfg(any(target_arch = "x86_64", target_arch = "riscv64", target_arch = "aarch64", target_arch = "s390x"))] {
231+
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x80086601;
232+
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x40086602;
233+
pub const FS_IOC_GETVERSION: ::Ioctl = 0x80087601;
234+
pub const FS_IOC_SETVERSION: ::Ioctl = 0x40087602;
235+
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x80046601;
236+
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x40046602;
237+
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x80047601;
238+
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x40047602;
239+
}
240+
}
241+
214242
cfg_if! {
215243
if #[cfg(any(target_arch = "arm",
216244
target_arch = "s390x"))] {

src/unix/linux_like/linux/arch/mips/mod.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,34 @@ pub const BLKIOOPT: ::Ioctl = 0x20001279;
193193
pub const BLKSSZGET: ::Ioctl = 0x20001268;
194194
pub const BLKPBSZGET: ::Ioctl = 0x2000127B;
195195

196+
cfg_if! {
197+
// Those type are constructed using the _IOC macro
198+
// DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN
199+
// where D stands for direction (either None (00), Read (01) or Write (11))
200+
// where S stands for size (int, long, struct...)
201+
// where T stands for type ('f','v','X'...)
202+
// where N stands for NR (NumbeR)
203+
if #[cfg(target_arch = "mips")] {
204+
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40046601;
205+
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80046602;
206+
pub const FS_IOC_GETVERSION: ::Ioctl = 0x40047601;
207+
pub const FS_IOC_SETVERSION: ::Ioctl = 0x80047602;
208+
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x40046601;
209+
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
210+
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
211+
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
212+
} else if #[cfg(target_arch = "mips64")] {
213+
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40086601;
214+
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80086602;
215+
pub const FS_IOC_GETVERSION: ::Ioctl = 0x40087601;
216+
pub const FS_IOC_SETVERSION: ::Ioctl = 0x80087602;
217+
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x40046601;
218+
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
219+
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
220+
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
221+
}
222+
}
223+
196224
cfg_if! {
197225
if #[cfg(target_env = "musl")] {
198226
pub const TIOCGRS485: ::Ioctl = 0x4020542e;

src/unix/linux_like/linux/arch/powerpc/mod.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,34 @@ pub const BLKSSZGET: ::Ioctl = 0x20001268;
179179
pub const BLKPBSZGET: ::Ioctl = 0x2000127B;
180180
//pub const FIOQSIZE: ::Ioctl = 0x40086680;
181181

182+
cfg_if! {
183+
// Those type are constructed using the _IOC macro
184+
// DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN
185+
// where D stands for direction (either None (00), Read (01) or Write (11))
186+
// where S stands for size (int, long, struct...)
187+
// where T stands for type ('f','v','X'...)
188+
// where N stands for NR (NumbeR)
189+
if #[cfg(target_arch = "powerpc")] {
190+
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40046601;
191+
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80046602;
192+
pub const FS_IOC_GETVERSION: ::Ioctl = 0x40047601;
193+
pub const FS_IOC_SETVERSION: ::Ioctl = 0x80047602;
194+
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x40046601;
195+
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
196+
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
197+
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
198+
} else if #[cfg(target_arch = "powerpc64")] {
199+
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40086601;
200+
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80086602;
201+
pub const FS_IOC_GETVERSION: ::Ioctl = 0x40087601;
202+
pub const FS_IOC_SETVERSION: ::Ioctl = 0x80087602;
203+
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x40046601;
204+
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
205+
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
206+
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
207+
}
208+
}
209+
182210
pub const TIOCM_LE: ::c_int = 0x001;
183211
pub const TIOCM_DTR: ::c_int = 0x002;
184212
pub const TIOCM_RTS: ::c_int = 0x004;

src/unix/linux_like/linux/arch/sparc/mod.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,31 @@ cfg_if! {
229229
pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff;
230230
}
231231
}
232+
233+
cfg_if! {
234+
// Those type are constructed using the _IOC macro
235+
// DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN
236+
// where D stands for direction (either None (00), Read (01) or Write (11))
237+
// where S stands for size (int, long, struct...)
238+
// where T stands for type ('f','v','X'...)
239+
// where N stands for NR (NumbeR)
240+
if #[cfg(target_arch = "sparc")] {
241+
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40046601;
242+
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80046602;
243+
pub const FS_IOC_GETVERSION: ::Ioctl = 0x40047601;
244+
pub const FS_IOC_SETVERSION: ::Ioctl = 0x80047602;
245+
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x40046601;
246+
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
247+
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
248+
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
249+
} else if #[cfg(target_arch = "sparc64")] {
250+
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40086601;
251+
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80086602;
252+
pub const FS_IOC_GETVERSION: ::Ioctl = 0x40087601;
253+
pub const FS_IOC_SETVERSION: ::Ioctl = 0x80087602;
254+
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x40046601;
255+
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
256+
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
257+
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
258+
}
259+
}

0 commit comments

Comments
 (0)