diff options
| author | svn2git <svn2git@FreeBSD.org> | 1993-11-01 08:00:00 +0000 |
|---|---|---|
| committer | svn2git <svn2git@FreeBSD.org> | 1993-11-01 08:00:00 +0000 |
| commit | 8503f4f13f77abf7adc8f7e329c6f9c1d52b6a20 (patch) | |
| tree | c5b2ce776438e0a52b492a2ab6ab41360b8ba1f6 /usr.sbin/flcopy | |
Diffstat (limited to 'usr.sbin/flcopy')
| -rw-r--r-- | usr.sbin/flcopy/Makefile | 7 | ||||
| -rw-r--r-- | usr.sbin/flcopy/flcopy.8 | 83 | ||||
| -rw-r--r-- | usr.sbin/flcopy/flcopy.c | 201 | ||||
| -rw-r--r-- | usr.sbin/flcopy/pathnames.h | 36 |
4 files changed, 327 insertions, 0 deletions
diff --git a/usr.sbin/flcopy/Makefile b/usr.sbin/flcopy/Makefile new file mode 100644 index 000000000000..2cfc59848c66 --- /dev/null +++ b/usr.sbin/flcopy/Makefile @@ -0,0 +1,7 @@ +# @(#)Makefile 5.2 (Berkeley) 1/20/91 + +PROG= flcopy +MANSUBDIR=/vax +MAN8= flcopy.8 + +.include <bsd.prog.mk> diff --git a/usr.sbin/flcopy/flcopy.8 b/usr.sbin/flcopy/flcopy.8 new file mode 100644 index 000000000000..1cc14ccd9c80 --- /dev/null +++ b/usr.sbin/flcopy/flcopy.8 @@ -0,0 +1,83 @@ +.\" Copyright (c) 1980 Regents of the University of California. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)flcopy.8 5.2 (Berkeley) 4/20/91 +.\" +.TH FLCOPY 8 "April 20, 1991" +.UC 4 +.SH NAME +flcopy \- floppy copy +.SH SYNOPSIS +.nf +.ft B +flcopy [ \-hr ] [ \-f file ] [ \-t ntracks ] +.ft R +.fi +.SH DESCRIPTION +.I Flcopy +copies the console floppy disk (``/dev/floppy'') to a file in the +current directory, named ``floppy''. +The user is then prompted to change the floppy, and enter a carriage +return when done. +When a carriage return is entered, +.I flcopy +copies the file out to the floppy disk. +.PP +The options are as follows: +.TP +\-f +Use +.I file +instead of ``/dev/floppy''. +.TP +-h +Cause +.I flcopy +to copy a file named ``floppy'' in the current directory to +the console floppy disk. +.TP +\-r +Cause +.I flcopy +to copy the floppy to the current directory and then quit. +.TP +\-t +Copy only the first +.I ntracks +tracks. +.SH FILES +floppy temporary file name +.br +/dev/floppy default floppy device +.SH SEE ALSO +crl(4), fl(4), rx(4), tu(4), arff(8), rxformat(8) +.SH BUGS +Device errors are handled ungracefully. diff --git a/usr.sbin/flcopy/flcopy.c b/usr.sbin/flcopy/flcopy.c new file mode 100644 index 000000000000..d1a2e35ff043 --- /dev/null +++ b/usr.sbin/flcopy/flcopy.c @@ -0,0 +1,201 @@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +char copyright[] = +"@(#) Copyright (c) 1989 The Regents of the University of California.\n\ + All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)flcopy.c 5.4 (Berkeley) 1/20/91"; +#endif /* not lint */ + +#include <sys/file.h> +#include <stdio.h> +#include "pathnames.h" + +int floppydes; +char *flopname = _PATH_FLOPPY; +long dsize = 77 * 26 * 128; +int hflag; +int rflag; + +main(argc, argv) + register char **argv; +{ + extern char *optarg; + extern int optind; + static char buff[512]; + register long count; + register startad = -26 * 128; + register int n, file; + register char *cp; + int ch; + + while ((ch = getopt(argc, argv, "f:hrt:")) != EOF) + switch(ch) { + case 'f': + flopname = optarg; + break; + case 'h': + hflag = 1; + printf("Halftime!\n"); + if ((file = open("floppy", 0)) < 0) { + printf("can't open \"floppy\"\n"); + exit(1); + } + break; + case 'r': + rflag = 1; + break; + case 't': + dsize = atoi(optarg); + if (dsize <= 0 || dsize > 77) { + (void)fprintf(stderr, + "flcopy: bad number of tracks (0 - 77).\n"); + exit(2); + } + dsize *= 26 * 128; + break; + case '?': + default: + usage(); + } + argc -= optind; + argv += optind; + + if (!hflag) { + file = open("floppy", O_RDWR|O_CREAT|O_TRUNC, 0666); + if (file < 0) { + printf("can't open \"floppy\"\n"); + exit(1); + } + for (count = dsize; count > 0 ; count -= 512) { + n = count > 512 ? 512 : count; + lread(startad, n, buff); + write(file, buff, n); + startad += 512; + } + } + if (rflag) + exit(0); + printf("Change Floppy, Hit return when done.\n"); + gets(buff); + lseek(file, 0, 0); + count = dsize; + startad = -26 * 128; + for ( ; count > 0 ; count -= 512) { + n = count > 512 ? 512 : count; + read(file, buff, n); + lwrite(startad, n, buff); + startad += 512; + } + exit(0); +} + +rt_init() +{ + static initized = 0; + int mode = 2; + + if (initized) + return; + if (rflag) + mode = 0; + initized = 1; + if ((floppydes = open(flopname, mode)) < 0) { + printf("Floppy open failed\n"); + exit(1); + } +} + +/* + * Logical to physical adress translation + */ +long +trans(logical) + register int logical; +{ + register int sector, bytes, track; + + logical += 26 * 128; + bytes = (logical & 127); + logical >>= 7; + sector = logical % 26; + if (sector >= 13) + sector = sector*2 +1; + else + sector *= 2; + sector += 26 + ((track = (logical / 26)) - 1) * 6; + sector %= 26; + return ((((track *26) + sector) << 7) + bytes); +} + +lread(startad, count, obuff) + register startad, count; + register char *obuff; +{ + long trans(); + extern floppydes; + + rt_init(); + while ((count -= 128) >= 0) { + lseek(floppydes, trans(startad), 0); + read(floppydes, obuff, 128); + obuff += 128; + startad += 128; + } +} + +lwrite(startad, count, obuff) + register startad, count; + register char *obuff; +{ + long trans(); + extern floppydes; + + rt_init(); + while ((count -= 128) >= 0) { + lseek(floppydes, trans(startad), 0); + write(floppydes, obuff, 128); + obuff += 128; + startad += 128; + } +} + +usage() +{ + (void)fprintf(stderr, "usage: flcopy [-hr] [-f file] [-t ntracks]\n"); + exit(1); +} diff --git a/usr.sbin/flcopy/pathnames.h b/usr.sbin/flcopy/pathnames.h new file mode 100644 index 000000000000..60b2df28a6b4 --- /dev/null +++ b/usr.sbin/flcopy/pathnames.h @@ -0,0 +1,36 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)pathnames.h 5.1 (Berkeley) 4/28/90 + */ + +#define _PATH_FLOPPY "/dev/floppy" |
