2 * The new sysinstall program.
4 * This is probably the last attempt in the `sysinstall' line, the next
5 * generation being slated to essentially a complete rewrite.
7 * $FreeBSD: src/release/sysinstall/tape.c,v 1.22.2.1 2002/07/02 22:25:39 jhb Exp $
8 * $DragonFly: src/release/sysinstall/Attic/tape.c,v 1.2 2003/06/17 04:27:21 dillon Exp $
11 * Jordan Hubbard. All rights reserved.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer,
18 * verbatim and that no modifications are made prior to this
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
24 * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 /* These routines deal with getting things off of tape media */
40 #include "sysinstall.h"
41 #include <sys/fcntl.h>
42 #include <sys/param.h>
44 static Boolean tapeInitted;
47 mediaTapeBlocksize(void)
49 char *cp = variable_get(VAR_TAPE_BLOCKSIZE);
51 return cp ? cp : DEFAULT_TAPE_BLOCKSIZE;
55 mediaInitTape(Device *dev)
57 /* This is REALLY gross, but we need to do the init later in get due to the fact
58 * that media is initialized BEFORE a filesystem is mounted now.
64 mediaGetTape(Device *dev, char *file, Boolean probe)
72 WINDOW *w = savescr();
74 msgDebug("Tape init routine called for %s (private dir is %s)\n",
75 dev->name, (char *)dev->private);
77 if (chdir(dev->private)) {
78 msgConfirm("Unable to CD to %s before extracting tape!\n"
79 "Tape media is not selected and thus cannot be installed from.",
80 (char *)dev->private);
81 return (FILE *)IO_ERROR;
83 /* We know the tape is already in the drive, so go for it */
84 msgNotify("First extracting distributions from %s...", dev->description);
85 if (!strcmp(dev->name, "rft0"))
86 i = vsystem("ft | cpio -idum %s --block-size %s", cpioVerbosity(), mediaTapeBlocksize());
88 i = vsystem("cpio -idum %s --block-size %s -I %s", cpioVerbosity(), mediaTapeBlocksize(), dev->devname);
91 msgDebug("Tape initialized successfully.\n");
94 msgConfirm("Tape extract command failed with status %d!\n"
95 "Unable to use tape media.", i);
97 return (FILE *)IO_ERROR;
102 sprintf(buf, "%s/%s", (char *)dev->private, file);
104 msgDebug("Request for %s from tape (looking in %s)\n", file, buf);
105 if (file_readable(buf))
106 fp = fopen(buf, "r");
108 sprintf(buf, "%s/releases/%s", (char *)dev->private, file);
109 fp = fopen(buf, "r");
111 /* Nuke the files behind us to save space */
118 mediaShutdownTape(Device *dev)
122 if (file_readable((char *)dev->private)) {
123 msgDebug("Cleaning up results of tape extract in %s..",
124 (char *)dev->private);
125 (void)vsystem("rm -rf %s", (char *)dev->private);