It is currently Sat, 18 May 2013 11:32:48 GMT



 
Author Message
 /dev/full device
Here is my implementation of the full device, /dev/full.
/dev/full is a simple extention to the /dev/null and /dev/zero
family of devices; reads always succeed (subject to memory
protection constraints), writes always fail (ENOSPC).  Useful
for testing programs for grace under pressure.

                --Ken Pizzini

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#               "End of shell archive."
# Contents:  README.full full-patch full.4
# Wrapped by ken@softland on Thu Apr 15 00:47:25 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README.full' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'README.full'\"
else
echo shar: Extracting \"'README.full'\" \(351 characters\)
sed "s/^X//" >'README.full' <<'END_OF_FILE'
XHere is a simple extention to the /dev/null and /dev/zero family of
Xdevices, /dev/full.  Reads always succeed (subject to memory protection
Xconstraints), writes always fail (ENOSPC).  Useful for testing programs
Xfor grace under pressure.
X
XRead the full.4 man page for a slightly more complete description.
X
XTo install:
X       cd /usr/src
X       patch <full-patch
END_OF_FILE
if test 351 -ne `wc -c <'README.full'`; then
    echo shar: \"'README.full'\" unpacked with wrong size!
fi
# end of 'README.full'
fi
if test -f 'full-patch' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'full-patch'\"
else
echo shar: Extracting \"'full-patch'\" \(1139 characters\)
sed "s/^X//" >'full-patch' <<'END_OF_FILE'
X--- linux/kernel/chr_drv/mem.c-sv      Mon Apr 12 23:17:14 1993
X+++ linux/kernel/chr_drv/mem.c Wed Apr 14 23:49:52 1993
X@@ -204,6 +204,17 @@
X       return 0;
X }
X
X+static int read_full(struct inode * node,struct file * file,char * buf,int count)
X+{
X+      return count;
X+}
X+
X+static int write_full(struct inode * inode,struct file * file,char * buf, int count)
X+{
X+      return -ENOSPC;
X+}
X+
X+
X /*
X  * The memory devices use the full 32 bits of the offset, and so we cannot
X  * check against negative addresses: they are ok. The return value is weird,
X@@ -317,6 +328,18 @@
X       NULL            /* no special release code */
X };
X
X+static struct file_operations full_fops = {
X+      memory_lseek,
X+      read_full,
X+      write_full,
X+      NULL,           /* full_readdir */
X+      NULL,           /* full_select */
X+      NULL,           /* full_ioctl */
X+      NULL,           /* full_mmap */
X+      NULL,           /* no special open code */
X+      NULL            /* no special release code */
X+};
X+
X static int memory_open(struct inode * inode, struct file * filp)
X {
X       switch (MINOR(inode->i_rdev)) {
X@@ -340,6 +363,9 @@
X                       break;
X               case 6:
X                       filp->f_op = &core_fops;
X+                      break;
X+              case 7:
X+                      filp->f_op = &full_fops;
X                       break;
X               default:
X                       return -ENODEV;
END_OF_FILE
if test 1139 -ne `wc -c <'full-patch'`; then
    echo shar: \"'full-patch'\" unpacked with wrong size!
fi
# end of 'full-patch'
fi
if test -f 'full.4' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'full.4'\"
else
echo shar: Extracting \"'full.4'\" \(1054 characters\)
sed "s/^X//" >'full.4' <<'END_OF_FILE'
X.TH full 4 "15 April 1993"
X.SH NAME
Xfull \- full device
X.SH
XCONFIG \- Linux 0.99p8
XMajor device c 1
X.br
XMinor device c 7
X.SH SYNOPSIS
X.B /dev/full
X.SH DESCRIPTION
XThe
X.B /dev/full
Xdevice is the opposite of
X.B /dev/null
X(cf.
X.IR null (4)).
X.LP
XIn particular, writes to
X.B /dev/full
Xalways fail with
X.TR ENOSPC ,
Xand reads from
X.B /dev/full
Xalways succeed
X(provided that the buffer passed by
X.IR read (2)
Xdoesn't violate memory protections).
XNote that reads of
X.B /dev/full
Xreturn whatever garbage existed in the buffer
Xat the time of the
X.IR read (2).
X.LP
X.B /dev/full
Xcan be used to test behavior of programs under disk-full
Xconditions without having to create an actual full disk.
X.SH FILES
X/dev/full
X.SH "SEE ALSO"
X.IR read (2),
X.IR null (4),
X.IR zero (4).
X.SH DIAGNOSTICS
X.TP
X.B ENOSP
Xattempt to write to
X.BR /dev/null .
X.SH BUGS
XOne probably really wants to read from
X.B /dev/zero
Xinstead of
X.BR /dev/full .
X.SH AUTHOR
XWritten by Ken Pizzini (k...@halcyon.com).
XPlaced in the public domain.
X.SH MOTTO
XLinux: Because a PC is a terrible thing to waste.
END_OF_FILE
if test 1054 -ne `wc -c <'full.4'`; then
    echo shar: \"'full.4'\" unpacked with wrong size!
fi
# end of 'full.4'
fi
echo shar: End of shell archive.
exit 0

--
Send submissions for comp.os.linux.announce to: linux-annou...@tc.cornell.edu



 Tue, 03 Oct 1995 23:29:45 GMT   
 
   [ 1 post ] 

Similar Threads

1. /dev/audio : device full ????

2. How can I create fax device files /dev/tty4c /dev/tty4d

3. ide-scsi: /dev/sg device but no corresponding /dev/scd

4. PCMCIA flash device name question / reading cards (/dev/mem0a, /dev/mem0c0c, etc)

5. /proc/dev: virtual device entries (/dev replacement)

6. /proc/dev: virtual device entries (/dev replacement)

7. /dev/tty00 vs /dev/cua00 and other device confusions

8. Solaris 2.7 x86 - Device detection and /dev device names

9. device /dev/dsp can't be opened (No such device) (with onbaord via soundcard)

10. pcap HELP: device: /dev/bpf0: Device not configured


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software