Do a better job of CDROM detection.

Use consistent spelling throughout.
Remove unmount in fixit_common() since that's bogus in the CDROM case and
properly "shut down" the media device instead.
This commit is contained in:
Jordan K. Hubbard 1997-01-06 11:10:25 +00:00
parent 16a960917f
commit 29d851f6c2
5 changed files with 80 additions and 59 deletions

View File

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $Id: cdrom.c,v 1.30 1996/12/12 16:55:37 jkh Exp $
* $Id: cdrom.c,v 1.31 1997/01/01 12:36:05 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -65,7 +65,7 @@ mediaInitCDROM(Device *dev)
struct iso_args args;
Attribs *cd_attr;
char *cp;
Boolean dontRead;
Boolean readInfo = TRUE;
if (cdromMounted != CD_UNMOUNTED)
return TRUE;
@ -76,7 +76,6 @@ mediaInitCDROM(Device *dev)
cd_attr = alloca(sizeof(Attribs) * MAX_ATTRIBS);
cp = NULL;
dontRead = FALSE;
/* If this cdrom's not already mounted or can't be mounted, yell */
if (!file_readable("/cdrom/cdrom.inf")) {
Mkdir("/cdrom");
@ -97,15 +96,17 @@ mediaInitCDROM(Device *dev)
"CD or it is an older (pre 2.1.5) FreeBSD CD which does not\n"
"have a version number on it. Do you wish to use this CD anyway?") != 0) {
unmount("/cdrom", MNT_FORCE);
cdromMounted = CD_UNMOUNTED;
return FALSE;
}
dontRead = TRUE;
else
readInfo = FALSE;
}
cdromMounted = CD_WE_MOUNTED_IT;
}
else
cdromMounted = CD_ALREADY_MOUNTED;
if (!dontRead && (DITEM_STATUS(attr_parse_file(cd_attr, "/cdrom/cdrom.inf")) == DITEM_FAILURE ||
if (readInfo && (DITEM_STATUS(attr_parse_file(cd_attr, "/cdrom/cdrom.inf")) == DITEM_FAILURE ||
!(cp = attr_match(cd_attr, "CD_VERSION")) || strcmp(cp, variable_get(VAR_RELNAME)))) {
if (cdromMounted != CD_ALREADY_MOUNTED)
unmount("/cdrom", MNT_FORCE);
@ -117,12 +118,18 @@ mediaInitCDROM(Device *dev)
"try again.");
else
msgConfirm("Warning: The version of the FreeBSD CD currently in the drive\n"
"(%s) does not match the version of this boot floppy\n"
"(%s) does not match the version of the boot floppy\n"
"(%s).\n\n"
"If this is intentional, then please visit the Options editor\n"
"to set the boot floppy version string to match that of the CD\n"
"before selecting it as an installation media.", cp, variable_get(VAR_RELNAME));
return FALSE;
"If this is intentional, to avoid this message in the future\n"
"please visit the Options editor to set the boot floppy version\n"
"string to match that of the CD before selecting it as your\n"
"installation media.", cp, variable_get(VAR_RELNAME));
if (msgYesNo("Would you like to try and use this CDROM anyway?") != 0) {
unmount("/cdrom", MNT_FORCE);
cdromMounted = CD_UNMOUNTED;
return FALSE;
}
}
msgDebug("Mounted FreeBSD CDROM on device %s as /cdrom\n", dev->devname);
return TRUE;
@ -151,8 +158,7 @@ mediaGetCDROM(Device *dev, char *file, Boolean probe)
void
mediaShutdownCDROM(Device *dev)
{
/* Only undo it if we did it */
if (cdromMounted != CD_WE_MOUNTED_IT)
if (cdromMounted == CD_UNMOUNTED)
return;
msgDebug("Unmounting %s from /cdrom\n", dev->devname);
if (unmount("/cdrom", MNT_FORCE) != 0) {
@ -160,7 +166,7 @@ mediaShutdownCDROM(Device *dev)
cdromMounted = CD_ALREADY_MOUNTED; /* Guess somebody else got it */
}
else {
msgDebug("Unmount successful\n");
msgDebug("Unmount of CDROM successful\n");
cdromMounted = CD_UNMOUNTED;
}
}

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.146 1996/12/26 03:32:50 jkh Exp $
* $Id: install.c,v 1.147 1996/12/29 05:51:35 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -249,7 +249,6 @@ installFixitHoloShell(dialogMenuItem *self)
return DITEM_SUCCESS;
}
int
installFixitCDROM(dialogMenuItem *self)
{
@ -260,11 +259,14 @@ installFixitCDROM(dialogMenuItem *self)
(void)rmdir("/mnt2");
while (1) {
msgConfirm("Please insert the second CD-ROM and press return");
if (DITEM_STATUS(mediaSetCDROM(NULL)) != DITEM_SUCCESS || !mediaDevice->init(mediaDevice)) {
msgConfirm("Please insert the second FreeBSD CDROM and press return");
if (DITEM_STATUS(mediaSetCDROM(NULL)) != DITEM_SUCCESS || !mediaDevice || !mediaDevice->init(mediaDevice)) {
/* If we can't initialize it, it's probably not a FreeBSD CDROM so punt on it */
mediaDevice = NULL;
if (msgYesNo("Unable to mount the CD-ROM - do you want to try again?") != 0)
if (mediaDevice) {
mediaDevice->shutdown(mediaDevice);
mediaDevice = NULL;
}
if (msgYesNo("Unable to mount the CDROM - do you want to try again?") != 0)
return DITEM_FAILURE;
}
}
@ -280,7 +282,7 @@ installFixitCDROM(dialogMenuItem *self)
/*
* If /tmp points to /mnt2/tmp from a previous fixit floppy session, it's
* not very good for us if we point it to the CD-ROM now. Rather make it
* not very good for us if we point it to the CDROM now. Rather make it
* a directory in the root MFS then. Experienced admins will still be
* able to mount their disk's /tmp over this if they need.
*/
@ -296,7 +298,7 @@ installFixitCDROM(dialogMenuItem *self)
Mkdir("/var/run");
if (vsystem("/mnt2/sbin/ldconfig -s /mnt2/usr/lib")) {
msgConfirm("Warning: ldconfig could not create the ld.so hints file.\n"
"Dynamic executables from the CD-ROM likely won't work.");
"Dynamic executables from the CDROM likely won't work.");
}
}
@ -305,13 +307,14 @@ installFixitCDROM(dialogMenuItem *self)
Mkdir("/usr/libexec");
if (symlink("/mnt2/usr/libexec/ld.so", "/usr/libexec/ld.so")) {
msgConfirm("Warning: could not create the symlink for ld.so.\n"
"Dynamic executables from the CD-ROM likely won't work.");
"Dynamic executables from the CDROM likely won't work.");
}
}
fixit_common();
msgConfirm("Please remove the CD-ROM now.");
msgConfirm("Please remove the FreeBSD CDROM now.");
mediaDevice->shutdown(mediaDevice);
return DITEM_SUCCESS;
}
@ -343,6 +346,7 @@ installFixitFloppy(dialogMenuItem *self)
fixit_common();
msgConfirm("Please remove the fixit floppy now.");
unmount("/mnt2", MNT_FORCE);
return DITEM_SUCCESS;
}
@ -413,7 +417,6 @@ fixit_common(void)
"the fixit shell and be returned here.");
(void)waitpid(child, &waitstatus, 0);
}
unmount("/mnt2", MNT_FORCE);
dialog_clear();
}

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.146 1996/12/26 03:32:50 jkh Exp $
* $Id: install.c,v 1.147 1996/12/29 05:51:35 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -249,7 +249,6 @@ installFixitHoloShell(dialogMenuItem *self)
return DITEM_SUCCESS;
}
int
installFixitCDROM(dialogMenuItem *self)
{
@ -260,11 +259,14 @@ installFixitCDROM(dialogMenuItem *self)
(void)rmdir("/mnt2");
while (1) {
msgConfirm("Please insert the second CD-ROM and press return");
if (DITEM_STATUS(mediaSetCDROM(NULL)) != DITEM_SUCCESS || !mediaDevice->init(mediaDevice)) {
msgConfirm("Please insert the second FreeBSD CDROM and press return");
if (DITEM_STATUS(mediaSetCDROM(NULL)) != DITEM_SUCCESS || !mediaDevice || !mediaDevice->init(mediaDevice)) {
/* If we can't initialize it, it's probably not a FreeBSD CDROM so punt on it */
mediaDevice = NULL;
if (msgYesNo("Unable to mount the CD-ROM - do you want to try again?") != 0)
if (mediaDevice) {
mediaDevice->shutdown(mediaDevice);
mediaDevice = NULL;
}
if (msgYesNo("Unable to mount the CDROM - do you want to try again?") != 0)
return DITEM_FAILURE;
}
}
@ -280,7 +282,7 @@ installFixitCDROM(dialogMenuItem *self)
/*
* If /tmp points to /mnt2/tmp from a previous fixit floppy session, it's
* not very good for us if we point it to the CD-ROM now. Rather make it
* not very good for us if we point it to the CDROM now. Rather make it
* a directory in the root MFS then. Experienced admins will still be
* able to mount their disk's /tmp over this if they need.
*/
@ -296,7 +298,7 @@ installFixitCDROM(dialogMenuItem *self)
Mkdir("/var/run");
if (vsystem("/mnt2/sbin/ldconfig -s /mnt2/usr/lib")) {
msgConfirm("Warning: ldconfig could not create the ld.so hints file.\n"
"Dynamic executables from the CD-ROM likely won't work.");
"Dynamic executables from the CDROM likely won't work.");
}
}
@ -305,13 +307,14 @@ installFixitCDROM(dialogMenuItem *self)
Mkdir("/usr/libexec");
if (symlink("/mnt2/usr/libexec/ld.so", "/usr/libexec/ld.so")) {
msgConfirm("Warning: could not create the symlink for ld.so.\n"
"Dynamic executables from the CD-ROM likely won't work.");
"Dynamic executables from the CDROM likely won't work.");
}
}
fixit_common();
msgConfirm("Please remove the CD-ROM now.");
msgConfirm("Please remove the FreeBSD CDROM now.");
mediaDevice->shutdown(mediaDevice);
return DITEM_SUCCESS;
}
@ -343,6 +346,7 @@ installFixitFloppy(dialogMenuItem *self)
fixit_common();
msgConfirm("Please remove the fixit floppy now.");
unmount("/mnt2", MNT_FORCE);
return DITEM_SUCCESS;
}
@ -413,7 +417,6 @@ fixit_common(void)
"the fixit shell and be returned here.");
(void)waitpid(child, &waitstatus, 0);
}
unmount("/mnt2", MNT_FORCE);
dialog_clear();
}

View File

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $Id: cdrom.c,v 1.30 1996/12/12 16:55:37 jkh Exp $
* $Id: cdrom.c,v 1.31 1997/01/01 12:36:05 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -65,7 +65,7 @@ mediaInitCDROM(Device *dev)
struct iso_args args;
Attribs *cd_attr;
char *cp;
Boolean dontRead;
Boolean readInfo = TRUE;
if (cdromMounted != CD_UNMOUNTED)
return TRUE;
@ -76,7 +76,6 @@ mediaInitCDROM(Device *dev)
cd_attr = alloca(sizeof(Attribs) * MAX_ATTRIBS);
cp = NULL;
dontRead = FALSE;
/* If this cdrom's not already mounted or can't be mounted, yell */
if (!file_readable("/cdrom/cdrom.inf")) {
Mkdir("/cdrom");
@ -97,15 +96,17 @@ mediaInitCDROM(Device *dev)
"CD or it is an older (pre 2.1.5) FreeBSD CD which does not\n"
"have a version number on it. Do you wish to use this CD anyway?") != 0) {
unmount("/cdrom", MNT_FORCE);
cdromMounted = CD_UNMOUNTED;
return FALSE;
}
dontRead = TRUE;
else
readInfo = FALSE;
}
cdromMounted = CD_WE_MOUNTED_IT;
}
else
cdromMounted = CD_ALREADY_MOUNTED;
if (!dontRead && (DITEM_STATUS(attr_parse_file(cd_attr, "/cdrom/cdrom.inf")) == DITEM_FAILURE ||
if (readInfo && (DITEM_STATUS(attr_parse_file(cd_attr, "/cdrom/cdrom.inf")) == DITEM_FAILURE ||
!(cp = attr_match(cd_attr, "CD_VERSION")) || strcmp(cp, variable_get(VAR_RELNAME)))) {
if (cdromMounted != CD_ALREADY_MOUNTED)
unmount("/cdrom", MNT_FORCE);
@ -117,12 +118,18 @@ mediaInitCDROM(Device *dev)
"try again.");
else
msgConfirm("Warning: The version of the FreeBSD CD currently in the drive\n"
"(%s) does not match the version of this boot floppy\n"
"(%s) does not match the version of the boot floppy\n"
"(%s).\n\n"
"If this is intentional, then please visit the Options editor\n"
"to set the boot floppy version string to match that of the CD\n"
"before selecting it as an installation media.", cp, variable_get(VAR_RELNAME));
return FALSE;
"If this is intentional, to avoid this message in the future\n"
"please visit the Options editor to set the boot floppy version\n"
"string to match that of the CD before selecting it as your\n"
"installation media.", cp, variable_get(VAR_RELNAME));
if (msgYesNo("Would you like to try and use this CDROM anyway?") != 0) {
unmount("/cdrom", MNT_FORCE);
cdromMounted = CD_UNMOUNTED;
return FALSE;
}
}
msgDebug("Mounted FreeBSD CDROM on device %s as /cdrom\n", dev->devname);
return TRUE;
@ -151,8 +158,7 @@ mediaGetCDROM(Device *dev, char *file, Boolean probe)
void
mediaShutdownCDROM(Device *dev)
{
/* Only undo it if we did it */
if (cdromMounted != CD_WE_MOUNTED_IT)
if (cdromMounted == CD_UNMOUNTED)
return;
msgDebug("Unmounting %s from /cdrom\n", dev->devname);
if (unmount("/cdrom", MNT_FORCE) != 0) {
@ -160,7 +166,7 @@ mediaShutdownCDROM(Device *dev)
cdromMounted = CD_ALREADY_MOUNTED; /* Guess somebody else got it */
}
else {
msgDebug("Unmount successful\n");
msgDebug("Unmount of CDROM successful\n");
cdromMounted = CD_UNMOUNTED;
}
}

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.146 1996/12/26 03:32:50 jkh Exp $
* $Id: install.c,v 1.147 1996/12/29 05:51:35 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -249,7 +249,6 @@ installFixitHoloShell(dialogMenuItem *self)
return DITEM_SUCCESS;
}
int
installFixitCDROM(dialogMenuItem *self)
{
@ -260,11 +259,14 @@ installFixitCDROM(dialogMenuItem *self)
(void)rmdir("/mnt2");
while (1) {
msgConfirm("Please insert the second CD-ROM and press return");
if (DITEM_STATUS(mediaSetCDROM(NULL)) != DITEM_SUCCESS || !mediaDevice->init(mediaDevice)) {
msgConfirm("Please insert the second FreeBSD CDROM and press return");
if (DITEM_STATUS(mediaSetCDROM(NULL)) != DITEM_SUCCESS || !mediaDevice || !mediaDevice->init(mediaDevice)) {
/* If we can't initialize it, it's probably not a FreeBSD CDROM so punt on it */
mediaDevice = NULL;
if (msgYesNo("Unable to mount the CD-ROM - do you want to try again?") != 0)
if (mediaDevice) {
mediaDevice->shutdown(mediaDevice);
mediaDevice = NULL;
}
if (msgYesNo("Unable to mount the CDROM - do you want to try again?") != 0)
return DITEM_FAILURE;
}
}
@ -280,7 +282,7 @@ installFixitCDROM(dialogMenuItem *self)
/*
* If /tmp points to /mnt2/tmp from a previous fixit floppy session, it's
* not very good for us if we point it to the CD-ROM now. Rather make it
* not very good for us if we point it to the CDROM now. Rather make it
* a directory in the root MFS then. Experienced admins will still be
* able to mount their disk's /tmp over this if they need.
*/
@ -296,7 +298,7 @@ installFixitCDROM(dialogMenuItem *self)
Mkdir("/var/run");
if (vsystem("/mnt2/sbin/ldconfig -s /mnt2/usr/lib")) {
msgConfirm("Warning: ldconfig could not create the ld.so hints file.\n"
"Dynamic executables from the CD-ROM likely won't work.");
"Dynamic executables from the CDROM likely won't work.");
}
}
@ -305,13 +307,14 @@ installFixitCDROM(dialogMenuItem *self)
Mkdir("/usr/libexec");
if (symlink("/mnt2/usr/libexec/ld.so", "/usr/libexec/ld.so")) {
msgConfirm("Warning: could not create the symlink for ld.so.\n"
"Dynamic executables from the CD-ROM likely won't work.");
"Dynamic executables from the CDROM likely won't work.");
}
}
fixit_common();
msgConfirm("Please remove the CD-ROM now.");
msgConfirm("Please remove the FreeBSD CDROM now.");
mediaDevice->shutdown(mediaDevice);
return DITEM_SUCCESS;
}
@ -343,6 +346,7 @@ installFixitFloppy(dialogMenuItem *self)
fixit_common();
msgConfirm("Please remove the fixit floppy now.");
unmount("/mnt2", MNT_FORCE);
return DITEM_SUCCESS;
}
@ -413,7 +417,6 @@ fixit_common(void)
"the fixit shell and be returned here.");
(void)waitpid(child, &waitstatus, 0);
}
unmount("/mnt2", MNT_FORCE);
dialog_clear();
}