~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/rust/kernel/ioctl.rs

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /rust/kernel/ioctl.rs (Version linux-6.12-rc7) and /rust/kernel/ioctl.rs (Version linux-6.4.16)


  1 // SPDX-License-Identifier: GPL-2.0                 1 // SPDX-License-Identifier: GPL-2.0
  2                                                     2 
  3 //! `ioctl()` number definitions.              !!   3 //! ioctl() number definitions
  4 //!                                                 4 //!
  5 //! C header: [`include/asm-generic/ioctl.h`]( !!   5 //! C header: [`include/asm-generic/ioctl.h`](../../../../include/asm-generic/ioctl.h)
  6                                                     6 
  7 #![allow(non_snake_case)]                           7 #![allow(non_snake_case)]
  8                                                     8 
  9 use crate::build_assert;                            9 use crate::build_assert;
 10                                                    10 
 11 /// Build an ioctl number, analogous to the C      11 /// Build an ioctl number, analogous to the C macro of the same name.
 12 #[inline(always)]                                  12 #[inline(always)]
 13 const fn _IOC(dir: u32, ty: u32, nr: u32, size     13 const fn _IOC(dir: u32, ty: u32, nr: u32, size: usize) -> u32 {
 14     build_assert!(dir <= uapi::_IOC_DIRMASK);      14     build_assert!(dir <= uapi::_IOC_DIRMASK);
 15     build_assert!(ty <= uapi::_IOC_TYPEMASK);      15     build_assert!(ty <= uapi::_IOC_TYPEMASK);
 16     build_assert!(nr <= uapi::_IOC_NRMASK);        16     build_assert!(nr <= uapi::_IOC_NRMASK);
 17     build_assert!(size <= (uapi::_IOC_SIZEMASK     17     build_assert!(size <= (uapi::_IOC_SIZEMASK as usize));
 18                                                    18 
 19     (dir << uapi::_IOC_DIRSHIFT)                   19     (dir << uapi::_IOC_DIRSHIFT)
 20         | (ty << uapi::_IOC_TYPESHIFT)             20         | (ty << uapi::_IOC_TYPESHIFT)
 21         | (nr << uapi::_IOC_NRSHIFT)               21         | (nr << uapi::_IOC_NRSHIFT)
 22         | ((size as u32) << uapi::_IOC_SIZESHI     22         | ((size as u32) << uapi::_IOC_SIZESHIFT)
 23 }                                                  23 }
 24                                                    24 
 25 /// Build an ioctl number for an argumentless      25 /// Build an ioctl number for an argumentless ioctl.
 26 #[inline(always)]                                  26 #[inline(always)]
 27 pub const fn _IO(ty: u32, nr: u32) -> u32 {        27 pub const fn _IO(ty: u32, nr: u32) -> u32 {
 28     _IOC(uapi::_IOC_NONE, ty, nr, 0)               28     _IOC(uapi::_IOC_NONE, ty, nr, 0)
 29 }                                                  29 }
 30                                                    30 
 31 /// Build an ioctl number for a read-only ioct !!  31 /// Build an ioctl number for an read-only ioctl.
 32 #[inline(always)]                                  32 #[inline(always)]
 33 pub const fn _IOR<T>(ty: u32, nr: u32) -> u32      33 pub const fn _IOR<T>(ty: u32, nr: u32) -> u32 {
 34     _IOC(uapi::_IOC_READ, ty, nr, core::mem::s     34     _IOC(uapi::_IOC_READ, ty, nr, core::mem::size_of::<T>())
 35 }                                                  35 }
 36                                                    36 
 37 /// Build an ioctl number for a write-only ioc !!  37 /// Build an ioctl number for an write-only ioctl.
 38 #[inline(always)]                                  38 #[inline(always)]
 39 pub const fn _IOW<T>(ty: u32, nr: u32) -> u32      39 pub const fn _IOW<T>(ty: u32, nr: u32) -> u32 {
 40     _IOC(uapi::_IOC_WRITE, ty, nr, core::mem::     40     _IOC(uapi::_IOC_WRITE, ty, nr, core::mem::size_of::<T>())
 41 }                                                  41 }
 42                                                    42 
 43 /// Build an ioctl number for a read-write ioc     43 /// Build an ioctl number for a read-write ioctl.
 44 #[inline(always)]                                  44 #[inline(always)]
 45 pub const fn _IOWR<T>(ty: u32, nr: u32) -> u32     45 pub const fn _IOWR<T>(ty: u32, nr: u32) -> u32 {
 46     _IOC(                                          46     _IOC(
 47         uapi::_IOC_READ | uapi::_IOC_WRITE,        47         uapi::_IOC_READ | uapi::_IOC_WRITE,
 48         ty,                                        48         ty,
 49         nr,                                        49         nr,
 50         core::mem::size_of::<T>(),                 50         core::mem::size_of::<T>(),
 51     )                                              51     )
 52 }                                                  52 }
 53                                                    53 
 54 /// Get the ioctl direction from an ioctl numb     54 /// Get the ioctl direction from an ioctl number.
 55 pub const fn _IOC_DIR(nr: u32) -> u32 {            55 pub const fn _IOC_DIR(nr: u32) -> u32 {
 56     (nr >> uapi::_IOC_DIRSHIFT) & uapi::_IOC_D     56     (nr >> uapi::_IOC_DIRSHIFT) & uapi::_IOC_DIRMASK
 57 }                                                  57 }
 58                                                    58 
 59 /// Get the ioctl type from an ioctl number.       59 /// Get the ioctl type from an ioctl number.
 60 pub const fn _IOC_TYPE(nr: u32) -> u32 {           60 pub const fn _IOC_TYPE(nr: u32) -> u32 {
 61     (nr >> uapi::_IOC_TYPESHIFT) & uapi::_IOC_     61     (nr >> uapi::_IOC_TYPESHIFT) & uapi::_IOC_TYPEMASK
 62 }                                                  62 }
 63                                                    63 
 64 /// Get the ioctl number from an ioctl number.     64 /// Get the ioctl number from an ioctl number.
 65 pub const fn _IOC_NR(nr: u32) -> u32 {             65 pub const fn _IOC_NR(nr: u32) -> u32 {
 66     (nr >> uapi::_IOC_NRSHIFT) & uapi::_IOC_NR     66     (nr >> uapi::_IOC_NRSHIFT) & uapi::_IOC_NRMASK
 67 }                                                  67 }
 68                                                    68 
 69 /// Get the ioctl size from an ioctl number.       69 /// Get the ioctl size from an ioctl number.
 70 pub const fn _IOC_SIZE(nr: u32) -> usize {         70 pub const fn _IOC_SIZE(nr: u32) -> usize {
 71     ((nr >> uapi::_IOC_SIZESHIFT) & uapi::_IOC     71     ((nr >> uapi::_IOC_SIZESHIFT) & uapi::_IOC_SIZEMASK) as usize
 72 }                                                  72 }
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php