PR/32682: Hauke Fath: netbsd-3 ptyfs intermittent failure with Matlab

For the benefit of linux emulation create a new minor device '2'
which is a ptmx with linux semantics. Linux changes the permissions
of the slave pty upon creation, not when grantpt(3) is called. The
glibc linux grantpt(3) checks that the pty is on ptyfs, and if it is,
it does nothing. To make use of this fix:

	mknod /emul/linux/dev/ptmx c 165 2
	chmod 666 /emul/linux/dev/ptmx

This is a lot simpler than copying a bunch of code and creating a
ptmx device just for the benefit of linux emulation.
This commit is contained in:
christos 2006-09-22 15:15:56 +00:00
parent 487c57538b
commit 1edf5bf30e
1 changed files with 19 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: tty_ptm.c,v 1.11 2006/07/23 22:06:11 ad Exp $ */
/* $NetBSD: tty_ptm.c,v 1.12 2006/09/22 15:15:56 christos Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tty_ptm.c,v 1.11 2006/07/23 22:06:11 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: tty_ptm.c,v 1.12 2006/09/22 15:15:56 christos Exp $");
#include "opt_ptm.h"
@ -321,8 +321,24 @@ ptmopen(dev_t dev, int flag, int mode, struct lwp *l)
switch(minor(dev)) {
case 0: /* /dev/ptmx */
case 2: /* /emul/linux/dev/ptmx */
if ((error = pty_alloc_master(l, &fd, &dev)) != 0)
return error;
if (minor(dev) == 2) {
/*
* Linux ptyfs grants the pty right here.
* Handle this case here, instead of writing
* a new linux module.
*/
if ((error = pty_grant_slave(l, dev)) != 0) {
struct file *fp =
fd_getfile(l->l_proc->p_fd, fd);
FILE_UNUSE(fp, l);
fdremove(l->l_proc->p_fd, fd);
ffree(fp);
return error;
}
}
curlwp->l_dupfd = fd;
return EMOVEFD;
case 1: /* /dev/ptm */
@ -369,6 +385,7 @@ ptmioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l)
}
bad:
fp = fd_getfile(p->p_fd, cfd);
FILE_UNUSE(fp, l);
fdremove(p->p_fd, cfd);
ffree(fp);
return error;