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.
10 * Jordan Hubbard. All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer,
17 * verbatim and that no modifications are made prior to this
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
23 * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 /* These routines deal with getting things off of tape media */
39 #include "sysinstall.h"
40 #include <sys/fcntl.h>
41 #include <sys/param.h>
43 static Boolean tapeInitted;
46 mediaTapeBlocksize(void)
48 char *cp = variable_get(VAR_TAPE_BLOCKSIZE);
50 return cp ? cp : DEFAULT_TAPE_BLOCKSIZE;
54 mediaInitTape(Device *dev)
56 /* This is REALLY gross, but we need to do the init later in get due to the fact
57 * that media is initialized BEFORE a filesystem is mounted now.
63 mediaGetTape(Device *dev, char *file, Boolean probe)
71 msgDebug("Tape init routine called for %s (private dir is %s)\n", dev->name, dev->private);
73 if (chdir(dev->private)) {
74 msgConfirm("Unable to CD to %s before extracting tape!\n"
75 "Tape media is not selected and thus cannot be installed from.", dev->private);
76 return (FILE *)IO_ERROR;
78 /* We know the tape is already in the drive, so go for it */
79 msgNotify("First extracting distributions from %s...", dev->description);
80 if (!strcmp(dev->name, "rft0"))
81 i = vsystem("ft | cpio -idum %s --block-size %s", cpioVerbosity(), mediaTapeBlocksize());
83 i = vsystem("cpio -idum %s --block-size %s -I %s", cpioVerbosity(), mediaTapeBlocksize(), dev->devname);
86 msgDebug("Tape initialized successfully.\n");
89 msgConfirm("Tape extract command failed with status %d!\n"
90 "Unable to use tape media.", i);
91 return (FILE *)IO_ERROR;
95 sprintf(buf, "%s/%s", (char *)dev->private, file);
97 msgDebug("Request for %s from tape (looking in %s)\n", file, buf);
98 if (file_readable(buf))
101 sprintf(buf, "%s/releases/%s", (char *)dev->private, file);
102 fp = fopen(buf, "r");
104 /* Nuke the files behind us to save space */
111 mediaShutdownTape(Device *dev)
115 if (file_readable((char *)dev->private)) {
116 msgNotify("Cleaning up results of tape extract in %s..",
117 (char *)dev->private);
118 (void)vsystem("rm -rf %s", (char *)dev->private);