- Fix a bug in sysinstall related to mounting CD-ROMs. If mount(2) fails
with EBUSY and a cdrom is not mounted at /cdrom, sysinstall fails to treat it as an error and thinks that the disk mounted ok. However, it doesn't find a cdrom.inf file so it complains. Later when it tries to unmount the disk due to a mediaClose() umount(2) returns an error, and it never clears its internal mounted flag. The fix here is to properly handle EBUSY as an error if there isn't a CD already mounted at /cdrom. - Add a new CDROMInitQuiet variable that can be used to shut up the dialog box about the mount(2) system call failing when trying to mount a CD-ROM. This is used by the feature described below. - When using a fixit CD, first try to see if we can mount the disc in the drive now and use it as a fixit CD. If not, then prompt the user to insert the disc and try again. If we do succeed on the first "silent" probe then we don't ask the user to eject the disk after leaving fixit mode. - Add a simple file existence test to make sure that the disc that we mount really is a livefs disc. - Explicitly switch back to ttyv0 when using the standard console after the fixit shell dies. Previously this behavior worked accidentally because all the fixit modes popped up a dialog box which contained a hidden switch to ttyv0. MFC after: 1 day
This commit is contained in:
parent
7819da7944
commit
d61e43fe1e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=143065
@ -36,6 +36,7 @@
|
||||
|
||||
#include "sysinstall.h"
|
||||
#include <ctype.h>
|
||||
#include <sys/consio.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
@ -328,6 +329,7 @@ int
|
||||
installFixitCDROM(dialogMenuItem *self)
|
||||
{
|
||||
struct stat sb;
|
||||
int need_eject;
|
||||
|
||||
if (!RunningAsInit)
|
||||
return DITEM_SUCCESS;
|
||||
@ -336,18 +338,29 @@ installFixitCDROM(dialogMenuItem *self)
|
||||
(void)unlink("/mnt2");
|
||||
(void)rmdir("/mnt2");
|
||||
|
||||
need_eject = 0;
|
||||
CDROMInitQuiet = 1;
|
||||
while (1) {
|
||||
msgConfirm("Please insert a FreeBSD live filesystem CD/DVD and press return");
|
||||
if (need_eject)
|
||||
msgConfirm(
|
||||
"Please insert a FreeBSD live filesystem CD/DVD and press return");
|
||||
if (DITEM_STATUS(mediaSetCDROM(NULL)) != DITEM_SUCCESS
|
||||
|| !DEVICE_INIT(mediaDevice)) {
|
||||
/* If we can't initialize it, it's probably not a FreeBSD CDROM so punt on it */
|
||||
mediaClose();
|
||||
if (msgYesNo("Unable to mount the disc - do you want to try again?") != 0)
|
||||
if (need_eject && msgYesNo("Unable to mount the disc. Do you want to try again?") != 0)
|
||||
return DITEM_FAILURE;
|
||||
}
|
||||
else
|
||||
} else if (!file_readable("/dist/rescue/ldconfig")) {
|
||||
mediaClose();
|
||||
if (need_eject &&
|
||||
msgYesNo("Unable to find a FreeBSD live filesystem. Do you want to try again?") != 0)
|
||||
return DITEM_FAILURE;
|
||||
} else
|
||||
break;
|
||||
CDROMInitQuiet = 0;
|
||||
need_eject = 1;
|
||||
}
|
||||
CDROMInitQuiet = 0;
|
||||
|
||||
/* Since the fixit code expects everything to be in /mnt2, and the CDROM mounting stuff /dist, do
|
||||
* a little kludge dance here..
|
||||
@ -397,7 +410,8 @@ installFixitCDROM(dialogMenuItem *self)
|
||||
symlink("/mnt2/usr/bin/vi", "/usr/bin/vi");
|
||||
fixit_common();
|
||||
mediaClose();
|
||||
msgConfirm("Please remove the FreeBSD fixit CDROM/DVD now.");
|
||||
if (need_eject)
|
||||
msgConfirm("Please remove the FreeBSD fixit CDROM/DVD now.");
|
||||
return DITEM_SUCCESS;
|
||||
}
|
||||
|
||||
@ -527,6 +541,10 @@ fixit_common(void)
|
||||
(void)waitpid(child, &waitstatus, 0);
|
||||
if (strcmp(variable_get(VAR_FIXIT_TTY), "serial") == 0)
|
||||
systemResumeDialog();
|
||||
else if (OnVTY) {
|
||||
ioctl(0, VT_ACTIVATE, 0);
|
||||
msgInfo(NULL);
|
||||
}
|
||||
}
|
||||
dialog_clear();
|
||||
}
|
||||
|
@ -402,6 +402,7 @@ typedef struct _devPriv {
|
||||
|
||||
/*** Externs ***/
|
||||
extern jmp_buf BailOut; /* Used to get the heck out */
|
||||
extern int CDROMInitQuiet; /* Don't whine if mount(2) fails */
|
||||
extern int DebugFD; /* Where diagnostic output goes */
|
||||
extern Boolean Fake; /* Don't actually modify anything - testing */
|
||||
extern Boolean Restarting; /* Are we restarting sysinstall? */
|
||||
|
@ -56,6 +56,7 @@
|
||||
static Boolean cdromMounted;
|
||||
static Boolean previouslyMounted; /* Was the disc already mounted? */
|
||||
static char mountpoint[MAXPATHLEN] = "/dist";
|
||||
int CDROMInitQuiet;
|
||||
|
||||
static properties
|
||||
read_props(char *name)
|
||||
@ -91,14 +92,19 @@ mediaInitCDROM(Device *dev)
|
||||
if (errno == EINVAL) {
|
||||
msgConfirm("The disc in your drive looks more like an Audio disc than a FreeBSD release.");
|
||||
return FALSE;
|
||||
} else if (errno == EBUSY) {
|
||||
}
|
||||
if (errno == EBUSY) {
|
||||
/* Perhaps the CDROM drive is already mounted as /cdrom */
|
||||
if (file_readable("/cdrom/cdrom.inf")) {
|
||||
previouslyMounted = TRUE;
|
||||
strlcpy(mountpoint, "/cdrom", 7);
|
||||
errno = 0;
|
||||
}
|
||||
} else {
|
||||
msgConfirm("Error mounting %s on %s: %s (%u)", dev->devname, mountpoint, strerror(errno), errno);
|
||||
}
|
||||
if (errno) {
|
||||
if (!CDROMInitQuiet)
|
||||
msgConfirm("Error mounting %s on %s: %s (%u)", dev->devname,
|
||||
mountpoint, strerror(errno), errno);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
#include "sysinstall.h"
|
||||
#include <ctype.h>
|
||||
#include <sys/consio.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
@ -328,6 +329,7 @@ int
|
||||
installFixitCDROM(dialogMenuItem *self)
|
||||
{
|
||||
struct stat sb;
|
||||
int need_eject;
|
||||
|
||||
if (!RunningAsInit)
|
||||
return DITEM_SUCCESS;
|
||||
@ -336,18 +338,29 @@ installFixitCDROM(dialogMenuItem *self)
|
||||
(void)unlink("/mnt2");
|
||||
(void)rmdir("/mnt2");
|
||||
|
||||
need_eject = 0;
|
||||
CDROMInitQuiet = 1;
|
||||
while (1) {
|
||||
msgConfirm("Please insert a FreeBSD live filesystem CD/DVD and press return");
|
||||
if (need_eject)
|
||||
msgConfirm(
|
||||
"Please insert a FreeBSD live filesystem CD/DVD and press return");
|
||||
if (DITEM_STATUS(mediaSetCDROM(NULL)) != DITEM_SUCCESS
|
||||
|| !DEVICE_INIT(mediaDevice)) {
|
||||
/* If we can't initialize it, it's probably not a FreeBSD CDROM so punt on it */
|
||||
mediaClose();
|
||||
if (msgYesNo("Unable to mount the disc - do you want to try again?") != 0)
|
||||
if (need_eject && msgYesNo("Unable to mount the disc. Do you want to try again?") != 0)
|
||||
return DITEM_FAILURE;
|
||||
}
|
||||
else
|
||||
} else if (!file_readable("/dist/rescue/ldconfig")) {
|
||||
mediaClose();
|
||||
if (need_eject &&
|
||||
msgYesNo("Unable to find a FreeBSD live filesystem. Do you want to try again?") != 0)
|
||||
return DITEM_FAILURE;
|
||||
} else
|
||||
break;
|
||||
CDROMInitQuiet = 0;
|
||||
need_eject = 1;
|
||||
}
|
||||
CDROMInitQuiet = 0;
|
||||
|
||||
/* Since the fixit code expects everything to be in /mnt2, and the CDROM mounting stuff /dist, do
|
||||
* a little kludge dance here..
|
||||
@ -397,7 +410,8 @@ installFixitCDROM(dialogMenuItem *self)
|
||||
symlink("/mnt2/usr/bin/vi", "/usr/bin/vi");
|
||||
fixit_common();
|
||||
mediaClose();
|
||||
msgConfirm("Please remove the FreeBSD fixit CDROM/DVD now.");
|
||||
if (need_eject)
|
||||
msgConfirm("Please remove the FreeBSD fixit CDROM/DVD now.");
|
||||
return DITEM_SUCCESS;
|
||||
}
|
||||
|
||||
@ -527,6 +541,10 @@ fixit_common(void)
|
||||
(void)waitpid(child, &waitstatus, 0);
|
||||
if (strcmp(variable_get(VAR_FIXIT_TTY), "serial") == 0)
|
||||
systemResumeDialog();
|
||||
else if (OnVTY) {
|
||||
ioctl(0, VT_ACTIVATE, 0);
|
||||
msgInfo(NULL);
|
||||
}
|
||||
}
|
||||
dialog_clear();
|
||||
}
|
||||
|
@ -402,6 +402,7 @@ typedef struct _devPriv {
|
||||
|
||||
/*** Externs ***/
|
||||
extern jmp_buf BailOut; /* Used to get the heck out */
|
||||
extern int CDROMInitQuiet; /* Don't whine if mount(2) fails */
|
||||
extern int DebugFD; /* Where diagnostic output goes */
|
||||
extern Boolean Fake; /* Don't actually modify anything - testing */
|
||||
extern Boolean Restarting; /* Are we restarting sysinstall? */
|
||||
|
Loading…
Reference in New Issue
Block a user