1 /* $NetBSD: linux_mtio.c,v 1.6 2007/12/20 23:02:55 dsl Exp $ */
4 * Copyright (c) 2005 Soren S. Jorvang. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/cdefs.h>
29 __KERNEL_RCSID(0, "$NetBSD: linux_mtio.c,v 1.6 2007/12/20 23:02:55 dsl Exp $");
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/ioctl.h>
35 #include <sys/filedesc.h>
36 #include <sys/mount.h>
41 #include <sys/syscallargs.h>
43 #include <compat/linux/common/linux_types.h>
44 #include <compat/linux/common/linux_ioctl.h>
45 #include <compat/linux/common/linux_signal.h>
46 #include <compat/linux/common/linux_mtio.h>
47 #include <compat/linux/common/linux_ipc.h>
48 #include <compat/linux/common/linux_sem.h>
50 #include <compat/linux/linux_syscallargs.h>
52 static const struct mtop_mapping
{
56 { LINUX_MTFSF
, MTFSF
},
57 { LINUX_MTBSF
, MTBSF
},
58 { LINUX_MTFSR
, MTFSR
},
59 { LINUX_MTBSR
, MTBSR
},
60 { LINUX_MTWEOF
, MTWEOF
},
61 { LINUX_MTREW
, MTREW
},
62 { LINUX_MTOFFL
, MTOFFL
},
63 { LINUX_MTNOP
, MTNOP
},
64 { LINUX_MTRETEN
, MTRETEN
},
65 { LINUX_MTEOM
, MTEOM
},
66 { LINUX_MTERASE
, MTERASE
},
67 { LINUX_MTSETBLK
, MTSETBSIZ
},
68 { LINUX_MTSETDENSITY
, MTSETDNSTY
},
69 { LINUX_MTCOMPRESSION
, MTCMPRESS
},
74 linux_ioctl_mtio(struct lwp
*l
, const struct linux_sys_ioctl_args
*uap
,
78 u_long com
= SCARG(uap
, com
);
80 int (*ioctlf
)(file_t
*, u_long
, void *);
81 struct linux_mtop lmtop
;
82 struct linux_mtget lmtget
;
85 if ((fp
= fd_getfile(SCARG(uap
, fd
))) == NULL
)
88 ioctlf
= fp
->f_ops
->fo_ioctl
;
93 error
= copyin(SCARG(uap
, data
), &lmtop
, sizeof lmtop
);
94 for (i
= 0; mtop_map
[i
].lop
>= 0; i
++) {
95 if (mtop_map
[i
].lop
== lmtop
.mt_op
)
99 if (mtop_map
[i
].lop
== -1) {
104 mt
.mt_op
= mtop_map
[i
].op
;
105 mt
.mt_count
= lmtop
.mt_count
;
106 error
= ioctlf(fp
, MTIOCTOP
, &mt
);
109 lmtget
.mt_type
= LINUX_MT_ISUNKNOWN
;
114 lmtget
.mt_fileno
= 0;
116 error
= copyout(&lmtget
, SCARG(uap
, data
), sizeof lmtget
);
120 printf("linux_mtio unsupported ioctl 0x%lx\n", com
);
125 fd_putfile(SCARG(uap
, fd
));