Skip to content

Commit aed89a5

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 4983ced + 011c1e1 commit aed89a5

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
@@ -610,6 +610,14 @@ FIONCLEX
610610
FIONREAD
611611
FLUSHO
612612
FOPEN_MAX
613+
FS_IOC_GETFLAGS
614+
FS_IOC_SETFLAGS
615+
FS_IOC_GETVERSION
616+
FS_IOC_SETVERSION
617+
FS_IOC32_GETFLAGS
618+
FS_IOC32_SETFLAGS
619+
FS_IOC32_GETVERSION
620+
FS_IOC32_SETVERSION
613621
FUTEX_CLOCK_REALTIME
614622
FUTEX_CMD_MASK
615623
FUTEX_CMP_REQUEUE

libc-test/semver/linux.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,14 @@ FIONCLEX
741741
FIONREAD
742742
FLUSHO
743743
FOPEN_MAX
744+
FS_IOC_GETFLAGS
745+
FS_IOC_SETFLAGS
746+
FS_IOC_GETVERSION
747+
FS_IOC_SETVERSION
748+
FS_IOC32_GETFLAGS
749+
FS_IOC32_SETFLAGS
750+
FS_IOC32_GETVERSION
751+
FS_IOC32_SETVERSION
744752
FUTEX_BITSET_MATCH_ANY
745753
FUTEX_CLOCK_REALTIME
746754
FUTEX_CMD_MASK

src/unix/linux_like/android/mod.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,6 +1775,34 @@ pub const BLKIOOPT: ::c_int = 0x1279;
17751775
pub const BLKSSZGET: ::c_int = 0x1268;
17761776
pub const BLKPBSZGET: ::c_int = 0x127B;
17771777

1778+
cfg_if! {
1779+
// Those type are constructed using the _IOC macro
1780+
// DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN
1781+
// where D stands for direction (either None (00), Read (01) or Write (11))
1782+
// where S stands for size (int, long, struct...)
1783+
// where T stands for type ('f','v','X'...)
1784+
// where N stands for NR (NumbeR)
1785+
if #[cfg(target_arch = "x86")] {
1786+
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x80046601;
1787+
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x40046602;
1788+
pub const FS_IOC_GETVERSION: ::Ioctl = 0x80047601;
1789+
pub const FS_IOC_SETVERSION: ::Ioctl = 0x40047602;
1790+
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x80046601;
1791+
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x40046602;
1792+
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x80047601;
1793+
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x40047602;
1794+
} else if #[cfg(any(target_arch = "x86_64", target_arch = "riscv64", target_arch = "aarch64"))] {
1795+
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x80086601;
1796+
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x40086602;
1797+
pub const FS_IOC_GETVERSION: ::Ioctl = 0x80087601;
1798+
pub const FS_IOC_SETVERSION: ::Ioctl = 0x40087602;
1799+
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x80046601;
1800+
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x40046602;
1801+
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x80047601;
1802+
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x40047602;
1803+
}
1804+
}
1805+
17781806
pub const EAI_AGAIN: ::c_int = 2;
17791807
pub const EAI_BADFLAGS: ::c_int = 3;
17801808
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
@@ -213,6 +213,34 @@ pub const BLKIOOPT: ::Ioctl = 0x1279;
213213
pub const BLKSSZGET: ::Ioctl = 0x1268;
214214
pub const BLKPBSZGET: ::Ioctl = 0x127B;
215215

216+
cfg_if! {
217+
// Those type are constructed using the _IOC macro
218+
// DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN
219+
// where D stands for direction (either None (00), Read (01) or Write (11))
220+
// where S stands for size (int, long, struct...)
221+
// where T stands for type ('f','v','X'...)
222+
// where N stands for NR (NumbeR)
223+
if #[cfg(target_arch = "x86")] {
224+
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x80046601;
225+
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x40046602;
226+
pub const FS_IOC_GETVERSION: ::Ioctl = 0x80047601;
227+
pub const FS_IOC_SETVERSION: ::Ioctl = 0x40047602;
228+
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x80046601;
229+
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x40046602;
230+
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x80047601;
231+
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x40047602;
232+
} else if #[cfg(target_arch = "x86_64")] {
233+
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x80086601;
234+
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x40086602;
235+
pub const FS_IOC_GETVERSION: ::Ioctl = 0x80087601;
236+
pub const FS_IOC_SETVERSION: ::Ioctl = 0x40087602;
237+
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x80046601;
238+
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x40046602;
239+
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x80047601;
240+
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x40047602;
241+
}
242+
}
243+
216244
cfg_if! {
217245
if #[cfg(any(target_arch = "arm",
218246
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
@@ -190,6 +190,34 @@ pub const BLKIOOPT: ::Ioctl = 0x20001279;
190190
pub const BLKSSZGET: ::Ioctl = 0x20001268;
191191
pub const BLKPBSZGET: ::Ioctl = 0x2000127B;
192192

193+
cfg_if! {
194+
// Those type are constructed using the _IOC macro
195+
// DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN
196+
// where D stands for direction (either None (00), Read (01) or Write (11))
197+
// where S stands for size (int, long, struct...)
198+
// where T stands for type ('f','v','X'...)
199+
// where N stands for NR (NumbeR)
200+
if #[cfg(target_arch = "mips")] {
201+
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40046601;
202+
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80046602;
203+
pub const FS_IOC_GETVERSION: ::Ioctl = 0x40047601;
204+
pub const FS_IOC_SETVERSION: ::Ioctl = 0x80047602;
205+
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x40046601;
206+
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
207+
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
208+
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
209+
} else if #[cfg(target_arch = "mips64")] {
210+
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40086601;
211+
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80086602;
212+
pub const FS_IOC_GETVERSION: ::Ioctl = 0x40087601;
213+
pub const FS_IOC_SETVERSION: ::Ioctl = 0x80087602;
214+
pub const FS_IOC32_GETFLAGS: ::Ioctl = 0x40046601;
215+
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
216+
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
217+
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
218+
}
219+
}
220+
193221
cfg_if! {
194222
if #[cfg(target_env = "musl")] {
195223
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
@@ -176,6 +176,34 @@ pub const BLKSSZGET: ::Ioctl = 0x20001268;
176176
pub const BLKPBSZGET: ::Ioctl = 0x2000127B;
177177
//pub const FIOQSIZE: ::Ioctl = 0x40086680;
178178

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

0 commit comments

Comments
 (0)