Date: Sun, 3 Sep 2000 02:54:27 +0200 (CEST) From: ob@seicom.net To: FreeBSD-gnats-submit@freebsd.org Subject: ports/21003: New Port, modification of tcopy Message-ID: <200009030054.CAA74217@hq.seicom.net>
next in thread | raw e-mail | index | archive | help
>Number: 21003 >Category: ports >Synopsis: New Port, modification of tcopy >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Sep 02 18:00:01 PDT 2000 >Closed-Date: >Last-Modified: >Originator: Oliver Breuninger >Release: FreeBSD 4.1-RELEASE i386 >Organization: >Environment: >Description: # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # tcopy2 # tcopy2/patches # tcopy2/patches/patch-aa # tcopy2/patches/patch-ab # tcopy2/patches/patch-ac # tcopy2/pkg # tcopy2/pkg/COMMENT # tcopy2/pkg/DESCR # tcopy2/pkg/PLIST # tcopy2/src # tcopy2/src/Makefile # tcopy2/src/pathnames.h # tcopy2/src/tcopy.1 # tcopy2/src/tcopy.c # tcopy2/Makefile # echo c - tcopy2 mkdir -p tcopy2 > /dev/null 2>&1 echo c - tcopy2/patches mkdir -p tcopy2/patches > /dev/null 2>&1 echo x - tcopy2/patches/patch-aa sed 's/^X//' >tcopy2/patches/patch-aa << 'END-of-tcopy2/patches/patch-aa' X--- Makefile.orig Sun Sep 3 02:30:57 2000 X+++ Makefile Sun Sep 3 02:32:41 2000 X@@ -1,5 +1,9 @@ X # @(#)Makefile 8.1 (Berkeley) 6/6/93 X X-PROG= tcopy X+PROG= tcopy2 X+SRCS= tcopy2.c X+BINDIR= ${PREFIX}/bin X+SHAREDIR= ${PREFIX} X X .include <bsd.prog.mk> X+ END-of-tcopy2/patches/patch-aa echo x - tcopy2/patches/patch-ab sed 's/^X//' >tcopy2/patches/patch-ab << 'END-of-tcopy2/patches/patch-ab' X--- tcopy2.1.orig Sun Sep 3 01:50:07 2000 X+++ tcopy2.1 Tue Aug 1 22:44:12 2000 X@@ -34,8 +34,8 @@ X .\" X .Dd April 17, 1994 X-.Dt TCOPY 1 X+.Dt TCOPY2 1 X .Os BSD 4.3 X .Sh NAME X-.Nm tcopy X+.Nm tcopy2 X .Nd copy and/or verify mag tapes X .Sh SYNOPSIS X@@ -46,8 +46,8 @@ X .Oc X .Sh DESCRIPTION X-.Nm Tcopy X+.Nm Tcopy2 X is designed to copy magnetic tapes. The only assumption made X about the tape is that there are two tape marks at the end. X-.Nm Tcopy X+.Nm Tcopy2 X with only a source tape X .Pf ( Ar /dev/rsa0 X@@ -98,9 +98,9 @@ X There are old systems which typically wrote three EOF's between tape X files. X-.Xr tcopy 1 X+.Xr tcopy2 1 X will erroneously stop copying early in this case. X X When using the copy/verify option \-c X-.Xr tcopy 1 X+.Xr tcopy2 1 X does not rewind the tapes prior to start. X A rewind is performed END-of-tcopy2/patches/patch-ab echo x - tcopy2/patches/patch-ac sed 's/^X//' >tcopy2/patches/patch-ac << 'END-of-tcopy2/patches/patch-ac' X--- tcopy2.c.orig Sun Sep 3 01:50:07 2000 X+++ tcopy2.c Wed Aug 9 10:18:30 2000 X@@ -1,3 +1,6 @@ X /* X+ X+ Modification 2000 Daniel Mack, Oliver Breuninger X+ X * Copyright (c) 1985, 1987, 1993 X * The Regents of the University of California. All rights reserved. X@@ -40,5 +43,5 @@ X #ifndef lint X #if 0 X-static char sccsid[] = "@(#)tcopy.c 8.2 (Berkeley) 4/17/94"; X+static char sccsid[] = "@(#)tcopy2.c 8.2 (Berkeley) 4/17/94"; X #endif X static const char rcsid[] = X@@ -86,5 +89,10 @@ X int ch, needeof; X char *buff, *inf; X+ struct stat statbuf; X+ char Dirname[0xff], FileName[0xff]; X+ int BlockSize; X X+ bzero (Dirname, sizeof (Dirname)); X+ bzero (FileName, sizeof (FileName)); X guesslen = 1; X while ((ch = getopt(argc, argv, "cs:vx")) != -1) X@@ -129,7 +137,16 @@ X op = COPY; X inf = argv[0]; X- if ((outp = open(argv[1], op == VERIFY ? O_RDONLY : X- op == COPY ? O_WRONLY : O_RDWR, DEFFILEMODE)) < 0) X- err(3, "%s", argv[1]); X+ X+ /* create file */ X+ if ((!stat (argv[1], &statbuf)) && (statbuf.st_mode & S_IFDIR)) { X+ sprintf (Dirname, "%s/tcopy2.tmp", argv[1]); X+ if ((outp = open (Dirname, O_CREAT | O_RDWR, DEFFILEMODE)) < 0) X+ err (3, "%s", Dirname); X+ } X+ else { X+ if ((outp = open(argv[1], op == VERIFY ? O_RDONLY : X+ op == COPY ? O_WRONLY : O_RDWR, DEFFILEMODE)) < 0) X+ err(3, "%s", argv[1]); X+ } X break; X default: X@@ -170,4 +187,5 @@ X } X if (nread != 0) X+ BlockSize = nread; X fprintf(msg, "file %d: block size %d: ", X filen, nread); X@@ -179,7 +197,12 @@ X if (op == COPY || op == COPYVERIFY) { X if (needeof) { X- writeop(outp, MTWEOF); X- needeof = 0; X- } X+ if (! strlen (Dirname)) { X+ writeop(outp, MTWEOF); X+ needeof = 0; X+ } X+ } X+ X+ /* fprintf(msg, "tcopy2: block %qu\n", record); */ X+ X nw = write(outp, buff, nread); X if (nw != nread) { X@@ -196,4 +219,14 @@ X record++; X } else { X+ if (strlen (Dirname)) { X+ nw = write(outp, buff, nread); X+ X+ sprintf (FileName, "%s/file-%03d.%d", argv[1], filen, BlockSize); X+ close (outp); X+ rename (Dirname, FileName); X+ if ((outp = open (Dirname, O_CREAT | O_RDWR, DEFFILEMODE)) < 0) X+ err (3, "%s", Dirname); X+ } X+ X if (lastnread <= 0 && lastnread != NOCOUNT) { X fprintf(msg, "eot\n"); X@@ -210,10 +243,19 @@ X } X lastnread = nread; X+ X } X fprintf(msg, "total length: %qu bytes\n", tsize); X (void)signal(SIGINT, oldsig); X if (op == COPY || op == COPYVERIFY) { X- writeop(outp, MTWEOF); X- writeop(outp, MTWEOF); X+ if (strlen (Dirname)) { X+ close (outp); X+ remove (FileName); X+ remove (Dirname); X+ } X+ else { X+ writeop(outp, MTWEOF); X+ writeop(outp, MTWEOF); X+ } X+ X if (op == COPYVERIFY) { X rewind_tape(outp); X@@ -259,10 +301,10 @@ X fprintf(msg, X "%s: tapes have different block sizes; %d != %d.\n", X- "tcopy", inn, outn); X+ "tcopy2", inn, outn); X break; X } X if (!inn) { X if (eot++) { X- fprintf(msg, "tcopy: tapes are identical.\n"); X+ fprintf(msg, "tcopy2: tapes are identical.\n"); X return; X } X@@ -270,5 +312,5 @@ X if (bcmp(inb, outb, inn)) { X fprintf(msg, X- "tcopy: tapes have different data.\n"); X+ "tcopy2: tapes have different data.\n"); X break; X } X@@ -320,5 +362,5 @@ X usage() X { X- fprintf(stderr, "usage: tcopy [-cvx] [-s maxblk] [src [dest]]\n"); X+ fprintf(stderr, "usage: tcopy2 [-cvx] [-s maxblk] [src [dest]]\n"); X exit(1); X } END-of-tcopy2/patches/patch-ac echo c - tcopy2/pkg mkdir -p tcopy2/pkg > /dev/null 2>&1 echo x - tcopy2/pkg/COMMENT sed 's/^X//' >tcopy2/pkg/COMMENT << 'END-of-tcopy2/pkg/COMMENT' XModified version of tcopy to copy tapes to directory. END-of-tcopy2/pkg/COMMENT echo x - tcopy2/pkg/DESCR sed 's/^X//' >tcopy2/pkg/DESCR << 'END-of-tcopy2/pkg/DESCR' X Xtcopy isn't able to copy tape files to disk in a usable form. X XIf the parameter is a directory, then copies tcopy2 the tape filesn into Xthis directory. X END-of-tcopy2/pkg/DESCR echo x - tcopy2/pkg/PLIST sed 's/^X//' >tcopy2/pkg/PLIST << 'END-of-tcopy2/pkg/PLIST' Xbin/tcopy2 Xman/man1/tcopy2.1.gz END-of-tcopy2/pkg/PLIST echo c - tcopy2/src mkdir -p tcopy2/src > /dev/null 2>&1 echo x - tcopy2/src/Makefile sed 's/^X//' >tcopy2/src/Makefile << 'END-of-tcopy2/src/Makefile' X# @(#)Makefile 8.1 (Berkeley) 6/6/93 X XPROG= tcopy X X.include <bsd.prog.mk> END-of-tcopy2/src/Makefile echo x - tcopy2/src/pathnames.h sed 's/^X//' >tcopy2/src/pathnames.h << 'END-of-tcopy2/src/pathnames.h' X/* X * Copyright (c) 1989, 1993 X * The Regents of the University of California. All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. All advertising materials mentioning features or use of this software X * must display the following acknowledgement: X * This product includes software developed by the University of X * California, Berkeley and its contributors. X * 4. Neither the name of the University nor the names of its contributors X * may be used to endorse or promote products derived from this software X * without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X * SUCH DAMAGE. X * X * @(#)pathnames.h 8.1 (Berkeley) 6/6/93 X */ X X#define _PATH_DEFTAPE "/dev/rsa0" END-of-tcopy2/src/pathnames.h echo x - tcopy2/src/tcopy.1 sed 's/^X//' >tcopy2/src/tcopy.1 << 'END-of-tcopy2/src/tcopy.1' X.\" Copyright (c) 1985, 1990, 1991, 1993 X.\" The Regents of the University of California. All rights reserved. X.\" X.\" Redistribution and use in source and binary forms, with or without X.\" modification, are permitted provided that the following conditions X.\" are met: X.\" 1. Redistributions of source code must retain the above copyright X.\" notice, this list of conditions and the following disclaimer. X.\" 2. Redistributions in binary form must reproduce the above copyright X.\" notice, this list of conditions and the following disclaimer in the X.\" documentation and/or other materials provided with the distribution. X.\" 3. All advertising materials mentioning features or use of this software X.\" must display the following acknowledgement: X.\" This product includes software developed by the University of X.\" California, Berkeley and its contributors. X.\" 4. Neither the name of the University nor the names of its contributors X.\" may be used to endorse or promote products derived from this software X.\" without specific prior written permission. X.\" X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X.\" SUCH DAMAGE. X.\" X.\" @(#)tcopy.1 8.2 (Berkeley) 4/17/94 X.\" $FreeBSD: src/usr.bin/tcopy/tcopy.1,v 1.7 2000/03/01 12:20:12 sheldonh Exp $ X.\" X.Dd April 17, 1994 X.Dt TCOPY 1 X.Os BSD 4.3 X.Sh NAME X.Nm tcopy X.Nd copy and/or verify mag tapes X.Sh SYNOPSIS X.Nm X.Op Fl cvx X.Op Fl s Ar maxblk X.Oo Ar src Op Ar dest X.Oc X.Sh DESCRIPTION X.Nm Tcopy Xis designed to copy magnetic tapes. The only assumption made Xabout the tape is that there are two tape marks at the end. X.Nm Tcopy Xwith only a source tape X.Pf ( Ar /dev/rsa0 Xby default) specified will print Xinformation about the sizes of records and tape files. If a destination Xis specified a copy will be made of the source tape. The blocking on the Xdestination tape will be identical to that used on the source tape. Copying Xa tape will yield the same output as if just printing the sizes. X.Pp XOptions: X.Bl -tag -width s_maxblk X.It Fl c XCopy X.Ar src Xto X.Ar dest Xand then verify that the two tapes are identical. X.It Fl s Ar maxblk XSpecify a maximum block size, X.Ar maxblk . X.It Fl v XGiven the two tapes, X.ar src Xand X.Ar dest Xverify that they are identical. X.It Fl x XOutput all informational messages to the standard error. XThis option is useful when X.Ar dest Xis X.Pa /dev/stdout . X.El X.Sh SEE ALSO X.Xr mtio 4 X.Sh HISTORY XThe X.Nm Xcommand appeared in X.Bx 4.3 . X.Sh BUGS XWritting an image of a tape to a file does not preserve much more than Xthe raw data. XBlock size(s) and tape EOF marks are lost which would Xotherwise be preserved in a tape-to-tape copy. X XEOD is determined by two sequential EOF marks with no data between. XThere are old systems which typically wrote three EOF's between tape Xfiles. X.Xr tcopy 1 Xwill erroneously stop copying early in this case. X XWhen using the copy/verify option \-c X.Xr tcopy 1 Xdoes not rewind the tapes prior to start. XA rewind is performed Xafter writing prior to the verification stage. XIf one doesn't start Xat BOT then the comparison may not be of the intended data. END-of-tcopy2/src/tcopy.1 echo x - tcopy2/src/tcopy.c sed 's/^X//' >tcopy2/src/tcopy.c << 'END-of-tcopy2/src/tcopy.c' X/* X * Copyright (c) 1985, 1987, 1993 X * The Regents of the University of California. All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. All advertising materials mentioning features or use of this software X * must display the following acknowledgement: X * This product includes software developed by the University of X * California, Berkeley and its contributors. X * 4. Neither the name of the University nor the names of its contributors X * may be used to endorse or promote products derived from this software X * without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X * SUCH DAMAGE. X */ X X#ifndef lint Xstatic const char copyright[] = X"@(#) Copyright (c) 1985, 1987, 1993\n\ X The Regents of the University of California. All rights reserved.\n"; X#endif /* not lint */ X X#ifndef lint X#if 0 Xstatic char sccsid[] = "@(#)tcopy.c 8.2 (Berkeley) 4/17/94"; X#endif Xstatic const char rcsid[] = X "$FreeBSD: src/usr.bin/tcopy/tcopy.c,v 1.7 1999/08/28 01:06:20 peter Exp $"; X#endif /* not lint */ X X#include <sys/types.h> X#include <sys/stat.h> X#include <sys/ioctl.h> X#include <sys/mtio.h> X X#include <err.h> X#include <errno.h> X#include <fcntl.h> X#include <signal.h> X#include <stdio.h> X#include <stdlib.h> X#include <string.h> X#include <unistd.h> X X#include "pathnames.h" X X#define MAXREC (64 * 1024) X#define NOCOUNT (-2) X Xint filen, guesslen, maxblk = MAXREC; Xu_int64_t lastrec, record, size, tsize; XFILE *msg = stdout; X Xvoid *getspace __P((int)); Xvoid intr __P((int)); Xstatic void usage __P((void)); Xvoid verify __P((int, int, char *)); Xvoid writeop __P((int, int)); Xvoid rewind_tape(int); X Xint Xmain(argc, argv) X int argc; X char *argv[]; X{ X register int lastnread, nread, nw, inp, outp; X enum {READ, VERIFY, COPY, COPYVERIFY} op = READ; X sig_t oldsig; X int ch, needeof; X char *buff, *inf; X X guesslen = 1; X while ((ch = getopt(argc, argv, "cs:vx")) != -1) X switch((char)ch) { X case 'c': X op = COPYVERIFY; X break; X case 's': X maxblk = atoi(optarg); X if (maxblk <= 0) { X warnx("illegal block size"); X usage(); X } X guesslen = 0; X break; X case 'v': X op = VERIFY; X break; X case 'x': X msg = stderr; X break; X case '?': X default: X usage(); X } X argc -= optind; X argv += optind; X X switch(argc) { X case 0: X if (op != READ) X usage(); X inf = _PATH_DEFTAPE; X break; X case 1: X if (op != READ) X usage(); X inf = argv[0]; X break; X case 2: X if (op == READ) X op = COPY; X inf = argv[0]; X if ((outp = open(argv[1], op == VERIFY ? O_RDONLY : X op == COPY ? O_WRONLY : O_RDWR, DEFFILEMODE)) < 0) X err(3, "%s", argv[1]); X break; X default: X usage(); X } X X if ((inp = open(inf, O_RDONLY, 0)) < 0) X err(1, "%s", inf); X X buff = getspace(maxblk); X X if (op == VERIFY) { X verify(inp, outp, buff); X exit(0); X } X X if ((oldsig = signal(SIGINT, SIG_IGN)) != SIG_IGN) X (void) signal(SIGINT, intr); X X needeof = 0; X for (lastnread = NOCOUNT;;) { X if ((nread = read(inp, buff, maxblk)) == -1) { X while (errno == EINVAL && (maxblk -= 1024)) { X nread = read(inp, buff, maxblk); X if (nread >= 0) X goto r1; X } X err(1, "read error, file %d, record %qu", filen, record); X } else if (nread != lastnread) { X if (lastnread != 0 && lastnread != NOCOUNT) { X if (lastrec == 0 && nread == 0) X fprintf(msg, "%qu records\n", record); X else if (record - lastrec > 1) X fprintf(msg, "records %qu to %qu\n", X lastrec, record); X else X fprintf(msg, "record %qu\n", lastrec); X } X if (nread != 0) X fprintf(msg, "file %d: block size %d: ", X filen, nread); X (void) fflush(stdout); X lastrec = record; X } Xr1: guesslen = 0; X if (nread > 0) { X if (op == COPY || op == COPYVERIFY) { X if (needeof) { X writeop(outp, MTWEOF); X needeof = 0; X } X nw = write(outp, buff, nread); X if (nw != nread) { X if (nw == -1) { X warn("write error, file %d, record %qu", filen, record); X } else { X warnx("write error, file %d, record %qu", filen, record); X warnx("write (%d) != read (%d)", nw, nread); X } X errx(5, "copy aborted"); X } X } X size += nread; X record++; X } else { X if (lastnread <= 0 && lastnread != NOCOUNT) { X fprintf(msg, "eot\n"); X break; X } X fprintf(msg, X "file %d: eof after %qu records: %qu bytes\n", X filen, record, size); X needeof = 1; X filen++; X tsize += size; X size = record = lastrec = 0; X lastnread = 0; X } X lastnread = nread; X } X fprintf(msg, "total length: %qu bytes\n", tsize); X (void)signal(SIGINT, oldsig); X if (op == COPY || op == COPYVERIFY) { X writeop(outp, MTWEOF); X writeop(outp, MTWEOF); X if (op == COPYVERIFY) { X rewind_tape(outp); X rewind_tape(inp); X verify(inp, outp, buff); X } X } X exit(0); X} X Xvoid Xverify(inp, outp, outb) X register int inp, outp; X register char *outb; X{ X register int eot, inmaxblk, inn, outmaxblk, outn; X register char *inb; X X inb = getspace(maxblk); X inmaxblk = outmaxblk = maxblk; X for (eot = 0;; guesslen = 0) { X if ((inn = read(inp, inb, inmaxblk)) == -1) { X if (guesslen) X while (errno == EINVAL && (inmaxblk -= 1024)) { X inn = read(inp, inb, inmaxblk); X if (inn >= 0) X goto r1; X } X warn("read error"); X break; X } Xr1: if ((outn = read(outp, outb, outmaxblk)) == -1) { X if (guesslen) X while (errno == EINVAL && (outmaxblk -= 1024)) { X outn = read(outp, outb, outmaxblk); X if (outn >= 0) X goto r2; X } X warn("read error"); X break; X } Xr2: if (inn != outn) { X fprintf(msg, X "%s: tapes have different block sizes; %d != %d.\n", X "tcopy", inn, outn); X break; X } X if (!inn) { X if (eot++) { X fprintf(msg, "tcopy: tapes are identical.\n"); X return; X } X } else { X if (bcmp(inb, outb, inn)) { X fprintf(msg, X "tcopy: tapes have different data.\n"); X break; X } X eot = 0; X } X } X exit(1); X} X Xvoid Xintr(signo) X int signo; X{ X if (record) { X if (record - lastrec > 1) X fprintf(msg, "records %qu to %qu\n", lastrec, record); X else X fprintf(msg, "record %qu\n", lastrec); X } X fprintf(msg, "interrupt at file %d: record %qu\n", filen, record); X fprintf(msg, "total length: %ld bytes\n", tsize + size); X exit(1); X} X Xvoid * Xgetspace(blk) X int blk; X{ X void *bp; X X if ((bp = malloc((size_t)blk)) == NULL) X errx(11, "no memory"); X return (bp); X} X Xvoid Xwriteop(fd, type) X int fd, type; X{ X struct mtop op; X X op.mt_op = type; X op.mt_count = (daddr_t)1; X if (ioctl(fd, MTIOCTOP, (char *)&op) < 0) X err(6, "tape op"); X} X Xstatic void Xusage() X{ X fprintf(stderr, "usage: tcopy [-cvx] [-s maxblk] [src [dest]]\n"); X exit(1); X} X Xvoid Xrewind_tape(int fd) X{ X struct stat sp; X X if(fstat(fd, &sp)) X errx(12, "fstat in rewind"); X X /* X * don't want to do tape ioctl on regular files: X */ X if( S_ISREG(sp.st_mode) ) { X if( lseek(fd, 0, SEEK_SET) == -1 ) X errx(13, "lseek"); X } else X /* assume its a tape */ X writeop(fd, MTREW); X} END-of-tcopy2/src/tcopy.c echo x - tcopy2/Makefile sed 's/^X//' >tcopy2/Makefile << 'END-of-tcopy2/Makefile' X# New ports collection makefile for: tcopy2 X# Date created: 1 August 2000 X# Whom: Oliver Breuninger <ob@seicom.net> X# X# $FreeBSD: ports/benchmarks/tcpblast/Makefile,v 1.17 2000/04/16 21:08:02 mharo Exp $ X# X# port's source files are in src dir in portball X XPORTNAME= tcopy2 XPORTVERSION= 1.0 XCATEGORIES= sysutils XDISTFILES= # none X XMAINTAINER= ports@FreeBSD.org X XWRKSRC= ${WRKDIR}/src X Xdo-extract: X @${RM} -rf ${WRKDIR} X @${MKDIR} ${WRKDIR} X @${MKDIR} ${WRKSRC} X# ${CP} -RP ${.CURDIR}/src ${WRKDIR} X ${CP} -RP ${.CURDIR}/src/Makefile ${WRKSRC} X ${CP} -RP ${.CURDIR}/src/pathnames.h ${WRKSRC} X ${CP} -RP ${.CURDIR}/src/tcopy.1 ${WRKSRC}/tcopy2.1 X ${CP} -RP ${.CURDIR}/src/tcopy.c ${WRKSRC}/tcopy2.c X X.include <bsd.port.mk> X END-of-tcopy2/Makefile exit >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200009030054.CAA74217>