`/dev/tty: No such device or address' may be the dreaded itrunc bug

Paul Eggert eggert at sm.unisys.com
Thu Mar 23 06:35:02 AEST 1989


|>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.



More information about the Comp.sys.sun mailing list