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 WINDOW *w = savescr();
73 msgDebug("Tape init routine called for %s (private dir is %s)\n",
74 dev->name, (char *)dev->private);
76 if (chdir(dev->private)) {
77 msgConfirm("Unable to CD to %s before extracting tape!\n"
78 "Tape media is not selected and thus cannot be installed from.",
79 (char *)dev->private);
80 return (FILE *)IO_ERROR;
82 /* We know the tape is already in the drive, so go for it */
83 msgNotify("First extracting distributions from %s...", dev->description);
84 if (!strcmp(dev->name, "rft0"))
85 i = vsystem("ft | cpio -idum %s --block-size %s", cpioVerbosity(), mediaTapeBlocksize());
87 i = vsystem("cpio -idum %s --block-size %s -I %s", cpioVerbosity(), mediaTapeBlocksize(), dev->devname);
90 msgDebug("Tape initialized successfully.\n");
93 msgConfirm("Tape extract command failed with status %d!\n"
94 "Unable to use tape media.", i);
96 return (FILE *)IO_ERROR;
101 sprintf(buf, "%s/%s", (char *)dev->private, file);
103 msgDebug("Request for %s from tape (looking in %s)\n", file, buf);
104 if (file_readable(buf))
105 fp = fopen(buf, "r");
107 sprintf(buf, "%s/releases/%s", (char *)dev->private, file);
108 fp = fopen(buf, "r");
110 /* Nuke the files behind us to save space */
117 mediaShutdownTape(Device *dev)
121 if (file_readable((char *)dev->private)) {
122 msgDebug("Cleaning up results of tape extract in %s..\n",
123 (char *)dev->private);
124 (void)vsystem("rm -rf %s", (char *)dev->private);