1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_MTIO_COMPAT_H
3 #define _LINUX_MTIO_COMPAT_H
5 #include <linux/compat.h>
6 #include <uapi/linux/mtio.h>
7 #include <linux/uaccess.h>
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.
24 #define MTIOCGET32 _IOR('m', 2, struct mtget32)
29 #define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
31 static inline int put_user_mtget(void __user
*u
, struct mtget
*k
)
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
,
44 if (in_compat_syscall())
45 ret
= copy_to_user(u
, &k32
, sizeof(k32
));
47 ret
= copy_to_user(u
, k
, sizeof(*k
));
49 return ret
? -EFAULT
: 0;
52 static inline int put_user_mtpos(void __user
*u
, struct mtpos
*k
)
54 if (in_compat_syscall())
55 return put_user(k
->mt_blkno
, (u32 __user
*)u
);
57 return put_user(k
->mt_blkno
, (long __user
*)u
);