Subject: Re: Replacing svr4_ptm_alloc() with ptmopen()
To: Christos Zoulas <christos@astron.com>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 07/04/2007 21:17:31
On Tue, Jul 03, 2007 at 06:40:02PM +0000, Christos Zoulas wrote:
> >
> >I suspect that call to svr4_ptm_alloc() could be replaced by a call to
> >ptmopen() (in kern/tty_ptm.c) and it would all still work.
> >
> >Is that correct? and should it use minor 0 or 2 ?
> 
> Yes, it should be done this way. But you also need to handle the case
> where the NO_DEV_PTM option or whatever it is called is enabled (perhaps
> just fail then). 2 grants the pty on open, 0 does not. You'll need to
> test or trusss a solaris binary to see what the c library does. I am
> guessing 0.

Ok, my trusty solaris 8 box seems to:
  1) open /dev/ptmx
  2) exec /usr/lib/pt_chmod
  2a) fstat the open file to find the minor number
  2b) chown and chmod /dev/pts/%d
  3) fstat
  4) open /dev/pts/%d

I don't think (that version of) solaris has 'revoke'.
There is probably the SYSV fudge of not letting you access the
device (by major/minor) that used to be your ctty [1].

So I suspect we'd need to do the revoke() even though the chown/chmod
that happens at the same time isn't needed.

	David

[1] Great fun if your ctty was a minor of a network driver and
a later clone-open returns the same minor.

-- 
David Laight: david@l8s.co.uk