[comp.sources.misc] /dev/full device for 4.3 BSD

arnold@emory.UUCP (Arnold D. Robbins {EUCC}) (07/11/87)

A while back in comp.unix.wizards, elsie!ado (Arthur David Olsen) suggested
the idea of /dev/full, a data source. He speculated it would be useful for
testing tape drives, e.g.

	$ dd if=/dev/full of=/dev/rmt8 bs=20k

to see how fast you can make it go. There may be other uses as well.

I liked the idea, so I went ahead and did it. It's only 7 more lines of
code in /sys/vax/mem.c in 4.3 BSD. As always, your line numbers may vary,
but patch should be able to handle it.

Enjoy,

Arnold Robbins
-------------------------------------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	mem.c.patch
#	full.4
# This archive created: Fri Jul 10 12:47:39 1987
export PATH; PATH=/bin:$PATH
echo shar: extracting "'mem.c.patch'" '(516 characters)'
if test -f 'mem.c.patch'
then
	echo shar: will not over-write existing file "'mem.c.patch'"
else
cat << \SHAR_EOF > 'mem.c.patch'
rcsdiff -c -r1.1 mem.c
RCS file: RCS/mem.c,v
retrieving revision 1.1
diff -c -r1.1 mem.c
*** /tmp/,RCSt1015020	Fri Jul 10 12:46:39 1987
--- mem.c	Wed May 27 15:24:33 1987
***************
*** 119,124 ****
--- 122,134 ----
  				goto fault;
  			error = UNIcpy((caddr_t)uio->uio_offset, iov->iov_base,
  			    (int)c, rw);
+ 			break;
+ 
+ /* minor device 4 is /dev/full -- success on read, 0 on write */
+ 		case 4:
+ 			if (rw == UIO_WRITE)
+ 				return (0);
+ 			c = iov->iov_len;
  			break;
  		}
  		if (error)
SHAR_EOF
fi # end of overwriting check
echo shar: extracting "'full.4'" '(277 characters)'
if test -f 'full.4'
then
	echo shar: will not over-write existing file "'full.4'"
else
cat << \SHAR_EOF > 'full.4'
.TH FULL 4 local
.SH NAME
full \- data source
.SH SYNOPSIS
Data read from the full special device always returns the number of
bytes requested.
.PP
The number of bytes that can be written to
the full special device is always zero.
.SH FILES
/dev/full
.SH SEE ALSO
.IR null (4)
SHAR_EOF
fi # end of overwriting check
#	End of shell archive
exit 0
-- 
Arnold Robbins
ARPA, CSNET:	arnold@emory.ARPA	BITNET: arnold@emory
UUCP:	{ decvax, gatech, sun!sunatl }!emory!arnold
ONE-OF-THESE-DAYS:	arnold@emory.mathcs.emory.edu