aboutsummaryrefslogtreecommitdiff
path: root/sbin/i386
diff options
context:
space:
mode:
authorPhilippe Charnier <charnier@FreeBSD.org>1998-06-30 06:22:08 +0000
committerPhilippe Charnier <charnier@FreeBSD.org>1998-06-30 06:22:08 +0000
commiteec2e675fcb12817e1cea53c685574a5c9846f43 (patch)
tree31fc9fcf98c028b63fe005b1bc3f84c925d6a43a /sbin/i386
parentc27b7bad4a10c012927ca25c85879876fa484301 (diff)
downloadsrc-eec2e675fcb12817e1cea53c685574a5c9846f43.tar.gz
src-eec2e675fcb12817e1cea53c685574a5c9846f43.zip
Document -r flag, document use of TAPE env variable. Add rcsid. Use err(3).
Remove unused vars (-Wall).
Notes
Notes: svn path=/head/; revision=37276
Diffstat (limited to 'sbin/i386')
-rw-r--r--sbin/i386/ft/ft.822
-rw-r--r--sbin/i386/ft/ft.c88
-rw-r--r--sbin/i386/ft/ftecc.c6
3 files changed, 67 insertions, 49 deletions
diff --git a/sbin/i386/ft/ft.8 b/sbin/i386/ft/ft.8
index 18449deb6f6f..986bb9267e18 100644
--- a/sbin/i386/ft/ft.8
+++ b/sbin/i386/ft/ft.8
@@ -10,7 +10,7 @@
.\" 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:
+.\" must display the following acknowledgment:
.\" 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
@@ -30,6 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)ft.8
+.\" $Id$
.\"
.Dd February 7, 1994
.Dt FT 8
@@ -40,15 +41,30 @@
.Sh SYNOPSIS
.Nm ft
.Op Fl f Ar tape
+.Op Fl r
.Op Ar description
.Sh DESCRIPTION
The
-.Nm ft
+.Nm
command allows multi-volume dump, extract, and view of tape labels, for
any pre-formatted QIC-40/80 tapes. It is totally system dependent,
and has nothing to do with the QIC standards.
.Pp
-.Nm ft
+The following options are available:
+.Bl -tag -width indent
+.It Fl f Ar tape
+Read or write the specified
+.Ar tape
+(default is
+.Pa /dev/rft0
+unless the environment variable
+.Ev TAPE
+is set).
+.It Fl r
+Do retension tape.
+.El
+.Pp
+.Nm Ft
is used primarily as a filter for tape i/o.
For example, to save and compress the
.Pa /usr
diff --git a/sbin/i386/ft/ft.c b/sbin/i386/ft/ft.c
index 3df36e581d84..41591a4239f9 100644
--- a/sbin/i386/ft/ft.c
+++ b/sbin/i386/ft/ft.c
@@ -31,14 +31,21 @@
* 09/02/93 v0.2 pl01
* Initial revision.
*
- * usage: ft [ -f tape ] [ description ]
+ * usage: ft [ -f tape ] [ -r ] [ description ]
*/
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
+#include <err.h>
+#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <signal.h>
#include <time.h>
+#include <unistd.h>
#include <sys/ftape.h>
#define DEFQIC "/dev/rft0"
@@ -73,7 +80,7 @@ int doretension = 0; /* TRUE if we should retension tape */
void
usage(void)
{
- fprintf(stderr, "usage: ft [ -r ] [ -f device ] [ \"description\" ]\n");
+ fprintf(stderr, "usage: ft [-f device] [-r] [\"description\"]\n");
exit(1);
}
@@ -84,35 +91,35 @@ usage(void)
int
check_stat(int fd, int wr)
{
- int r, s;
+ int s;
int sawit = 0;
/* get tape status */
if (ioctl(fd, QIOSTATUS, &s) < 0) {
- fprintf(stderr, "could not get drive status\n");
+ warnx("could not get drive status");
return(1);
}
/* wait for the tape drive to become ready */
while ((s & QS_READY) == 0) {
if (!sawit) {
- fprintf(stderr, "waiting for drive to become ready...\n");
+ warnx("waiting for drive to become ready");
sawit = 1;
}
sleep(2);
if (ioctl(fd, QIOSTATUS, &s) < 0) {
- fprintf(stderr, "could not get drive status\n");
+ warnx("could not get drive status");
return(1);
}
}
if ((s & QS_FMTOK) == 0) {
- fprintf(stderr, "tape is not formatted\n");
+ warnx("tape is not formatted");
return(2);
}
if (wr && (s & QS_RDONLY) != 0) {
- fprintf(stderr, "tape is write protected\n");
+ warnx("tape is write protected");
return(3);
}
@@ -186,12 +193,12 @@ char *qstr(char *str, int nchar)
int
get_header(int fd)
{
- int r, sn, bytes;
+ int r, sn;
QIC_Segment s;
int gothdr = 0;
if (ioctl(fd, QIOGEOM, &geo) < 0) {
- fprintf(stderr, "couldn't determine tape geometry\n");
+ warnx("couldn't determine tape geometry");
return(1);
}
@@ -208,7 +215,7 @@ get_header(int fd)
if (hsn >= 0) {
dhsn = sn;
if (!r && !gothdr) {
- fprintf(stderr, "using secondary header\n");
+ warnx("using secondary header");
bcopy(s.sg_data, hbuff, QCV_SEGSIZE);
gothdr = 1;
}
@@ -219,13 +226,13 @@ get_header(int fd)
bcopy(s.sg_data, hbuff, QCV_SEGSIZE);
gothdr = 1;
} else {
- fprintf(stderr, "too many errors in primary header\n");
+ warnx("too many errors in primary header");
}
}
}
if (!gothdr) {
- fprintf(stderr, "couldn't read header segment\n");
+ warnx("couldn't read header segment");
ioctl(fd, QIOREWIND);
return(1);
}
@@ -237,16 +244,14 @@ get_header(int fd)
/*
* Open /dev/tty and ask for next volume.
*/
+void
ask_vol(int vn)
{
- FILE *inp;
int fd;
char c;
- if ((fd = open("/dev/tty", 2)) < 0) {
- fprintf(stderr, "argh!! can't open /dev/tty\n");
- exit(1);
- }
+ if ((fd = open("/dev/tty", 2)) < 0)
+ errx(1, "argh!! can't open /dev/tty");
fprintf(stderr, "Insert ftfilt volume %02d and press enter:", vn);
read(fd, &c, 1);
@@ -273,7 +278,7 @@ do_getname(void)
void
do_read(void)
{
- int sno, vno, sbytes, r, eccfails;
+ int sno, vno, sbytes, eccfails;
long curpos;
char *hname;
QIC_Segment s;
@@ -330,13 +335,12 @@ do_read(void)
if (check_parity(s.sg_data, s.sg_badmap, s.sg_crcmap)) {
if (++eccfails <= 5) {
- fprintf(stderr,
- "ft: retry %d at segment %d byte %ld\n",
+ warnx("retry %d at segment %d byte %ld",
eccfails, sno, curpos);
continue;
} else
- fprintf(stderr,
- "ft: *** ecc failure in segment %d at byte %ld\n",
+ warnx(
+ "*** ecc failure in segment %d at byte %ld",
sno, curpos);
}
if (tvsize < sbytes) sbytes = tvsize;
@@ -360,7 +364,7 @@ void
do_write(void)
{
int sno, vno, amt, sbytes;
- int c, maxseg, r;
+ int maxseg, r;
ULONG qnow;
QIC_Segment s;
char tmpstr[80];
@@ -414,11 +418,9 @@ do_write(void)
if (amt < sbytes)
bzero(&s.sg_data[amt], sbytes - amt);
r = set_parity(s.sg_data, s.sg_badmap);
- if (r) fprintf(stderr, "** warning: ecc problem !!\n");
- if (ioctl(tfd, QIOWRITE, &s) < 0) {
- perror("QIOWRITE");
- exit(1);
- }
+ if (r) warnx("** warning: ecc problem !!");
+ if (ioctl(tfd, QIOWRITE, &s) < 0)
+ err(1, "QIOWRITE");
tvsize += amt;
}
}
@@ -439,11 +441,9 @@ do_write(void)
s.sg_badmap = 0;
s.sg_data = (UCHAR *)hbuff;
r = set_parity(s.sg_data, s.sg_badmap);
- if (r) fprintf(stderr, "** warning: header ecc problem !!\n");
- if (ioctl(tfd, QIOWRITE, &s) < 0) {
- perror("QIOWRITE");
- exit(1);
- }
+ if (r) warnx("** warning: header ecc problem !!");
+ if (ioctl(tfd, QIOWRITE, &s) < 0)
+ err(1, "QIOWRITE");
}
if (dhsn >= 0) {
s.sg_trk = dhsn / geo.g_segtrk;
@@ -451,11 +451,9 @@ do_write(void)
s.sg_badmap = 0;
s.sg_data = (UCHAR *)hbuff;
r = set_parity(s.sg_data, s.sg_badmap);
- if (r) fprintf(stderr, "** warning: duphdr ecc problem !!\n");
- if (ioctl(tfd, QIOWRITE, &s) < 0) {
- perror("QIOWRITE");
- exit(1);
- }
+ if (r) warnx("** warning: duphdr ecc problem !!");
+ if (ioctl(tfd, QIOWRITE, &s) < 0)
+ err(1, "QIOWRITE");
}
ioctl(tfd, QIOREWIND);
if (tvlast) break;
@@ -467,10 +465,10 @@ do_write(void)
/*
* Entry.
*/
-void
+int
main(int argc, char *argv[])
{
- int r, s, i;
+ int i;
char *tape, *getenv();
@@ -500,10 +498,8 @@ main(int argc, char *argv[])
}
/* Open the tape device */
- if ((tfd = open(tape, 2)) < 0) {
- perror(tape);
- exit(1);
- }
+ if ((tfd = open(tape, 2)) < 0)
+ err(1, "%s", tape);
if (!isatty(0))
do_write();
diff --git a/sbin/i386/ft/ftecc.c b/sbin/i386/ft/ftecc.c
index 95de073620de..abc6d438d767 100644
--- a/sbin/i386/ft/ftecc.c
+++ b/sbin/i386/ft/ftecc.c
@@ -29,6 +29,12 @@
* Modified slightly to fit with my driver. Based entirely upon David
* L. Brown's package.
*/
+
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
#include <sys/ftape.h>
/* Inverse matrix */