Emulate basic mtio ioctls.
This commit is contained in:
parent
4f02ad16c6
commit
18d6a3043f
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux_ioctl.c,v 1.41 2005/02/26 23:10:19 perry Exp $ */
|
||||
/* $NetBSD: linux_ioctl.c,v 1.42 2005/02/28 22:11:32 soren Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_ioctl.c,v 1.41 2005/02/26 23:10:19 perry Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_ioctl.c,v 1.42 2005/02/28 22:11:32 soren Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "sequencer.h"
|
||||
@ -110,6 +110,9 @@ linux_sys_ioctl(l, v, retval)
|
||||
case 'f':
|
||||
error = linux_ioctl_termios(p, uap, retval);
|
||||
break;
|
||||
case 'm':
|
||||
error = linux_ioctl_mtio(p, uap, retval);
|
||||
break;
|
||||
case 'T':
|
||||
{
|
||||
#if NSEQUENCER > 0
|
||||
@ -169,7 +172,7 @@ linux_sys_ioctl(l, v, retval)
|
||||
if (error == EPASSTHROUGH) {
|
||||
/*
|
||||
* linux returns EINVAL or ENOTTY for not supported ioctls.
|
||||
*/
|
||||
*/
|
||||
error = EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux_ioctl.h,v 1.20 2005/02/26 23:10:19 perry Exp $ */
|
||||
/* $NetBSD: linux_ioctl.h,v 1.21 2005/02/28 22:11:32 soren Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
||||
@ -58,6 +58,8 @@ int linux_ioctl_blkio __P((struct proc *p, struct linux_sys_ioctl_args *uap,
|
||||
register_t *retval));
|
||||
int linux_ioctl_sg __P((struct proc *p, struct linux_sys_ioctl_args *uap,
|
||||
register_t *retval));
|
||||
int linux_ioctl_mtio __P((struct proc *p, struct linux_sys_ioctl_args *uap,
|
||||
register_t *retval));
|
||||
__END_DECLS
|
||||
#endif /* !_KERNEL */
|
||||
|
||||
|
130
sys/compat/linux/common/linux_mtio.c
Normal file
130
sys/compat/linux/common/linux_mtio.c
Normal file
@ -0,0 +1,130 @@
|
||||
/* $NetBSD: linux_mtio.c,v 1.1 2005/02/28 22:11:32 soren Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005 Soren S. Jorvang. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_mtio.c,v 1.1 2005/02/28 22:11:32 soren Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/proc.h>
|
||||
|
||||
#include <sys/mtio.h>
|
||||
|
||||
#include <sys/sa.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#include <compat/linux/common/linux_types.h>
|
||||
#include <compat/linux/common/linux_ioctl.h>
|
||||
#include <compat/linux/common/linux_signal.h>
|
||||
#include <compat/linux/common/linux_mtio.h>
|
||||
|
||||
#include <compat/linux/linux_syscallargs.h>
|
||||
|
||||
static const struct mtop_mapping {
|
||||
short lop;
|
||||
short op;
|
||||
} mtop_map[] = {
|
||||
{ LINUX_MTFSF, MTFSF },
|
||||
{ LINUX_MTBSF, MTBSF },
|
||||
{ LINUX_MTFSR, MTFSR },
|
||||
{ LINUX_MTBSR, MTBSR },
|
||||
{ LINUX_MTWEOF, MTWEOF },
|
||||
{ LINUX_MTREW, MTREW },
|
||||
{ LINUX_MTOFFL, MTOFFL },
|
||||
{ LINUX_MTNOP, MTNOP },
|
||||
{ LINUX_MTRETEN, MTRETEN },
|
||||
{ LINUX_MTEOM, MTEOM },
|
||||
{ LINUX_MTERASE, MTERASE },
|
||||
{ LINUX_MTSETBLK, MTSETBSIZ },
|
||||
{ LINUX_MTSETDENSITY, MTSETDNSTY },
|
||||
{ LINUX_MTCOMPRESSION, MTCMPRESS },
|
||||
{ -1, -1 }
|
||||
};
|
||||
|
||||
int
|
||||
linux_ioctl_mtio(struct proc *p, struct linux_sys_ioctl_args *uap,
|
||||
register_t *retval)
|
||||
{
|
||||
struct file *fp;
|
||||
struct filedesc *fdp;
|
||||
u_long com = SCARG(uap, com);
|
||||
int i, error = 0;
|
||||
int (*ioctlf)(struct file *, u_long, void *, struct proc *);
|
||||
struct linux_mtop lmtop;
|
||||
struct linux_mtget lmtget;
|
||||
struct mtop mt;
|
||||
|
||||
fdp = p->p_fd;
|
||||
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
|
||||
return EBADF;
|
||||
|
||||
FILE_USE(fp);
|
||||
ioctlf = fp->f_ops->fo_ioctl;
|
||||
|
||||
*retval = 0;
|
||||
switch (com) {
|
||||
case LINUX_MTIOCTOP:
|
||||
error = copyin(SCARG(uap, data), &lmtop, sizeof lmtop);
|
||||
for (i = 0; mtop_map[i].lop >= 0; i++) {
|
||||
if (mtop_map[i].lop == lmtop.mt_op)
|
||||
break;
|
||||
}
|
||||
|
||||
if (mtop_map[i].lop == -1) {
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
mt.mt_op = mtop_map[i].op;
|
||||
mt.mt_count = lmtop.mt_count;
|
||||
error = ioctlf(fp, MTIOCTOP, (caddr_t)&mt, p);
|
||||
break;
|
||||
case LINUX_MTIOCGET:
|
||||
lmtget.mt_type = LINUX_MT_ISUNKNOWN;
|
||||
lmtget.mt_resid = 0;
|
||||
lmtget.mt_dsreg = 0;
|
||||
lmtget.mt_gstat = 0;
|
||||
lmtget.mt_erreg = 0;
|
||||
lmtget.mt_fileno = 0;
|
||||
lmtget.mt_blkno = 0;
|
||||
error = copyout(&lmtget, SCARG(uap, data), sizeof lmtget);
|
||||
break;
|
||||
case LINUX_MTIOCPOS:
|
||||
default:
|
||||
printf("linux_mtio unsupported ioctl 0x%lx\n", com);
|
||||
error = ENODEV;
|
||||
break;
|
||||
}
|
||||
|
||||
FILE_UNUSE(fp, p);
|
||||
|
||||
return error;
|
||||
}
|
88
sys/compat/linux/common/linux_mtio.h
Normal file
88
sys/compat/linux/common/linux_mtio.h
Normal file
@ -0,0 +1,88 @@
|
||||
/* $NetBSD: linux_mtio.h,v 1.1 2005/02/28 22:11:32 soren Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005 Soren S. Jorvang. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_MTIO_H
|
||||
#define _LINUX_MTIO_H
|
||||
|
||||
#define LINUX_MTIOCTOP _LINUX_IOW('m', 1, struct linux_mtop)
|
||||
#define LINUX_MTIOCGET _LINUX_IOR('m', 2, struct linux_mtget)
|
||||
#define LINUX_MTIOCPOS _LINUX_IOR('m', 3, struct linux_mtpos)
|
||||
|
||||
struct linux_mtop {
|
||||
short mt_op;
|
||||
int mt_count;
|
||||
};
|
||||
|
||||
#define LINUX_MTRESET 0
|
||||
#define LINUX_MTFSF 1
|
||||
#define LINUX_MTBSF 2
|
||||
#define LINUX_MTFSR 3
|
||||
#define LINUX_MTBSR 4
|
||||
#define LINUX_MTWEOF 5
|
||||
#define LINUX_MTREW 6
|
||||
#define LINUX_MTOFFL 7
|
||||
#define LINUX_MTNOP 8
|
||||
#define LINUX_MTRETEN 9
|
||||
#define LINUX_MTBSFM 10
|
||||
#define LINUX_MTFSFM 11
|
||||
#define LINUX_MTEOM 12
|
||||
#define LINUX_MTERASE 13
|
||||
#define LINUX_MTRAS1 14
|
||||
#define LINUX_MTRAS2 15
|
||||
#define LINUX_MTRAS3 16
|
||||
#define LINUX_MTSETBLK 20
|
||||
#define LINUX_MTSETDENSITY 21
|
||||
#define LINUX_MTSEEK 22
|
||||
#define LINUX_MTTELL 23
|
||||
#define LINUX_MTSETDRVBUFFER 24
|
||||
#define LINUX_MTFSS 25
|
||||
#define LINUX_MTBSS 26
|
||||
#define LINUX_MTWSM 27
|
||||
#define LINUX_MTLOCK 28
|
||||
#define LINUX_MTUNLOCK 29
|
||||
#define LINUX_MTLOAD 30
|
||||
#define LINUX_MTUNLOAD 31
|
||||
#define LINUX_MTCOMPRESSION 32
|
||||
#define LINUX_MTSETPART 33
|
||||
#define LINUX_MTMKPART 34
|
||||
|
||||
struct linux_mtget {
|
||||
#define LINUX_MT_ISUNKNOWN 0x01
|
||||
long mt_type;
|
||||
long mt_resid;
|
||||
long mt_dsreg;
|
||||
long mt_gstat;
|
||||
long mt_erreg;
|
||||
daddr_t mt_fileno;
|
||||
daddr_t mt_blkno;
|
||||
};
|
||||
|
||||
struct linux_mtpos {
|
||||
long mt_blkno;
|
||||
};
|
||||
|
||||
#endif /* !_LINUX_MTIO_H */
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.linux,v 1.17 2005/02/03 00:09:30 christos Exp $
|
||||
# $NetBSD: files.linux,v 1.18 2005/02/28 22:11:31 soren Exp $
|
||||
#
|
||||
# Config file description for machine-independent Linux compat code.
|
||||
# Included by ports that need it.
|
||||
@ -19,6 +19,7 @@ file compat/linux/common/linux_hdio.c compat_linux
|
||||
file compat/linux/common/linux_ioctl.c compat_linux
|
||||
file compat/linux/common/linux_ipc.c compat_linux
|
||||
file compat/linux/common/linux_misc.c compat_linux
|
||||
file compat/linux/common/linux_mtio.c compat_linux
|
||||
file compat/linux/common/linux_sched.c compat_linux
|
||||
file compat/linux/common/linux_sg.c compat_linux
|
||||
file compat/linux/common/linux_signal.c compat_linux
|
||||
|
Loading…
x
Reference in New Issue
Block a user