From owner-freebsd-current Sun May 13 5:38:43 2001 Delivered-To: freebsd-current@freebsd.org Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by hub.freebsd.org (Postfix) with ESMTP id CA7C237B423; Sun, 13 May 2001 05:38:36 -0700 (PDT) (envelope-from phk@critter.freebsd.dk) Received: from critter (localhost [127.0.0.1]) by critter.freebsd.dk (8.11.3/8.11.3) with ESMTP id f4DCcPp08076; Sun, 13 May 2001 14:38:25 +0200 (CEST) (envelope-from phk@critter.freebsd.dk) To: arch@freebsd.org, current@freebsd.org Subject: /dev/tty and device cloning. From: Poul-Henning Kamp Date: Sun, 13 May 2001 14:38:25 +0200 Message-ID: <8074.989757505@critter> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG /dev/tty is as we all know quite a hack: it is a variant symlink is disguise. I have create a patch which cleans up the way /dev/tty works using the DEVFS cloning mechanism, and I would like to get feedback on it. http://phk.freebsd.dk/patch/devtty.patch 20010513 devtty.patch This patch slightly changes the way device cloning works. After the cloners have been called we try to find the match not by name but by the dev_t the successfull cloner gave us. This allows "cloning by a different name" activities. The patch to kern/tty_tty.c exploits this feature to remove the the magic and bogus /dev/tty device, and instead /dev/tty by clone-magic points at the process' controlling terminal. (The patch also contains a few cleanups) The following difference results: Without this patch: critter phk> tty /dev/ttypd critter phk> ls -li /dev/ttypd /dev/tty 12 crw-rw-rw- 1 root wheel 1, 0 13 Maj 14:22 /dev/tty 109 crw--w---- 1 phk tty 5, 13 13 Maj 14:28 /dev/ttypd With this patch: syv# tty /dev/ttyp0 syv# ls -li /dev/ttyp0 /dev/tty 87 crw--w---- 1 root tty 5, 0 May 13 12:27 /dev/tty 87 crw--w---- 1 root tty 5, 0 May 13 12:27 /dev/ttyp0 -- 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-current" in the body of the message