Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-request From: eggert@sm.unisys.com (Paul Eggert) Newsgroups: comp.sys.sun Subject: `/dev/tty: No such device or address' may be the dreaded itrunc bug Keywords: SunOS Message-ID: <8903091654.AA00897@poi.sm.unisys.com> Date: 22 Mar 89 20:35:02 GMT References: <176@mdcb.UUCP> Sender: usenet@rice.edu Organization: Unisys Santa Monica Lines: 34 Approved: Sun-Spots@rice.edu Original-Date: Thu, 9 Mar 89 08:54:33 PST X-Sun-Spots-Digest: Volume 7, Issue 204, message 8 of 13 |>How come any attempt to open /dev/tty ( as O_RDWR ) fails with the error |>"No such device or address"... Run `ls -l /dev/tty'. The output should look something like this. crw-rw-rw- 1 root 2, 0 Aug 25 1988 /dev/tty If the numbers aren't `2, 0' then perhaps you have been struck by the dreaded itrunc bug in SunOS 4.0 and 4.0.1 on Sun-3s and Sun-4s. The problem is that calls to ftruncate() can corrupt character special device files. The kernel routine itrunc() fails to verify the type of file/inode it is asked to act upon, and puts garbage in the file's inode, causing the inode to point at some other device -- a nonexistent device if you're lucky. To temporarily fix your problem, try the following commands as root. BEWARE: you are on thin ice here. The numbers `2 0' may be different on your system -- I don't know Sun's convention here, so run `grep "mknod tty" /dev/MAKEDEV' to be sure. cd /dev mv tty ttyBAD mknod tty c 2 0 chmod 666 tty rm -f ttyBAD # This `rm' may well cause your system crash and reboot. # It won't hurt to do a full file system check at this point. Unfortunately, the above fix is temporary: the next time your program calls ftruncate() on /dev/tty, the problem will probably recur. It happened to us with /dev/null :-( Sun says it's fixed in 4.1, and has a patch for ufs_inode.o if you want the fix now. Ask for the patch to bugid 1009825.