[net.sources] Fix for stdio bug invoked by mass driver installation

chris@umcp-cs.UUCP (Chris Torek) (08/22/85)

[I'm posting this to net.sources, rather than net.sources.bugs,
because it's important that it show up on the ARPA unix-sources
mailing list.  If you've installed my "mass driver" code, read
on.  Otherwise, ignore the rest of this.]

The 4.2BSD stdio library has two fixed size buffers, _sibuf and
_sobuf, which are attached to stdin and stdout respectively.  The
buffers are MAXBSIZE characters, which is OK, except that the block
size from the stat() done at setup time is never checked, and can
be larger than what MAXBSIZE was when stdio was compiled.

In particular,

	command_with_lots_of_output >/dev/null

tends to do mysterious things after installing the mass driver.
The following kernel hack makes sure that stat() never reports more
than 8K as the block size of a character special device.

In sys/sys/sys_inode.c, find ino_stat().  Change the two lines 
reading 
 
        else if ((ip->i_mode&IFMT) == IFCHR)
                sb->st_blksize = MAXBSIZE;
 
to
 
        else if ((ip->i_mode&IFMT) == IFCHR)
#if MAXBSIZE > 8192                     /* XXX required for old binaries */
                sb->st_blksize = 8192;
#else
                sb->st_blksize = MAXBSIZE;
#endif
 
The alternative is to recompile stdio (possibly after fixing its
bug), then recompile every binary compiled since 4.2BSD, which is
probably infeasible at most installations.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@maryland