diff options
-rw-r--r-- | etc/MAKEDEV | 17 | ||||
-rw-r--r-- | etc/etc.i386/MAKEDEV | 17 | ||||
-rw-r--r-- | sys/i386/isa/lpt.c | 28 | ||||
-rw-r--r-- | usr.sbin/Makefile | 3 | ||||
-rw-r--r-- | usr.sbin/lptcontrol/lptcontrol.8 | 84 | ||||
-rw-r--r-- | usr.sbin/lptcontrol/lptcontrol.c | 54 |
6 files changed, 117 insertions, 86 deletions
diff --git a/etc/MAKEDEV b/etc/MAKEDEV index de7d633..1da5366 100644 --- a/etc/MAKEDEV +++ b/etc/MAKEDEV @@ -64,7 +64,6 @@ # # Printers: # lpt* stock lp -# lpa* interruptless lp # # Call units: # @@ -76,7 +75,7 @@ # snd* various sound cards # pcaudio PCM audio driver # -# $Id: MAKEDEV,v 1.36 1994/05/30 03:53:01 ache Exp $ +# $Id: MAKEDEV,v 1.37 1994/06/17 21:50:07 jkh Exp $ # PATH=/sbin:/bin/:/usr/bin:/usr/sbin: @@ -89,7 +88,7 @@ all) sh MAKEDEV std # standard sh MAKEDEV wd0 wd1 fd0 fd1 ft0 wt0 sd0 sd1 st0 cd0 mcd0 # bdev sh MAKEDEV pty0 tty0 tty1 pc0 lpt0 lpt1 lpt2 # cdev - sh MAKEDEV ch0 tw0 bpf0 dcf0 lpa0 lpa1 lpa2 # cdev + sh MAKEDEV ch0 tw0 bpf0 dcf0 # cdev sh MAKEDEV speaker pcaudio psm0 mse0 ttyd2 ttyd3 # cdev sh MAKEDEV vty4 # cdev ;; @@ -418,7 +417,10 @@ cd*|mcd*) lpt*) unit=`expr $i : 'lpt\(.*\)'` rm -f lpt$unit + rm -f lpctl$unit mknod lpt$unit c 16 $unit + mknod lpctl$unit c 16 `expr $unit + 128` + chown root.wheel lpt$unit chown root.wheel lpt$unit ;; @@ -469,15 +471,6 @@ dcf*) chown root.wheel dcf$unit ;; -lpa*) - unit=`expr $i : 'lpa\(.*\)'` - chr=25 - rm -f lpa$unit lpa${unit}p - mknod lpa${unit} c $chr `expr $unit + 0` - mknod lpa${unit}p c $chr `expr $unit + 32` - chown root.wheel lpa${unit} lpa${unit}p - ;; - speaker) rm -f speaker mknod speaker c 26 0 diff --git a/etc/etc.i386/MAKEDEV b/etc/etc.i386/MAKEDEV index de7d633..1da5366 100644 --- a/etc/etc.i386/MAKEDEV +++ b/etc/etc.i386/MAKEDEV @@ -64,7 +64,6 @@ # # Printers: # lpt* stock lp -# lpa* interruptless lp # # Call units: # @@ -76,7 +75,7 @@ # snd* various sound cards # pcaudio PCM audio driver # -# $Id: MAKEDEV,v 1.36 1994/05/30 03:53:01 ache Exp $ +# $Id: MAKEDEV,v 1.37 1994/06/17 21:50:07 jkh Exp $ # PATH=/sbin:/bin/:/usr/bin:/usr/sbin: @@ -89,7 +88,7 @@ all) sh MAKEDEV std # standard sh MAKEDEV wd0 wd1 fd0 fd1 ft0 wt0 sd0 sd1 st0 cd0 mcd0 # bdev sh MAKEDEV pty0 tty0 tty1 pc0 lpt0 lpt1 lpt2 # cdev - sh MAKEDEV ch0 tw0 bpf0 dcf0 lpa0 lpa1 lpa2 # cdev + sh MAKEDEV ch0 tw0 bpf0 dcf0 # cdev sh MAKEDEV speaker pcaudio psm0 mse0 ttyd2 ttyd3 # cdev sh MAKEDEV vty4 # cdev ;; @@ -418,7 +417,10 @@ cd*|mcd*) lpt*) unit=`expr $i : 'lpt\(.*\)'` rm -f lpt$unit + rm -f lpctl$unit mknod lpt$unit c 16 $unit + mknod lpctl$unit c 16 `expr $unit + 128` + chown root.wheel lpt$unit chown root.wheel lpt$unit ;; @@ -469,15 +471,6 @@ dcf*) chown root.wheel dcf$unit ;; -lpa*) - unit=`expr $i : 'lpa\(.*\)'` - chr=25 - rm -f lpa$unit lpa${unit}p - mknod lpa${unit} c $chr `expr $unit + 0` - mknod lpa${unit}p c $chr `expr $unit + 32` - chown root.wheel lpa${unit} lpa${unit}p - ;; - speaker) rm -f speaker mknod speaker c 26 0 diff --git a/sys/i386/isa/lpt.c b/sys/i386/isa/lpt.c index 00080c3..4b03ae3 100644 --- a/sys/i386/isa/lpt.c +++ b/sys/i386/isa/lpt.c @@ -46,7 +46,7 @@ * SUCH DAMAGE. * * from: unknown origin, 386BSD 0.1 - * $Id: lpt.c,v 1.15 1994/08/14 01:46:28 phk Exp $ + * $Id: lpt.c,v 1.16 1994/08/23 07:52:20 paul Exp $ */ /* @@ -397,7 +397,7 @@ lptattach(struct isa_device *isdp) sc->sc_irq = LP_HAS_IRQ | LP_USE_IRQ | LP_ENABLE_IRQ; printf("lpt%d: Interrupt-driven port\n", isdp->id_unit); #ifdef INET - lpattach(sc,isdp->id_unit); + lpattach(sc,isdp->id_unit); #endif } else { sc->sc_irq = 0; @@ -410,6 +410,8 @@ lptattach(struct isa_device *isdp) /* * lptopen -- reset the printer, then wait until it's selected and not busy. + * If LP_BYPASS flag is selected, then we do not try to select the + * printer -- this is just used for passing ioctls. */ int @@ -434,8 +436,15 @@ lptopen(dev_t dev, int flag) return(EBUSY); } else sc->sc_state |= INIT; - s = spltty(); sc->sc_flags = LPTFLAGS(minor(dev)); + + /* Check for open with BYPASS flag set. */ + if(sc->sc_flags & LP_BYPASS) { + sc->sc_state = OPEN; + return(0); + } + + s = spltty(); lprintf("lp flags 0x%x\n", sc->sc_flags); port = sc->sc_port; @@ -540,6 +549,9 @@ lptclose(dev_t dev, int flag) struct lpt_softc *sc = lpt_sc + LPTUNIT(minor(dev)); int port = sc->sc_port; + if(sc->sc_flags & LP_BYPASS) + goto end_close; + sc->sc_state &= ~OPEN; /* if the last write was interrupted, don't complete it */ @@ -551,10 +563,11 @@ lptclose(dev_t dev, int flag) "lpclose", hz) != EWOULDBLOCK) break; - sc->sc_state = 0; - sc->sc_xfercnt = 0; outb(sc->sc_port+lpt_control, LPC_NINIT); brelse(sc->sc_inbuf); +end_close: + sc->sc_state = 0; + sc->sc_xfercnt = 0; lprintf("closed.\n"); return(0); } @@ -634,6 +647,11 @@ lptwrite(dev_t dev, struct uio * uio) int pl, err; struct lpt_softc *sc = lpt_sc + LPTUNIT(minor(dev)); + if(sc->sc_flags & LP_BYPASS) { + /* we can't do writes in bypass mode */ + return(EPERM); + } + sc->sc_state &= ~INTERRUPTED; while (n = min(BUFSIZE, uio->uio_resid)) { sc->sc_cp = sc->sc_inbuf->b_un.b_addr ; diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile index 0a9704f..7c0c5d5 100644 --- a/usr.sbin/Makefile +++ b/usr.sbin/Makefile @@ -4,7 +4,8 @@ # XXX MISSING SOURCES: ac quot # XXX TEMP. BROKEN: iostat xntpd SUBDIR= accton amd arp chown chroot cron dbsym dev_mkdb diskpart \ - edquota inetd kbdcontrol kgmon kvm_mkdb lpr mtree portmap pstat \ + edquota inetd kbdcontrol kgmon kvm_mkdb lpr lptcontrol \ + mtree portmap pstat \ pwd_mkdb quotaon repquota routed rmt rtprio rwhod sendmail \ sliplogin sysctl syslogd tcpdump traceroute trpt vidcontrol \ vipw ypbind yppoll ypset diff --git a/usr.sbin/lptcontrol/lptcontrol.8 b/usr.sbin/lptcontrol/lptcontrol.8 index 52c34a6..4a02390 100644 --- a/usr.sbin/lptcontrol/lptcontrol.8 +++ b/usr.sbin/lptcontrol/lptcontrol.8 @@ -12,56 +12,62 @@ .\" .\" .\" $Id: lptcontrol.1,v 1.3 1994/05/22 12:31:54 csgr Exp $ -.TH lptcontrol 1 "March 12, 1994" "" "FreeBSD" - -.SH NAME -lptcontrol - a utility for manipulating the lpt printer driver. -.SH SYNOPSIS -.na -.B lptcontrol -.RB [options] -.SH DESCRIPTION +.Dd September 3, 1994 +.Dt LPTCONTROL 8 +.Os FreeBSD 2 +.Sh NAME +.Nm \&lptcontrol +.Nd a utility for manipulating the lpt printer driver. +.Sh SYNOPSIS +.Nm \&lptcontrol +.Cm -i +| +.Cm -p +.Op Fl u Ar unit no +.Sh DESCRIPTION The -.B lptcontrol +.Nm lptcontrol command is used to set either the interrupt-driven or polling mode -of individual lpt devices. When a printer is switched between +of individual +.Xr lpt 4 +devices. When a printer is switched between interrupt-driven and polled mode, this change will only take effect the next time the device is opened. -.SH OPTIONS +.Sh OPTIONS .TP -The following command line options are supported. -.TP -.B \-i +The following command line options are supported: +.Bl -tag -width indent +.It Fl i Turns on interrupt-driven mode. -.TP -.B \-p +.It Fl p Turns on polled mode. -.TP -.BI "\-f\ " file +.It Fl u Ar n Sets the mode of the printer device specified by -.I file. +.Em n . The default value for -.I file +.Em n is -.I /dev/lpt0 -.TP +.Em 0 (ie. /dev/lpt0) +.El +.Pp One of -.B \-i +.Fl i or -.B \-p +.Fl p must be specified. -.PP -.SH FILES -/dev/lpt? -.PP -.SH BUGS -If the port to be controlled does not have a printer connected and -on-line, then lptcontrol will not be able to open the port in question -for performing ioctl's and will fail. -.sp -Sure to be others. -.SH "SEE ALSO" -.BR lpt (4) , -.BR /sys/i386/conf/GENERICAH -.SH AUTHOR +.Pp +.Sh FILES +.Bl -tag -width indent -compact +.It Pa /dev/lpt? - printer devices +.It Pa /dev/lpctl? - printer control devices +.El +.Sh BUGS +Sure to be some. +.Sh "SEE ALSO" +.Xr lpt 4 +.Xr /sys/i386/conf/GENERICAH +.Sh AUTHOR Geoffrey M. Rehmet +.Sh HISTORY +.Nm lptcontrol +first appeared in FreeBSD 1.1.5 diff --git a/usr.sbin/lptcontrol/lptcontrol.c b/usr.sbin/lptcontrol/lptcontrol.c index bcb3ad3..cbe0410 100644 --- a/usr.sbin/lptcontrol/lptcontrol.c +++ b/usr.sbin/lptcontrol/lptcontrol.c @@ -27,30 +27,35 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: lptcontrol.c,v 1.2 1994/04/08 22:23:39 csgr Exp $ + * $Id: lptcontrol.c,v 1.1.1.1 1994/09/03 13:10:09 csgr Exp $ */ -#include <sys/types.h> -#include <sys/file.h> -#include <sys/ioctl.h> -#include <machine/lpt.h> -#include <stdlib.h> -#include <unistd.h> +#include <ctype.h> +#include <limits.h> +#include <paths.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> +#include <unistd.h> + +#include <machine/lpt.h> #include <sys/errno.h> +#include <sys/file.h> +#include <sys/ioctl.h> +#include <sys/types.h> -#define DEFAULT_LPT "/dev/lpt0" +#define PATH_LPCTL _PATH_DEV "lpctl" +#define DEFAULT_UNIT "0" #define IRQ_INVALID -1 #define DO_POLL 0 #define USE_IRQ 1 -static char default_printer[] = DEFAULT_LPT; - static void usage(const char * progname) { - fprintf(stderr, "usage: %s -i | -p [-f <file name>]\n", progname); + fprintf(stderr, "usage: %s -i | -p [-u <unit no.>]\n", progname); + fprintf(stderr, "\tUnit no. is a value in the range 0 to 3\n"); + fprintf(stderr, "\tThe default unit no is 0 (ie. /dev/lpt0)\n"); exit(1); } @@ -69,23 +74,38 @@ static void set_interrupt_status(int irq_status, const char * file) close(fd); } +static char * dev_file(char unit_no) +{ + static char devname[_POSIX_PATH_MAX+1]; + int len; + + strncpy(devname, PATH_LPCTL, _POSIX_PATH_MAX); + devname[len = strlen(devname)] = unit_no; + devname[++len] = '\0'; + + return(devname); +} int main (int argc, char * argv[]) { int opt; - int irq_status = -1; - char * file = default_printer; + int irq_status = IRQ_INVALID; + char * unit = DEFAULT_UNIT; - while((opt = getopt(argc, argv, "pif:")) != -1) + while((opt = getopt(argc, argv, "ipu:")) != -1) switch(opt) { case 'i': irq_status = USE_IRQ; break; case 'p': irq_status = DO_POLL; break; - case 'f': file = optarg; break; + case 'u': unit = optarg; + if(!isdigit(*unit)) + usage(argv[0]); + break; default : usage(argv[0]); } - if(irq_status == IRQ_INVALID) usage(argv[0]); + if(irq_status == IRQ_INVALID) + usage(argv[0]); - set_interrupt_status(irq_status, file); + set_interrupt_status(irq_status, dev_file(*unit)); exit(0); } |