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 * Gary J Palmer. All rights reserved.
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer,
19 * verbatim and that no modifications are made prior to this
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
25 * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 /* These routines deal with getting things off of CDROM media */
41 #include "sysinstall.h"
43 #include <sys/errno.h>
44 #include <sys/param.h>
52 #include <sys/mount.h>
53 #include <isofs/cd9660/cd9660_mount.h>
56 static Boolean cdromMounted;
57 static char mountpoint[] = "/dist";
60 read_props(char *name)
65 fd = open(name, O_RDONLY);
68 n = properties_read(fd);
74 mediaInitCDROM(Device *dev)
77 properties cd_attr = NULL;
79 Boolean readInfo = TRUE;
80 static Boolean bogusCDOK = FALSE;
86 bzero(&args, sizeof(args));
87 args.fspec = dev->devname;
89 if (mount("cd9660", mountpoint, MNT_RDONLY, (caddr_t) &args) == -1) {
90 if (errno == EINVAL) {
91 msgConfirm("The CD in your drive looks more like an Audio CD than a FreeBSD release.");
94 else if (errno != EBUSY) {
95 msgConfirm("Error mounting %s on %s: %s (%u)", dev->devname, mountpoint, strerror(errno), errno);
101 if (!file_readable(string_concat(mountpoint, "/cdrom.inf")) && !bogusCDOK) {
102 if (msgYesNo("Warning: The CD currently in the drive is either not a FreeBSD\n"
103 "CD or it is an older (pre 2.1.5) FreeBSD CD which does not\n"
104 "have a version number on it. Do you wish to use this CD anyway?") != 0) {
105 unmount(mountpoint, MNT_FORCE);
106 cdromMounted = FALSE;
116 if (!(cd_attr = read_props(string_concat(mountpoint, "/cdrom.inf")))
117 || !(cp = property_find(cd_attr, "CD_VERSION"))) {
118 msgConfirm("Unable to find a %s/cdrom.inf file.\n"
119 "Either this is not a FreeBSD CDROM, there is a problem with\n"
120 "the CDROM driver or something is wrong with your hardware.\n"
121 "Please fix this problem (check the console logs on VTY2) and\n"
122 "try again.", mountpoint);
125 if (variable_cmp(VAR_RELNAME, cp)
126 && variable_cmp(VAR_RELNAME, "none")
127 && variable_cmp(VAR_RELNAME, "any") && !bogusCDOK) {
128 msgConfirm("Warning: The version of the FreeBSD CD currently in the drive\n"
129 "(%s) does not match the version of the boot floppy\n"
131 "If this is intentional, to avoid this message in the future\n"
132 "please visit the Options editor to set the boot floppy version\n"
133 "string to match that of the CD before selecting it as your\n"
134 "installation media.", cp, variable_get(VAR_RELNAME));
136 if (msgYesNo("Would you like to try and use this CDROM anyway?") != 0) {
137 unmount(mountpoint, MNT_FORCE);
138 cdromMounted = FALSE;
139 properties_free(cd_attr);
145 if ((cp = property_find(cd_attr, "CD_MACHINE_ARCH")) != NULL) {
147 if (strcmp(cp, "alpha")) {
149 if (strcmp(cp, "x86")) {
151 msgConfirm("Fatal: The FreeBSD install CD currently in the drive\n"
152 "is for the %s architecture, not the machine you're using.\n\n"
154 "Please use the correct installation CD for your machine type.", cp);
156 unmount(mountpoint, MNT_FORCE);
157 cdromMounted = FALSE;
158 properties_free(cd_attr);
165 properties_free(cd_attr);
170 mediaGetCDROM(Device *dev, char *file, Boolean probe)
172 return mediaGenericGet(mountpoint, file);
176 mediaShutdownCDROM(Device *dev)
181 if (unmount(mountpoint, MNT_FORCE) != 0)
182 msgConfirm("Could not unmount the CDROM from %s: %s", mountpoint, strerror(errno));
184 cdromMounted = FALSE;