Skip to content

Commit ecfff18

Browse files
committed
Auto merge of #3089 - ETKNeil:add-ioctl-flags, r=JohnTitor
Add ioctl FS_IOC_{G,S}ETVERSION and FS_IOC_{G,S}ETFLAGS This PR focus on adding support for the constants behind the call of ioctl(FS_IOC_G/SETFLAGS) and ioctl(FS_IOC_G/SETVERSION) Ressources: Linux: https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/fs.h#L220 Android: https://cs.android.com/android/platform/superproject/+/master:prebuilts/vndk/v31/arm/include/bionic/libc/kernel/uapi/linux/fs.h;l=155?q=FS_APPEND_FL&ss=android%2Fplatform%2Fsuperproject Android (bis): https://cs.android.com/android/platform/superproject/+/master:bionic/libc/kernel/uapi/linux/fs.h;l=161;drc=4794e479f4b485be2680e83993e3cf93f0f42d03?q=FS_APPEND_FL&sq=&ss=android%2Fplatform%2Fsuperproject Note: Thoses calls are a bit of a mess historically, however the constants did not change since
2 parents a1ad825 + 011c1e1 commit ecfff18

File tree

6 files changed

+128
-0
lines changed

6 files changed

+128
-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
@@ -1800,6 +1800,34 @@ pub const BLKIOOPT: ::c_int = 0x1279;
18001800
pub const BLKSSZGET: ::c_int = 0x1268;
18011801
pub const BLKPBSZGET: ::c_int = 0x127B;
18021802

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

0 commit comments

Comments
 (0)