Unbreak the fixit floppy.

Clean up some of the media handling to use common routines.
This commit is contained in:
Jordan K. Hubbard 1999-02-15 00:49:33 +00:00
parent 5a1e113f67
commit 065f34b7e2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=44029
10 changed files with 84 additions and 85 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: floppy.c,v 1.30 1998/10/12 23:45:06 jkh Exp $
* $Id: floppy.c,v 1.31 1998/12/22 12:31:24 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -63,12 +63,14 @@ mediaInitFloppy(Device *dev)
{
struct msdosfs_args dosargs;
struct ufs_args u_args;
char *mp;
if (floppyMounted)
return TRUE;
if (Mkdir(mountpoint)) {
msgConfirm("Unable to make %s directory mountpoint for %s!", mountpoint, dev->devname);
mp = dev->private ? (char *)dev->private : mountpoint;
if (Mkdir(mp)) {
msgConfirm("Unable to make %s directory mountpoint for %s!", mp, dev->devname);
return FALSE;
}
@ -90,10 +92,10 @@ mediaInitFloppy(Device *dev)
memset(&u_args, 0, sizeof(u_args));
u_args.fspec = dev->devname;
if (mount("msdos", mountpoint, MNT_RDONLY, (caddr_t)&dosargs) == -1) {
if (mount("ufs", mountpoint, MNT_RDONLY, (caddr_t)&u_args) == -1) {
if (mount("msdos", mp, MNT_RDONLY, (caddr_t)&dosargs) == -1) {
if (mount("ufs", mp, MNT_RDONLY, (caddr_t)&u_args) == -1) {
msgConfirm("Error mounting floppy %s (%s) on %s : %s",
dev->name, dev->devname, mountpoint, strerror(errno));
dev->name, dev->devname, mp, strerror(errno));
return FALSE;
}
}
@ -105,7 +107,7 @@ mediaInitFloppy(Device *dev)
FILE *
mediaGetFloppy(Device *dev, char *file, Boolean probe)
{
char buf[PATH_MAX];
char buf[PATH_MAX], *mp;
FILE *fp;
int nretries = 5;
@ -114,7 +116,8 @@ mediaGetFloppy(Device *dev, char *file, Boolean probe)
* to speculatively open files on a floppy disk. Make user get it
* right or give up with floppies.
*/
snprintf(buf, PATH_MAX, "%s/%s", mountpoint, file);
mp = dev->private ? (char *)dev->private : mountpoint;
snprintf(buf, PATH_MAX, "%s/%s", mp, file);
if (!file_readable(buf)) {
if (probe)
return NULL;
@ -139,8 +142,10 @@ void
mediaShutdownFloppy(Device *dev)
{
if (floppyMounted) {
if (unmount(mountpoint, MNT_FORCE) != 0)
msgDebug("Umount of floppy on %s failed: %s (%d)\n", mountpoint, strerror(errno), errno);
char *mp = dev->private ? (char *)dev->private : mountpoint;
if (unmount(mp, MNT_FORCE) != 0)
msgDebug("Umount of floppy on %s failed: %s (%d)\n", mp, strerror(errno), errno);
else {
floppyMounted = FALSE;
if (!variable_get(VAR_NONINTERACTIVE))

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.227 1999/02/09 22:18:10 jkh Exp $
* $Id: install.c,v 1.228 1999/02/14 21:26:28 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -272,13 +272,10 @@ installFixitCDROM(dialogMenuItem *self)
(void)rmdir("/mnt2");
while (1) {
msgConfirm("Please insert the second FreeBSD CDROM and press return");
msgConfirm("Please insert a FreeBSD live filesystem 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 */
if (mediaDevice) {
mediaDevice->shutdown(mediaDevice);
mediaDevice = NULL;
}
mediaClose();
if (msgYesNo("Unable to mount the CDROM - do you want to try again?") != 0)
return DITEM_FAILURE;
}
@ -325,11 +322,9 @@ installFixitCDROM(dialogMenuItem *self)
"Dynamic executables from the CDROM likely won't work.");
}
}
fixit_common();
mediaDevice->shutdown(mediaDevice);
msgConfirm("Please remove the FreeBSD CDROM now.");
mediaClose();
msgConfirm("Please remove the FreeBSD fixit CDROM now.");
return DITEM_SUCCESS;
}
@ -337,15 +332,13 @@ int
installFixitFloppy(dialogMenuItem *self)
{
struct ufs_args args;
extern char *distWanted;
if (!RunningAsInit)
return DITEM_SUCCESS;
variable_set2(SYSTEM_STATE, "fixit", 0);
Mkdir("/mnt2");
/* Try to open the floppy drive */
if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE) {
if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE || !mediaDevice) {
msgConfirm("Unable to set media device to floppy.");
mediaClose();
return DITEM_FAILURE;
@ -353,10 +346,13 @@ installFixitFloppy(dialogMenuItem *self)
memset(&args, 0, sizeof(args));
args.fspec = mediaDevice->devname;
mediaDevice->private = "/mnt2";
distWanted = NULL;
Mkdir("/mnt2");
variable_set2(SYSTEM_STATE, "fixit", 0);
while (1) {
msgConfirm("Please insert a writable fixit floppy and press return");
mediaDevice->private = "/mnt2";
if (!mediaDevice->init(mediaDevice)) {
if (msgYesNo("The attempt to mount the fixit floppy failed, bad floppy\n"
"or unclean filesystem. Do you want to try again?"))
@ -368,8 +364,7 @@ installFixitFloppy(dialogMenuItem *self)
if (!directory_exists("/tmp"))
(void)symlink("/mnt2/tmp", "/tmp");
fixit_common();
mediaDevice->shutdown(mediaDevice);
mediaDevice = NULL;
mediaClose();
msgConfirm("Please remove the fixit floppy now.");
return DITEM_SUCCESS;
}

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: media.c,v 1.94 1998/12/22 12:31:25 jkh Exp $
* $Id: media.c,v 1.95 1999/02/05 22:15:50 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -204,6 +204,8 @@ mediaSetFloppy(dialogMenuItem *self)
}
else
mediaDevice = devs[0];
if (mediaDevice)
mediaDevice->private = NULL;
return (mediaDevice ? DITEM_LEAVE_MENU : DITEM_FAILURE) | DITEM_RESTORE;
}

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: system.c,v 1.89 1999/02/09 22:18:10 jkh Exp $
* $Id: system.c,v 1.90 1999/02/14 21:26:29 jkh Exp $
*
* Jordan Hubbard
*
@ -146,8 +146,8 @@ void
systemShutdown(int status)
{
/* If some media is open, close it down */
if (status >=0 && mediaDevice)
mediaDevice->shutdown(mediaDevice);
if (status >=0)
mediaClose();
/* write out any changes to rc.conf .. */
configRC_conf();

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.227 1999/02/09 22:18:10 jkh Exp $
* $Id: install.c,v 1.228 1999/02/14 21:26:28 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -272,13 +272,10 @@ installFixitCDROM(dialogMenuItem *self)
(void)rmdir("/mnt2");
while (1) {
msgConfirm("Please insert the second FreeBSD CDROM and press return");
msgConfirm("Please insert a FreeBSD live filesystem 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 */
if (mediaDevice) {
mediaDevice->shutdown(mediaDevice);
mediaDevice = NULL;
}
mediaClose();
if (msgYesNo("Unable to mount the CDROM - do you want to try again?") != 0)
return DITEM_FAILURE;
}
@ -325,11 +322,9 @@ installFixitCDROM(dialogMenuItem *self)
"Dynamic executables from the CDROM likely won't work.");
}
}
fixit_common();
mediaDevice->shutdown(mediaDevice);
msgConfirm("Please remove the FreeBSD CDROM now.");
mediaClose();
msgConfirm("Please remove the FreeBSD fixit CDROM now.");
return DITEM_SUCCESS;
}
@ -337,15 +332,13 @@ int
installFixitFloppy(dialogMenuItem *self)
{
struct ufs_args args;
extern char *distWanted;
if (!RunningAsInit)
return DITEM_SUCCESS;
variable_set2(SYSTEM_STATE, "fixit", 0);
Mkdir("/mnt2");
/* Try to open the floppy drive */
if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE) {
if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE || !mediaDevice) {
msgConfirm("Unable to set media device to floppy.");
mediaClose();
return DITEM_FAILURE;
@ -353,10 +346,13 @@ installFixitFloppy(dialogMenuItem *self)
memset(&args, 0, sizeof(args));
args.fspec = mediaDevice->devname;
mediaDevice->private = "/mnt2";
distWanted = NULL;
Mkdir("/mnt2");
variable_set2(SYSTEM_STATE, "fixit", 0);
while (1) {
msgConfirm("Please insert a writable fixit floppy and press return");
mediaDevice->private = "/mnt2";
if (!mediaDevice->init(mediaDevice)) {
if (msgYesNo("The attempt to mount the fixit floppy failed, bad floppy\n"
"or unclean filesystem. Do you want to try again?"))
@ -368,8 +364,7 @@ installFixitFloppy(dialogMenuItem *self)
if (!directory_exists("/tmp"))
(void)symlink("/mnt2/tmp", "/tmp");
fixit_common();
mediaDevice->shutdown(mediaDevice);
mediaDevice = NULL;
mediaClose();
msgConfirm("Please remove the fixit floppy now.");
return DITEM_SUCCESS;
}

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: system.c,v 1.89 1999/02/09 22:18:10 jkh Exp $
* $Id: system.c,v 1.90 1999/02/14 21:26:29 jkh Exp $
*
* Jordan Hubbard
*
@ -146,8 +146,8 @@ void
systemShutdown(int status)
{
/* If some media is open, close it down */
if (status >=0 && mediaDevice)
mediaDevice->shutdown(mediaDevice);
if (status >=0)
mediaClose();
/* write out any changes to rc.conf .. */
configRC_conf();

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: floppy.c,v 1.30 1998/10/12 23:45:06 jkh Exp $
* $Id: floppy.c,v 1.31 1998/12/22 12:31:24 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -63,12 +63,14 @@ mediaInitFloppy(Device *dev)
{
struct msdosfs_args dosargs;
struct ufs_args u_args;
char *mp;
if (floppyMounted)
return TRUE;
if (Mkdir(mountpoint)) {
msgConfirm("Unable to make %s directory mountpoint for %s!", mountpoint, dev->devname);
mp = dev->private ? (char *)dev->private : mountpoint;
if (Mkdir(mp)) {
msgConfirm("Unable to make %s directory mountpoint for %s!", mp, dev->devname);
return FALSE;
}
@ -90,10 +92,10 @@ mediaInitFloppy(Device *dev)
memset(&u_args, 0, sizeof(u_args));
u_args.fspec = dev->devname;
if (mount("msdos", mountpoint, MNT_RDONLY, (caddr_t)&dosargs) == -1) {
if (mount("ufs", mountpoint, MNT_RDONLY, (caddr_t)&u_args) == -1) {
if (mount("msdos", mp, MNT_RDONLY, (caddr_t)&dosargs) == -1) {
if (mount("ufs", mp, MNT_RDONLY, (caddr_t)&u_args) == -1) {
msgConfirm("Error mounting floppy %s (%s) on %s : %s",
dev->name, dev->devname, mountpoint, strerror(errno));
dev->name, dev->devname, mp, strerror(errno));
return FALSE;
}
}
@ -105,7 +107,7 @@ mediaInitFloppy(Device *dev)
FILE *
mediaGetFloppy(Device *dev, char *file, Boolean probe)
{
char buf[PATH_MAX];
char buf[PATH_MAX], *mp;
FILE *fp;
int nretries = 5;
@ -114,7 +116,8 @@ mediaGetFloppy(Device *dev, char *file, Boolean probe)
* to speculatively open files on a floppy disk. Make user get it
* right or give up with floppies.
*/
snprintf(buf, PATH_MAX, "%s/%s", mountpoint, file);
mp = dev->private ? (char *)dev->private : mountpoint;
snprintf(buf, PATH_MAX, "%s/%s", mp, file);
if (!file_readable(buf)) {
if (probe)
return NULL;
@ -139,8 +142,10 @@ void
mediaShutdownFloppy(Device *dev)
{
if (floppyMounted) {
if (unmount(mountpoint, MNT_FORCE) != 0)
msgDebug("Umount of floppy on %s failed: %s (%d)\n", mountpoint, strerror(errno), errno);
char *mp = dev->private ? (char *)dev->private : mountpoint;
if (unmount(mp, MNT_FORCE) != 0)
msgDebug("Umount of floppy on %s failed: %s (%d)\n", mp, strerror(errno), errno);
else {
floppyMounted = FALSE;
if (!variable_get(VAR_NONINTERACTIVE))

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.227 1999/02/09 22:18:10 jkh Exp $
* $Id: install.c,v 1.228 1999/02/14 21:26:28 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -272,13 +272,10 @@ installFixitCDROM(dialogMenuItem *self)
(void)rmdir("/mnt2");
while (1) {
msgConfirm("Please insert the second FreeBSD CDROM and press return");
msgConfirm("Please insert a FreeBSD live filesystem 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 */
if (mediaDevice) {
mediaDevice->shutdown(mediaDevice);
mediaDevice = NULL;
}
mediaClose();
if (msgYesNo("Unable to mount the CDROM - do you want to try again?") != 0)
return DITEM_FAILURE;
}
@ -325,11 +322,9 @@ installFixitCDROM(dialogMenuItem *self)
"Dynamic executables from the CDROM likely won't work.");
}
}
fixit_common();
mediaDevice->shutdown(mediaDevice);
msgConfirm("Please remove the FreeBSD CDROM now.");
mediaClose();
msgConfirm("Please remove the FreeBSD fixit CDROM now.");
return DITEM_SUCCESS;
}
@ -337,15 +332,13 @@ int
installFixitFloppy(dialogMenuItem *self)
{
struct ufs_args args;
extern char *distWanted;
if (!RunningAsInit)
return DITEM_SUCCESS;
variable_set2(SYSTEM_STATE, "fixit", 0);
Mkdir("/mnt2");
/* Try to open the floppy drive */
if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE) {
if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE || !mediaDevice) {
msgConfirm("Unable to set media device to floppy.");
mediaClose();
return DITEM_FAILURE;
@ -353,10 +346,13 @@ installFixitFloppy(dialogMenuItem *self)
memset(&args, 0, sizeof(args));
args.fspec = mediaDevice->devname;
mediaDevice->private = "/mnt2";
distWanted = NULL;
Mkdir("/mnt2");
variable_set2(SYSTEM_STATE, "fixit", 0);
while (1) {
msgConfirm("Please insert a writable fixit floppy and press return");
mediaDevice->private = "/mnt2";
if (!mediaDevice->init(mediaDevice)) {
if (msgYesNo("The attempt to mount the fixit floppy failed, bad floppy\n"
"or unclean filesystem. Do you want to try again?"))
@ -368,8 +364,7 @@ installFixitFloppy(dialogMenuItem *self)
if (!directory_exists("/tmp"))
(void)symlink("/mnt2/tmp", "/tmp");
fixit_common();
mediaDevice->shutdown(mediaDevice);
mediaDevice = NULL;
mediaClose();
msgConfirm("Please remove the fixit floppy now.");
return DITEM_SUCCESS;
}

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: media.c,v 1.94 1998/12/22 12:31:25 jkh Exp $
* $Id: media.c,v 1.95 1999/02/05 22:15:50 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -204,6 +204,8 @@ mediaSetFloppy(dialogMenuItem *self)
}
else
mediaDevice = devs[0];
if (mediaDevice)
mediaDevice->private = NULL;
return (mediaDevice ? DITEM_LEAVE_MENU : DITEM_FAILURE) | DITEM_RESTORE;
}

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: system.c,v 1.89 1999/02/09 22:18:10 jkh Exp $
* $Id: system.c,v 1.90 1999/02/14 21:26:29 jkh Exp $
*
* Jordan Hubbard
*
@ -146,8 +146,8 @@ void
systemShutdown(int status)
{
/* If some media is open, close it down */
if (status >=0 && mediaDevice)
mediaDevice->shutdown(mediaDevice);
if (status >=0)
mediaClose();
/* write out any changes to rc.conf .. */
configRC_conf();