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

TOMOYO Linux Cross Reference
Linux/include/linux/mtio.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef _LINUX_MTIO_COMPAT_H
  3 #define _LINUX_MTIO_COMPAT_H
  4 
  5 #include <linux/compat.h>
  6 #include <uapi/linux/mtio.h>
  7 #include <linux/uaccess.h>
  8 
  9 /*
 10  * helper functions for implementing compat ioctls on the four tape
 11  * drivers: we define the 32-bit layout of each incompatible structure,
 12  * plus a wrapper function to copy it to user space in either format.
 13  */
 14 
 15 struct  mtget32 {
 16         s32     mt_type;
 17         s32     mt_resid;
 18         s32     mt_dsreg;
 19         s32     mt_gstat;
 20         s32     mt_erreg;
 21         s32     mt_fileno;
 22         s32     mt_blkno;
 23 };
 24 #define MTIOCGET32      _IOR('m', 2, struct mtget32)
 25 
 26 struct  mtpos32 {
 27         s32     mt_blkno;
 28 };
 29 #define MTIOCPOS32      _IOR('m', 3, struct mtpos32)
 30 
 31 static inline int put_user_mtget(void __user *u, struct mtget *k)
 32 {
 33         struct mtget32 k32 = {
 34                 .mt_type   = k->mt_type,
 35                 .mt_resid  = k->mt_resid,
 36                 .mt_dsreg  = k->mt_dsreg,
 37                 .mt_gstat  = k->mt_gstat,
 38                 .mt_erreg  = k->mt_erreg,
 39                 .mt_fileno = k->mt_fileno,
 40                 .mt_blkno  = k->mt_blkno,
 41         };
 42         int ret;
 43 
 44         if (in_compat_syscall())
 45                 ret = copy_to_user(u, &k32, sizeof(k32));
 46         else
 47                 ret = copy_to_user(u, k, sizeof(*k));
 48 
 49         return ret ? -EFAULT : 0;
 50 }
 51 
 52 static inline int put_user_mtpos(void __user *u, struct mtpos *k)
 53 {
 54         if (in_compat_syscall())
 55                 return put_user(k->mt_blkno, (u32 __user *)u);
 56         else
 57                 return put_user(k->mt_blkno, (long __user *)u);
 58 }
 59 
 60 #endif
 61 

~ [ 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