From owner-freebsd-arch Mon Jan 29 6:47: 6 2001 Delivered-To: freebsd-arch@freebsd.org Received: from critter.freebsd.dk (flutter.freebsd.dk [212.242.40.147]) by hub.freebsd.org (Postfix) with ESMTP id AC8BC37B402 for ; Mon, 29 Jan 2001 06:46:48 -0800 (PST) Received: from critter (localhost [127.0.0.1]) by critter.freebsd.dk (8.11.1/8.11.1) with ESMTP id f0TEklK21636; Mon, 29 Jan 2001 15:46:47 +0100 (CET) (envelope-from phk@critter.freebsd.dk) Cc: Peter Wemm , Brian Somers , freebsd-arch@FreeBSD.ORG Subject: Re: Cloned open support In-Reply-To: Your message of "Mon, 29 Jan 2001 15:39:27 +0100." <21576.980779167@critter> Date: Mon, 29 Jan 2001 15:46:47 +0100 Message-ID: <21634.980779607@critter> From: Poul-Henning Kamp Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message <21576.980779167@critter>, Poul-Henning Kamp writes: >>Well, how do we support Unix98 /dev/ptmx then? This is not an academic >>question, Linux apps are starting to do it this way and if we want to run >>anything that uses ptys.... >> >> int fdm fds; >> char *slavename; >> extern char *ptsname(); >> >> fdm = open("/dev/ptmx", O_RDWR); /* open master */ >> grantpt(fdm); /* change permission ofslave */ >> unlockpt(fdm); /* unlock slave */ >> slavename = ptsname(fdm); /* get name of slave */ >> fds = open(slavename, O_RDWR); /* open slave */ >> >>Opening the master allocates you a private unit of the device with its own >>minor number. > >We will support it just like that. pts_clone() will recognize the "ptmx" >name. Create a new dev_t and return it. Getting the name can be done >with fstat(2) and devname(3). A transformation to slave name is needed >but that will always be needed. and it will DTRT. > >In fact, I think you can implement this in less than 20 lines of code total. There is one more thing you have to do: in fs/devfs/devfs_vnops.c you need to modify the loop right before the "notfound:" label to recognize the new entry by the dev_t instead of the name, since the clone function creates a dev_t for another name. That will probably be faster in the normal case as well... -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message