Skip to content

Commit 65dd811

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 78301e2 + 011c1e1 commit 65dd811

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
@@ -612,6 +612,14 @@ FIONCLEX
612612
FIONREAD
613613
FLUSHO
614614
FOPEN_MAX
615+
FS_IOC_GETFLAGS
616+
FS_IOC_SETFLAGS
617+
FS_IOC_GETVERSION
618+
FS_IOC_SETVERSION
619+
FS_IOC32_GETFLAGS
620+
FS_IOC32_SETFLAGS
621+
FS_IOC32_GETVERSION
622+
FS_IOC32_SETVERSION
615623
FUTEX_CLOCK_REALTIME
616624
FUTEX_CMD_MASK
617625
FUTEX_CMP_REQUEUE

libc-test/semver/linux.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,14 @@ FIONCLEX
755755
FIONREAD
756756
FLUSHO
757757
FOPEN_MAX
758+
FS_IOC_GETFLAGS
759+
FS_IOC_SETFLAGS
760+
FS_IOC_GETVERSION
761+
FS_IOC_SETVERSION
762+
FS_IOC32_GETFLAGS
763+
FS_IOC32_SETFLAGS
764+
FS_IOC32_GETVERSION
765+
FS_IOC32_SETVERSION
758766
FUTEX_BITSET_MATCH_ANY
759767
FUTEX_CLOCK_REALTIME
760768
FUTEX_CMD_MASK

src/unix/linux_like/android/mod.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,34 @@ pub const BLKIOOPT: ::c_int = 0x1279;
17991799
pub const BLKSSZGET: ::c_int = 0x1268;
18001800
pub const BLKPBSZGET: ::c_int = 0x127B;
18011801

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