Add ptmx fakedevice hack for amd64

Fix a bug in ioctl handling
This commit is contained in:
manu 2007-03-14 21:52:17 +00:00
parent d74897d542
commit 91e99f33d3
3 changed files with 46 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_machdep.c,v 1.20 2007/03/05 14:14:15 christos Exp $ */
/* $NetBSD: linux_machdep.c,v 1.21 2007/03/14 21:52:17 manu Exp $ */
/*-
* Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
@ -33,7 +33,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.20 2007/03/05 14:14:15 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.21 2007/03/14 21:52:17 manu Exp $");
#include <sys/param.h>
#include <sys/types.h>
@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.20 2007/03/05 14:14:15 christos
#include <sys/user.h>
#include <sys/wait.h>
#include <sys/ucontext.h>
#include <sys/conf.h>
#include <machine/reg.h>
#include <machine/pcb.h>
@ -53,6 +54,18 @@ __KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.20 2007/03/05 14:14:15 christos
#include <machine/specialreg.h>
#include <machine/vmparam.h>
/*
* To see whether wscons is configured (for virtual console ioctl calls).
*/
#if defined(_KERNEL_OPT)
#include "wsdisplay.h"
#endif
#if (NWSDISPLAY > 0)
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wsdisplay_usl_io.h>
#endif
#include <compat/linux/common/linux_signal.h>
#include <compat/linux/common/linux_errno.h>
#include <compat/linux/common/linux_exec.h>
@ -345,6 +358,23 @@ linux_fakedev(dev, raw)
dev_t dev;
int raw;
{
extern const struct cdevsw ptc_cdevsw, pts_cdevsw;
const struct cdevsw *cd = cdevsw_lookup(dev);
if (raw) {
#if (NWSDISPLAY > 0)
extern const struct cdevsw wsdisplay_cdevsw;
if (cd == &wsdisplay_cdevsw)
return makedev(LINUX_CONS_MAJOR, (minor(dev) + 1));
#endif
}
if (cd == &ptc_cdevsw)
return makedev(LINUX_PTC_MAJOR, minor(dev));
if (cd == &pts_cdevsw)
return makedev(LINUX_PTS_MAJOR, minor(dev));
return ((minor(dev) & 0xff) | ((major(dev) & 0xfff) << 8)
| (((unsigned long long int) (minor(dev) & ~0xff)) << 12)
| (((unsigned long long int) (major(dev) & ~0xfff)) << 32));

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_machdep.h,v 1.6 2007/03/14 12:44:39 njoly Exp $ */
/* $NetBSD: linux_machdep.h,v 1.7 2007/03/14 21:52:17 manu Exp $ */
/*-
* Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
@ -116,4 +116,14 @@ __END_DECLS
#define LINUX_NPTL
#define LINUX_LARGEFILE64
/*
* Used in ugly patch to fake device numbers.
*/
/* Major device numbers for new style ptys. */
#define LINUX_PTC_MAJOR 2
#define LINUX_PTS_MAJOR 3
/* Major device numbers of VT device on both Linux and NetBSD. */
#define LINUX_CONS_MAJOR 4
#endif /* _AMD64_LINUX_MACHDEP_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_termios.c,v 1.29 2007/03/04 06:01:24 christos Exp $ */
/* $NetBSD: linux_termios.c,v 1.30 2007/03/14 21:52:17 manu Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_termios.c,v 1.29 2007/03/04 06:01:24 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_termios.c,v 1.30 2007/03/14 21:52:17 manu Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ptm.h"
@ -105,7 +105,7 @@ linux_ioctl_termios(l, uap, retval)
com = SCARG(uap, com);
retval[0] = 0;
switch (com & 0xffff) {
switch (com) {
case LINUX_TCGETS:
error = (*bsdioctl)(fp, TIOCGETA, (void *)&tmpbts, l);
if (error)