aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/sysinstall
diff options
context:
space:
mode:
authorDima Dorfman <dd@FreeBSD.org>2001-07-02 00:18:04 +0000
committerDima Dorfman <dd@FreeBSD.org>2001-07-02 00:18:04 +0000
commit13704ca508967d083346df8d9ed32bdfa51bf38c (patch)
treeeb3e6d3ae80fce772bbe283df44e815263d1b83f /usr.sbin/sysinstall
parent0c2e00bb8f535911955ff05eba0d1aba3e0cd72c (diff)
Notes
Diffstat (limited to 'usr.sbin/sysinstall')
-rw-r--r--usr.sbin/sysinstall/devices.c2
-rw-r--r--usr.sbin/sysinstall/dispatch.c4
-rw-r--r--usr.sbin/sysinstall/dist.c20
-rw-r--r--usr.sbin/sysinstall/ftp.c8
-rw-r--r--usr.sbin/sysinstall/index.c6
-rw-r--r--usr.sbin/sysinstall/install.c11
-rw-r--r--usr.sbin/sysinstall/installUpgrade.c4
-rw-r--r--usr.sbin/sysinstall/media.c14
-rw-r--r--usr.sbin/sysinstall/nfs.c4
-rw-r--r--usr.sbin/sysinstall/package.c6
-rw-r--r--usr.sbin/sysinstall/sysinstall.h7
-rw-r--r--usr.sbin/sysinstall/tcpip.c2
12 files changed, 48 insertions, 40 deletions
diff --git a/usr.sbin/sysinstall/devices.c b/usr.sbin/sysinstall/devices.c
index 484a3d6041d2..aa98bd02810d 100644
--- a/usr.sbin/sysinstall/devices.c
+++ b/usr.sbin/sysinstall/devices.c
@@ -236,7 +236,7 @@ deviceReset(void)
int i;
for (i = 0; i < numDevs; i++) {
- Devices[i]->shutdown(Devices[i]);
+ DEVICE_SHUTDOWN(Devices[i]);
/* XXX this potentially leaks Devices[i]->private if it's being
* used to point to something dynamic, but you're not supposed
diff --git a/usr.sbin/sysinstall/dispatch.c b/usr.sbin/sysinstall/dispatch.c
index cd64bf059369..63734760a6c0 100644
--- a/usr.sbin/sysinstall/dispatch.c
+++ b/usr.sbin/sysinstall/dispatch.c
@@ -406,14 +406,14 @@ dispatch_load_floppy(dialogMenuItem *self)
return what;
}
- if (!mediaDevice->init(mediaDevice)) {
+ if (!DEVICE_INIT(mediaDevice)) {
msgConfirm("Unable to mount floppy filesystem.");
what |= DITEM_FAILURE;
mediaClose();
return what;
}
- fp = mediaDevice->get(mediaDevice, cp, TRUE);
+ fp = DEVICE_GET(mediaDevice, cp, TRUE);
if (fp) {
list = dispatch_load_fp(fp);
fclose(fp);
diff --git a/usr.sbin/sysinstall/dist.c b/usr.sbin/sysinstall/dist.c
index 488dd5a089ed..1f8f5fc107ec 100644
--- a/usr.sbin/sysinstall/dist.c
+++ b/usr.sbin/sysinstall/dist.c
@@ -605,14 +605,14 @@ distExtract(char *parent, Distribution *me)
snprintf(buf, sizeof buf, "%s/%s.inf", path, dist);
getinfo:
- fp = mediaDevice->get(mediaDevice, buf, TRUE);
+ fp = DEVICE_GET(mediaDevice, buf, TRUE);
intr = check_for_interrupt();
if (fp == (FILE *)IO_ERROR || intr || !mediaDevice) {
/* Hard error, can't continue */
if (!msgYesNo("Unable to open %s: %s.\nReinitialize media?",
buf, !intr ? "I/O error." : "User interrupt.")) {
- mediaDevice->shutdown(mediaDevice);
- if (!mediaDevice->init(mediaDevice)) {
+ DEVICE_SHUTDOWN(mediaDevice);
+ if (!DEVICE_INIT(mediaDevice)) {
status = FALSE;
goto done;
}
@@ -652,7 +652,7 @@ distExtract(char *parent, Distribution *me)
* are not considered too significant.
*/
getsingle:
- fp = mediaDevice->get(mediaDevice, buf, TRUE);
+ fp = DEVICE_GET(mediaDevice, buf, TRUE);
intr = check_for_interrupt();
if (fp == (FILE *)IO_ERROR || intr || !mediaDevice) {
/* Hard error, can't continue */
@@ -660,8 +660,8 @@ distExtract(char *parent, Distribution *me)
msgConfirm("Unable to open %s: User interrupt", buf);
else
msgConfirm("Unable to open %s: I/O error", buf);
- mediaDevice->shutdown(mediaDevice);
- if (!mediaDevice->init(mediaDevice)) {
+ DEVICE_SHUTDOWN(mediaDevice);
+ if (!DEVICE_INIT(mediaDevice)) {
status = FALSE;
goto done;
}
@@ -715,7 +715,7 @@ distExtract(char *parent, Distribution *me)
snprintf(buf, sizeof buf, "%s/%s.%c%c", path, dist, (chunk / 26) + 'a', (chunk % 26) + 'a');
if (isDebug())
msgDebug("trying for piece %d of %d: %s\n", chunk + 1, numchunks, buf);
- fp = mediaDevice->get(mediaDevice, buf, FALSE);
+ fp = DEVICE_GET(mediaDevice, buf, FALSE);
intr = check_for_interrupt();
if (fp <= (FILE *)0 || intr) {
if (fp == (FILE *)0)
@@ -723,8 +723,8 @@ distExtract(char *parent, Distribution *me)
else
msgConfirm("failed to retreive piece file %s.\n"
"%s: Reinitializing media.", buf, !intr ? "I/O error" : "User interrupt");
- mediaDevice->shutdown(mediaDevice);
- if (!mediaDevice->init(mediaDevice))
+ DEVICE_SHUTDOWN(mediaDevice);
+ if (!DEVICE_INIT(mediaDevice))
goto punt;
else
goto getchunk;
@@ -867,7 +867,7 @@ distExtractAll(dialogMenuItem *self)
return DITEM_FAILURE;
}
- if (!mediaVerify() || !mediaDevice->init(mediaDevice))
+ if (!mediaVerify() || !DEVICE_INIT(mediaDevice))
return DITEM_FAILURE;
old_dists = Dists;
diff --git a/usr.sbin/sysinstall/ftp.c b/usr.sbin/sysinstall/ftp.c
index 2541230536a7..14fd74ba13ea 100644
--- a/usr.sbin/sysinstall/ftp.c
+++ b/usr.sbin/sysinstall/ftp.c
@@ -60,7 +60,7 @@ netUp(Device *dev)
Device *netdev = (Device *)dev->private;
if (netdev)
- return netdev->init(netdev);
+ return DEVICE_INIT(netdev);
else
return TRUE; /* No net == happy net */
}
@@ -72,7 +72,7 @@ netDown(Device *dev)
Device *netdev = (Device *)dev->private;
if (netdev)
- netdev->shutdown(netdev);
+ DEVICE_SHUTDOWN(netdev);
}
Boolean
@@ -228,8 +228,8 @@ mediaGetFTP(Device *dev, char *file, Boolean probe)
if (ftperr != 421) /* Timeout? */
variable_unset(VAR_FTP_PATH);
/* If we can't re-initialize, just forget it */
- dev->shutdown(dev);
- if (!dev->init(dev)) {
+ DEVICE_SHUTDOWN(dev);
+ if (!DEVICE_INIT(dev)) {
netDown(dev);
if (OpenConn) {
fclose(OpenConn);
diff --git a/usr.sbin/sysinstall/index.c b/usr.sbin/sysinstall/index.c
index b6d5c00f7538..c30403a06aa1 100644
--- a/usr.sbin/sysinstall/index.c
+++ b/usr.sbin/sysinstall/index.c
@@ -727,21 +727,21 @@ index_initialize(char *path)
}
/* Does it move when you kick it? */
- if (!mediaDevice->init(mediaDevice)) {
+ if (!DEVICE_INIT(mediaDevice)) {
restorescr(w);
return DITEM_FAILURE;
}
dialog_clear_norefresh();
msgNotify("Attempting to fetch %s file from selected media.", path);
- fp = mediaDevice->get(mediaDevice, path, TRUE);
+ fp = DEVICE_GET(mediaDevice, path, TRUE);
if (!fp) {
msgConfirm("Unable to get packages/INDEX file from selected media.\n\n"
"This may be because the packages collection is not available\n"
"on the distribution media you've chosen, most likely an FTP site\n"
"without the packages collection mirrored. Please verify that\n"
"your media, or your path to the media, is correct and try again.");
- mediaDevice->shutdown(mediaDevice);
+ DEVICE_SHUTDOWN(mediaDevice);
restorescr(w);
return DITEM_FAILURE;
}
diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c
index d5820a6acd4f..3d8539f6ebb1 100644
--- a/usr.sbin/sysinstall/install.c
+++ b/usr.sbin/sysinstall/install.c
@@ -269,8 +269,9 @@ installFixitCDROM(dialogMenuItem *self)
(void)rmdir("/mnt2");
while (1) {
- msgConfirm("Please insert a FreeBSD live filesystem CD/DVD and press return");
- if (DITEM_STATUS(mediaSetCDROM(NULL)) != DITEM_SUCCESS || !mediaDevice || !mediaDevice->init(mediaDevice)) {
+ msgConfirm("Please insert a FreeBSD live filesystem CDROM 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)
@@ -357,7 +358,7 @@ installFixitFloppy(dialogMenuItem *self)
variable_set2(SYSTEM_STATE, "fixit", 0);
while (1) {
- if (!mediaDevice->init(mediaDevice)) {
+ if (!DEVICE_INIT(mediaDevice)) {
if (msgYesNo("The attempt to mount the fixit floppy failed, bad floppy\n"
"or unclean filesystem. Do you want to try again?"))
return DITEM_FAILURE;
@@ -562,7 +563,7 @@ nodisks:
Device *tmp = tcpDeviceSelect();
if (tmp && !((DevInfo *)tmp->private)->use_dhcp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
- if (!tmp->init(tmp))
+ if (!DEVICE_INIT(tmp))
msgConfirm("Initialization of %s device failed.", tmp->name);
}
dialog_clear_norefresh();
@@ -702,7 +703,7 @@ installCommit(dialogMenuItem *self)
return i;
try_media:
- if (!mediaDevice->init(mediaDevice)) {
+ if (!DEVICE_INIT(mediaDevice)) {
if (!msgYesNo("Unable to initialize selected media. Would you like to\n"
"adjust your media configuration and try again?")) {
mediaDevice = NULL;
diff --git a/usr.sbin/sysinstall/installUpgrade.c b/usr.sbin/sysinstall/installUpgrade.c
index 4b0b4ce5e27c..90eaa7c31e45 100644
--- a/usr.sbin/sysinstall/installUpgrade.c
+++ b/usr.sbin/sysinstall/installUpgrade.c
@@ -308,7 +308,7 @@ media:
if (!mediaVerify())
return DITEM_FAILURE;
- if (!mediaDevice->init(mediaDevice)) {
+ if (!DEVICE_INIT(mediaDevice)) {
if (!msgYesNo("Couldn't initialize the media. Would you like\n"
"to adjust your media selection and try again?")) {
mediaDevice = NULL;
@@ -442,7 +442,7 @@ installUpgradeNonInteractive(dialogMenuItem *self)
systemCreateHoloshell();
}
- if (!mediaVerify() || !mediaDevice->init(mediaDevice)) {
+ if (!mediaVerify() || !DEVICE_INIT(mediaDevice)) {
msgNotify("Upgrade: Couldn't initialize media.");
return DITEM_FAILURE;
}
diff --git a/usr.sbin/sysinstall/media.c b/usr.sbin/sysinstall/media.c
index 5e4925f9882b..b2eb519c06c0 100644
--- a/usr.sbin/sysinstall/media.c
+++ b/usr.sbin/sysinstall/media.c
@@ -125,7 +125,7 @@ void
mediaClose(void)
{
if (mediaDevice)
- mediaDevice->shutdown(mediaDevice);
+ DEVICE_SHUTDOWN(mediaDevice);
mediaDevice = NULL;
}
@@ -361,13 +361,13 @@ mediaSetFTP(dialogMenuItem *self)
if (!networkDev || msgYesNo("You've already done the network configuration once,\n"
"would you like to skip over it now?") != 0) {
if (networkDev)
- networkDev->shutdown(networkDev);
+ DEVICE_SHUTDOWN(networkDev);
if (!(networkDev = tcpDeviceSelect())) {
variable_unset(VAR_FTP_PATH);
return DITEM_FAILURE;
}
}
- if (!networkDev->init(networkDev)) {
+ if (!DEVICE_INIT(networkDev)) {
if (isDebug())
msgDebug("mediaSetFTP: Net device init failed.\n");
variable_unset(VAR_FTP_PATH);
@@ -415,7 +415,7 @@ mediaSetFTP(dialogMenuItem *self)
" your\nname server, gateway and network interface are"
" correctly configured?", hostname);
if (networkDev)
- networkDev->shutdown(networkDev);
+ DEVICE_SHUTDOWN(networkDev);
networkDev = NULL;
variable_unset(VAR_FTP_PATH);
return DITEM_FAILURE;
@@ -558,11 +558,11 @@ mediaSetNFS(dialogMenuItem *self)
if (!networkDev || msgYesNo("You've already done the network configuration once,\n"
"would you like to skip over it now?") != 0) {
if (networkDev)
- networkDev->shutdown(networkDev);
+ DEVICE_SHUTDOWN(networkDev);
if (!(networkDev = tcpDeviceSelect()))
return DITEM_FAILURE;
}
- if (!networkDev->init(networkDev)) {
+ if (!DEVICE_INIT(networkDev)) {
if (isDebug())
msgDebug("mediaSetNFS: Net device init failed\n");
}
@@ -572,7 +572,7 @@ mediaSetNFS(dialogMenuItem *self)
msgConfirm("Cannot resolve hostname `%s'! Are you sure that your\n"
"name server, gateway and network interface are correctly configured?", hostname);
if (networkDev)
- networkDev->shutdown(networkDev);
+ DEVICE_SHUTDOWN(networkDev);
networkDev = NULL;
variable_unset(VAR_NFS_PATH);
return DITEM_FAILURE;
diff --git a/usr.sbin/sysinstall/nfs.c b/usr.sbin/sysinstall/nfs.c
index f9a557239a92..2f096377b6fe 100644
--- a/usr.sbin/sysinstall/nfs.c
+++ b/usr.sbin/sysinstall/nfs.c
@@ -53,7 +53,7 @@ mediaInitNFS(Device *dev)
if (NFSMounted)
return TRUE;
- if (netDevice && !netDevice->init(netDevice))
+ if (!DEVICE_INIT(netDevice))
return FALSE;
if (Mkdir(mountpoint))
@@ -65,7 +65,7 @@ mediaInitNFS(Device *dev)
variable_get(VAR_NFS_SECURE) ? "-P" : "", dev->name, mountpoint)) {
msgConfirm("Error mounting %s on %s: %s.", dev->name, mountpoint, strerror(errno));
if (netDevice)
- netDevice->shutdown(netDevice);
+ DEVICE_SHUTDOWN(netDevice);
restorescr(w);
return FALSE;
}
diff --git a/usr.sbin/sysinstall/package.c b/usr.sbin/sysinstall/package.c
index 577421fc5677..73600bfae44e 100644
--- a/usr.sbin/sysinstall/package.c
+++ b/usr.sbin/sysinstall/package.c
@@ -61,7 +61,7 @@ package_add(char *name)
if (!mediaVerify())
return DITEM_FAILURE;
- if (!mediaDevice->init(mediaDevice))
+ if (!DEVICE_INIT(mediaDevice))
return DITEM_FAILURE;
i = index_initialize("packages/INDEX");
@@ -123,7 +123,7 @@ package_extract(Device *dev, char *name, Boolean depended)
if (package_exists(name))
return DITEM_SUCCESS;
- if (!dev->init(dev)) {
+ if (!DEVICE_INIT(dev)) {
msgConfirm("Unable to initialize media type for package extract.");
return DITEM_FAILURE;
}
@@ -154,7 +154,7 @@ package_extract(Device *dev, char *name, Boolean depended)
sprintf(path, "%s%s", name, strstr(name, ".tgz") ? "" : ".tgz");
/* We have a path, call the device strategy routine to get the file */
- fp = dev->get(dev, path, TRUE);
+ fp = DEVICE_GET(dev, path, TRUE);
if (fp) {
int i = 0, tot, pfd[2];
pid_t pid;
diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h
index b8cf0e1f7b0c..0f8fd7540e32 100644
--- a/usr.sbin/sysinstall/sysinstall.h
+++ b/usr.sbin/sysinstall/sysinstall.h
@@ -770,5 +770,12 @@ extern int dump_variables(dialogMenuItem *self);
/* wizard.c */
extern void slice_wizard(Disk *d);
+/*
+ * Macros. Please find a better place for us!
+ */
+#define DEVICE_INIT(d) ((d) != NULL ? (d)->init((d)) : NULL)
+#define DEVICE_GET(d, b, f) ((d) != NULL ? (d)->get((d), (b), (f)) : NULL)
+#define DEVICE_SHUTDOWN(d) ((d) != NULL ? (d)->shutdown((d)) : (void)0)
+
#endif
/* _SYSINSTALL_H_INCLUDE */
diff --git a/usr.sbin/sysinstall/tcpip.c b/usr.sbin/sysinstall/tcpip.c
index 1be52391c9a9..fee6283f47e1 100644
--- a/usr.sbin/sysinstall/tcpip.c
+++ b/usr.sbin/sysinstall/tcpip.c
@@ -644,7 +644,7 @@ tcpMenuSelect(dialogMenuItem *self)
variable_unset("NETWORK_CONFIGURED");
save = savescr();
if (tmp && tmp->private && !((DevInfo *)tmp->private)->use_dhcp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
- if (!tmp->init(tmp))
+ if (!DEVICE_INIT(tmp))
msgConfirm("Initialization of %s device failed.", tmp->name);
restorescr(save);
return DITEM_SUCCESS;