From owner-freebsd-bugs@FreeBSD.ORG Tue Oct 7 12:50:10 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E424416A4B3 for ; Tue, 7 Oct 2003 12:50:10 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id CF3B943FE5 for ; Tue, 7 Oct 2003 12:50:08 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h97Jo8FY095958 for ; Tue, 7 Oct 2003 12:50:08 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h97Jo8dW095957; Tue, 7 Oct 2003 12:50:08 -0700 (PDT) (envelope-from gnats) Resent-Date: Tue, 7 Oct 2003 12:50:08 -0700 (PDT) Resent-Message-Id: <200310071950.h97Jo8dW095957@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, ob@breuninger.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C17F016A4B3 for ; Tue, 7 Oct 2003 12:45:10 -0700 (PDT) Received: from pop3.mail-relay.com (mail.mail-relay.com [194.49.77.201]) by mx1.FreeBSD.org (Postfix) with ESMTP id B5B8543FEA for ; Tue, 7 Oct 2003 12:45:03 -0700 (PDT) (envelope-from ob@pop3.mail-relay.com) Received: from pop3.mail-relay.com (localhost.partner.de [127.0.0.1]) by pop3.mail-relay.com (8.12.10/8.12.10) with ESMTP id h97Jj2qX094064 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Tue, 7 Oct 2003 21:45:02 +0200 (CEST) Received: (from ob@localhost) by pop3.mail-relay.com (8.12.10/8.12.10/Submit) id h97Jj2eZ094063; Tue, 7 Oct 2003 21:45:02 +0200 (CEST) Message-Id: <200310071945.h97Jj2eZ094063@pop3.mail-relay.com> Date: Tue, 7 Oct 2003 21:45:02 +0200 (CEST) From: ob@breuninger.org To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/57715: tcopy enhancement X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: ob@breuninger.org List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Oct 2003 19:50:11 -0000 >Number: 57715 >Category: bin >Synopsis: tcopy enhancement >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Tue Oct 07 12:50:07 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Oliver Breuninger >Release: FreeBSD 4.8-RELEASE i386 >Organization: >Environment: System: FreeBSD bs-tosh.breuninger.org 4.8-RELEASE FreeBSD 4.8-RELEASE #12: Thu Oct 2 18:42:17 CEST 2003 root@bs-tosh.breuninger.org:/usr/src/sys/compile/TOSHIBA i386 >Description: tcopy can be used to copy tape's from streamer to streamer. This modification enable you to copy from a tape to disk, with information of blocksizes: tcopy /dev/nsa0 . This produces files like: file-000.32768 file-001.32768 file-002.32768 file-003.32768 file-004.32768 file-005.32768 file-006.32768 file-007.32768 In this case is '.32768' the used blocksize on this tape. You can copy each file with dd to a other tape: dd if=file-000.32768 obs=64k conv=osync of=/dev/nsa0 This modification is helpful for recompilation of tapes and changing the blocksizes. >How-To-Repeat: >Fix: --- tcopy.c.orig Thu Nov 7 18:54:42 2002 +++ tcopy.c Tue Oct 7 15:14:07 2003 @@ -32,4 +32,8 @@ */ +/* + Modification 2000 Daniel Mack, Oliver Breuninger +*/ + #ifndef lint static const char copyright[] = @@ -86,5 +90,10 @@ int ch, needeof; char *buff, *inf; + struct stat statbuf; + char Dirname[0xff], FileName[0xff]; + int BlockSize; + bzero (Dirname, sizeof (Dirname)); + bzero (FileName, sizeof (FileName)); msg = stdout; guesslen = 1; @@ -130,7 +139,16 @@ op = COPY; inf = argv[0]; - if ((outp = open(argv[1], op == VERIFY ? O_RDONLY : - op == COPY ? O_WRONLY : O_RDWR, DEFFILEMODE)) < 0) - err(3, "%s", argv[1]); + + /* create file */ + if ((!stat (argv[1], &statbuf)) && (statbuf.st_mode & S_IFDIR)) { + sprintf (Dirname, "%s/tcopy.tmp", argv[1]); + if ((outp = open (Dirname, O_CREAT | O_RDWR, DEFFILEMODE)) < 0) + err (3, "%s", Dirname); + } + else { + if ((outp = open(argv[1], op == VERIFY ? O_RDONLY : + op == COPY ? O_WRONLY : O_RDWR, DEFFILEMODE)) < 0) + err(3, "%s", argv[1]); + } break; default: @@ -171,4 +189,5 @@ } if (nread != 0) + BlockSize = nread; fprintf(msg, "file %d: block size %d: ", filen, nread); @@ -180,7 +199,12 @@ if (op == COPY || op == COPYVERIFY) { if (needeof) { - writeop(outp, MTWEOF); - needeof = 0; - } + if (! strlen (Dirname)) { + writeop(outp, MTWEOF); + needeof = 0; + } + } + + /* fprintf(msg, "tcopy: block %qu\n", record); */ + nw = write(outp, buff, nread); if (nw != nread) { @@ -197,4 +221,14 @@ record++; } else { + if (strlen (Dirname)) { + nw = write(outp, buff, nread); + + sprintf (FileName, "%s/file-%03d.%d", argv[1], filen, BlockSize); + close (outp); + rename (Dirname, FileName); + if ((outp = open (Dirname, O_CREAT | O_RDWR, DEFFILEMODE)) < 0) + err (3, "%s", Dirname); + } + if (lastnread <= 0 && lastnread != NOCOUNT) { fprintf(msg, "eot\n"); @@ -211,10 +245,19 @@ } lastnread = nread; + } fprintf(msg, "total length: %qu bytes\n", tsize); (void)signal(SIGINT, oldsig); if (op == COPY || op == COPYVERIFY) { - writeop(outp, MTWEOF); - writeop(outp, MTWEOF); + if (strlen (Dirname)) { + close (outp); + remove (FileName); + remove (Dirname); + } + else { + writeop(outp, MTWEOF); + writeop(outp, MTWEOF); + } + if (op == COPYVERIFY) { rewind_tape(outp); >Release-Note: >Audit-Trail: >Unformatted: