summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--release/sysinstall/devices.c311
-rw-r--r--release/sysinstall/floppy.c15
-rw-r--r--release/sysinstall/install.c6
-rw-r--r--release/sysinstall/menus.c6
-rw-r--r--usr.sbin/sade/devices.c311
-rw-r--r--usr.sbin/sade/install.c6
-rw-r--r--usr.sbin/sade/menus.c6
-rw-r--r--usr.sbin/sysinstall/devices.c311
-rw-r--r--usr.sbin/sysinstall/floppy.c15
-rw-r--r--usr.sbin/sysinstall/install.c6
-rw-r--r--usr.sbin/sysinstall/menus.c6
11 files changed, 524 insertions, 475 deletions
diff --git a/release/sysinstall/devices.c b/release/sysinstall/devices.c
index 8e34985..aebfe66 100644
--- a/release/sysinstall/devices.c
+++ b/release/sysinstall/devices.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: devices.c,v 1.67 1998/01/21 19:25:49 jkh Exp $
+ * $Id: devices.c,v 1.68 1998/01/22 21:14:31 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -52,50 +52,50 @@
static Device *Devices[DEV_MAX];
static int numDevs;
-static struct {
+static struct _devname {
DeviceType type;
char *name;
char *description;
+ int major, minor, delta, max;
+ char dev_type;
} device_names[] = {
- { DEVICE_TYPE_CDROM, "cd0a", "SCSI CDROM drive" },
- { DEVICE_TYPE_CDROM, "mcd0a", "Mitsumi (old model) CDROM drive" },
- { DEVICE_TYPE_CDROM, "scd0a", "Sony CDROM drive - CDU31/33A type", },
- { DEVICE_TYPE_CDROM, "matcd0a", "Matsushita CDROM ('sound blaster' type)" },
- { DEVICE_TYPE_CDROM, "wcd0c", "ATAPI IDE CDROM" },
- { DEVICE_TYPE_TAPE, "rst0", "SCSI tape drive" },
- { DEVICE_TYPE_TAPE, "rsa0", "SCSI tape drive (CAM)" },
- { DEVICE_TYPE_TAPE, "rft0", "Floppy tape drive (QIC-02)" },
- { DEVICE_TYPE_TAPE, "rwt0", "Wangtek tape drive" },
- { DEVICE_TYPE_DISK, "sd", "SCSI disk device" },
- { DEVICE_TYPE_DISK, "da", "SCSI disk device (CAM)" },
- { DEVICE_TYPE_DISK, "wd", "IDE/ESDI/MFM/ST506 disk device" },
- { DEVICE_TYPE_DISK, "wfd", "ATAPI floppy (LS-120) device" },
- { DEVICE_TYPE_DISK, "od", "SCSI optical disk device" },
- { DEVICE_TYPE_FLOPPY, "fd0", "floppy drive unit A" },
- { DEVICE_TYPE_FLOPPY, "fd1", "floppy drive unit B" },
- { DEVICE_TYPE_FLOPPY, "od0", "SCSI optical disk/floppy format" },
- { DEVICE_TYPE_NETWORK, "cuaa0", "%s on serial port 0 (COM1)" },
- { DEVICE_TYPE_NETWORK, "cuaa1", "%s on serial port 1 (COM2)" },
- { DEVICE_TYPE_NETWORK, "cuaa2", "%s on serial port 2 (COM3)" },
- { DEVICE_TYPE_NETWORK, "cuaa3", "%s on serial port 3 (COM4)" },
- { DEVICE_TYPE_NETWORK, "lp0", "Parallel Port IP (PLIP) using laplink cable" },
- { DEVICE_TYPE_NETWORK, "lo", "Loop-back (local) network interface" },
- { DEVICE_TYPE_NETWORK, "de", "DEC DE435 PCI NIC or other DC21040-AA based card" },
- { DEVICE_TYPE_NETWORK, "fxp", "Intel EtherExpress Pro/100B PCI Fast Ethernet card" },
- { DEVICE_TYPE_NETWORK, "ed", "WD/SMC 80xx; Novell NE1000/2000; 3Com 3C503 card" },
- { DEVICE_TYPE_NETWORK, "ep", "3Com 3C509 ethernet card" },
- { DEVICE_TYPE_NETWORK, "el", "3Com 3C501 ethernet card" },
- { DEVICE_TYPE_NETWORK, "ex", "Intel EtherExpress Pro/10 ethernet card" },
- { DEVICE_TYPE_NETWORK, "fe", "Fujitsu MB86960A/MB86965A ethernet card" },
- { DEVICE_TYPE_NETWORK, "ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210" },
- { DEVICE_TYPE_NETWORK, "ix", "Intel Etherexpress ethernet card" },
- { DEVICE_TYPE_NETWORK, "le", "DEC EtherWorks 2 or 3 ethernet card" },
- { DEVICE_TYPE_NETWORK, "lnc", "Lance/PCnet (Isolan/Novell NE2100/NE32-VL) ethernet" },
- { DEVICE_TYPE_NETWORK, "tx", "SMC 9432TX ethernet card" },
- { DEVICE_TYPE_NETWORK, "vx", "3COM 3c590 / 3c595 / 3c9xx ethernet card" },
- { DEVICE_TYPE_NETWORK, "ze", "IBM/National Semiconductor PCMCIA ethernet card" },
- { DEVICE_TYPE_NETWORK, "zp", "3Com Etherlink III PCMCIA ethernet card" },
- { NULL },
+ { DEVICE_TYPE_CDROM, "cd%dc", "SCSI CDROM drive", 6, 2, 8, 4, 'b' },
+ { DEVICE_TYPE_CDROM, "mcd%dc", "Mitsumi (old model) CDROM drive", 7, 2, 8, 4, 'b' },
+ { DEVICE_TYPE_CDROM, "scd%dc", "Sony CDROM drive - CDU31/33A type", 16, 2, 8, 4, 'b' },
+ { DEVICE_TYPE_CDROM, "matcd%dc", "Matsushita CDROM ('sound blaster' type)", 17, 2, 8, 4, 'b' },
+ { DEVICE_TYPE_CDROM, "wcd%dc", "ATAPI IDE CDROM", 19, 2, 8, 4, 'b' },
+ { DEVICE_TYPE_TAPE, "rst%d", "SCSI tape drive", 14, 0, 16, 4, 'c' },
+ { DEVICE_TYPE_TAPE, "rft%d", "Floppy tape drive (QIC-02)", 9, 32, 64, 4, 'c' },
+ { DEVICE_TYPE_TAPE, "rwt%d", "Wangtek tape drive", 10, 0, 1, 4, 'c' },
+ { DEVICE_TYPE_DISK, "sd%d", "SCSI disk device", 4, 65538, 8, 32, 'b' },
+ { DEVICE_TYPE_DISK, "rsd%d", "SCSI disk device", 13, 65538, 8, 32, 'c' },
+ { DEVICE_TYPE_DISK, "wd%d", "IDE/ESDI/MFM/ST506 disk device", 0, 65538, 8, 32, 'b' },
+ { DEVICE_TYPE_DISK, "rwd%d", "IDE/ESDI/MFM/ST506 disk device", 3, 65538, 8, 32, 'c' },
+ { DEVICE_TYPE_DISK, "od%d", "SCSI optical disk device", 20, 65538, 8, 4, 'b' },
+ { DEVICE_TYPE_DISK, "rod%d", "SCSI optical disk device", 70, 65538, 8, 4, 'c' },
+ { DEVICE_TYPE_DISK, "wfd%d", "ATAPI FLOPPY (LS-120) device", 24, 65538, 8, 4, 'b' },
+ { DEVICE_TYPE_DISK, "rwfd%d", "ATAPI FLOPPY (LS-120) device", 87, 65538, 8, 4, 'c' },
+ { DEVICE_TYPE_FLOPPY, "fd%d", "floppy drive unit A", 2, 0, 64, 4, 'b' },
+ { DEVICE_TYPE_FLOPPY, "worm%d", "SCSI optical disk / CDR", 23, 0, 1, 4, 'b' },
+ { DEVICE_TYPE_NETWORK, "cuaa%d", "%s on device %s (COM%d)", 28, 128, 1, 16, 'c' },
+ { DEVICE_TYPE_NETWORK, "lp", "Parallel Port IP (PLIP) peer connection" },
+ { DEVICE_TYPE_NETWORK, "lo", "Loop-back (local) network interface" },
+ { DEVICE_TYPE_NETWORK, "de", "DEC DE435 PCI NIC or other DC21040-AA based card" },
+ { DEVICE_TYPE_NETWORK, "fxp", "Intel EtherExpress Pro/100B PCI Fast Ethernet card" },
+ { DEVICE_TYPE_NETWORK, "ed", "WD/SMC 80xx; Novell NE1000/2000; 3Com 3C503 card" },
+ { DEVICE_TYPE_NETWORK, "ep", "3Com 3C509 ethernet card" },
+ { DEVICE_TYPE_NETWORK, "el", "3Com 3C501 ethernet card" },
+ { DEVICE_TYPE_NETWORK, "ex", "Intel EtherExpress Pro/10 ethernet card" },
+ { DEVICE_TYPE_NETWORK, "fe", "Fujitsu MB86960A/MB86965A ethernet card" },
+ { DEVICE_TYPE_NETWORK, "ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210" },
+ { DEVICE_TYPE_NETWORK, "ix", "Intel Etherexpress ethernet card" },
+ { DEVICE_TYPE_NETWORK, "le", "DEC EtherWorks 2 or 3 ethernet card" },
+ { DEVICE_TYPE_NETWORK, "lnc", "Lance/PCnet (Isolan/Novell NE2100/NE32-VL) ethernet" },
+ { DEVICE_TYPE_NETWORK, "tx", "SMC 9432TX ethernet card" },
+ { DEVICE_TYPE_NETWORK, "vx", "3COM 3c590 / 3c595 / 3c9xx ethernet card" },
+ { DEVICE_TYPE_NETWORK, "ze", "IBM/National Semiconductor PCMCIA ethernet card" },
+ { DEVICE_TYPE_NETWORK, "zp", "3Com Etherlink III PCMCIA ethernet card" },
+ { 0 },
};
Device *
@@ -130,17 +130,30 @@ dummyShutdown(Device *dev)
}
static int
-deviceTry(char *name, char *try)
+deviceTry(struct _devname dev, char *try, int i)
{
int fd;
-
- snprintf(try, FILENAME_MAX, "/dev/%s", name);
+ char unit[80];
+ mode_t m;
+ dev_t d;
+ int fail;
+
+ snprintf(unit, sizeof unit, dev.name, i);
+ snprintf(try, FILENAME_MAX, "/dev/%s", unit);
+ m = 0666;
+ if (dev.dev_type == 'c')
+ m |= S_IFCHR;
+ else
+ m |= S_IFBLK;
+ d = makedev(dev.major, dev.minor + (i * dev.delta));
+ fail = mknod(try, m, d);
fd = open(try, O_RDONLY);
if (fd > 0)
return fd;
- if (errno == EBUSY)
- return -1;
- snprintf(try, FILENAME_MAX, "/mnt/dev/%s", name);
+ else if (!fail)
+ (void)unlink(try);
+ /* Don't try a "make-under" here since we're using a fixit floppy in this case */
+ snprintf(try, FILENAME_MAX, "/mnt/dev/%s", unit);
fd = open(try, O_RDONLY);
return fd;
}
@@ -175,47 +188,14 @@ deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean e
void
deviceGetAll(void)
{
- int i, fd, s;
+ int i, j, fd, s;
struct ifconf ifc;
struct ifreq *ifptr, *end;
int ifflags;
char buffer[INTERFACE_MAX * sizeof(struct ifreq)];
char **names;
- /* Try and get the disks first */
- if ((names = Disk_Names()) != NULL) {
- int i;
-
- for (i = 0; names[i]; i++) {
- Chunk *c1;
- Disk *d;
-
- d = Open_Disk(names[i]);
- if (!d)
- msgFatal("Unable to open disk %s", names[i]);
-
- (void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE, NULL, NULL, NULL, d);
- msgDebug("Found a disk device named %s\n", names[i]);
-
- /* Look for existing DOS partitions to register */
- for (c1 = d->chunks->part; c1; c1 = c1->next) {
- if (c1->type == fat || c1->type == extended) {
- Device *dev;
- char devname[80];
-
- /* Got one! */
- sprintf(devname, "/dev/%s", c1->name);
- dev = deviceRegister(c1->name, c1->name, strdup(devname), DEVICE_TYPE_DOS, TRUE,
- mediaInitDOS, mediaGetDOS, mediaShutdownDOS, NULL);
- dev->private = c1;
- msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
- }
- }
- }
- free(names);
- }
-
- /* Now go for the network interfaces. Stolen shamelessly from ifconfig! */
+ /* First go for the network interfaces. Stolen shamelessly from ifconfig! */
ifc.ifc_len = sizeof(buffer);
ifc.ifc_buf = buffer;
@@ -238,7 +218,7 @@ deviceGetAll(void)
continue;
/* Eliminate network devices that don't make sense */
- if (!strncmp(ifptr->ifr_name, "lo0", 3))
+ if (!strncmp(ifptr->ifr_name, "lo", 2))
continue;
/* If we have a slip device, don't register it */
@@ -253,7 +233,9 @@ deviceGetAll(void)
for (i = 0, descr = NULL; device_names[i].name; i++) {
int len = strlen(device_names[i].name);
- if (!strncmp(ifptr->ifr_name, device_names[i].name, len)) {
+ if (!ifptr->ifr_name || !ifptr->ifr_name[0])
+ continue;
+ else if (!strncmp(ifptr->ifr_name, device_names[i].name, len)) {
descr = device_names[i].description;
break;
}
@@ -274,71 +256,114 @@ deviceGetAll(void)
}
skipif:
- /* Finally, try to find all the types of devices one might need
+ /* Next, try to find all the types of devices one might need
* during the second stage of the installation.
*/
for (i = 0; device_names[i].name; i++) {
- char try[FILENAME_MAX];
-
- switch(device_names[i].type) {
- case DEVICE_TYPE_CDROM:
- fd = deviceTry(device_names[i].name, try);
- msgDebug("Try for %s returns errno %d\n", device_names[i].name, errno);
- if (fd >= 0 || errno == EBUSY) { /* EBUSY if already mounted */
- if (fd >= 0) close(fd);
- (void)deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
- DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM,
- mediaShutdownCDROM, NULL);
- msgDebug("Found a CDROM device named %s\n", device_names[i].name);
- }
- break;
-
- case DEVICE_TYPE_TAPE:
- fd = deviceTry(device_names[i].name, try);
- if (fd >= 0) {
- close(fd);
- deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
- DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaShutdownTape, NULL);
- msgDebug("Found a TAPE device named %s\n", device_names[i].name);
- }
- break;
-
- case DEVICE_TYPE_FLOPPY:
- fd = deviceTry(device_names[i].name, try);
- if (fd >= 0) {
- close(fd);
- deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
- DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy,
- mediaShutdownFloppy, NULL);
- msgDebug("Found a floppy device named %s\n", device_names[i].name);
- }
- break;
-
- case DEVICE_TYPE_NETWORK:
- fd = deviceTry(device_names[i].name, try);
- /* The only network devices that you can open this way are serial ones */
- if (fd >= 0) {
- char *newdesc, *cp;
-
- close(fd);
- cp = device_names[i].description;
- /* Serial devices get a slip and ppp device each, if supported */
- newdesc = safe_malloc(strlen(cp) + 40);
- sprintf(newdesc, cp, "SLIP interface");
- deviceRegister("sl0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
- NULL, mediaShutdownNetwork, NULL);
- msgDebug("Add mapping for %s on %s to sl0\n", device_names[i].name, try);
- newdesc = safe_malloc(strlen(cp) + 50);
- sprintf(newdesc, cp, "PPP interface");
- deviceRegister("ppp0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
- NULL, mediaShutdownNetwork, NULL);
- msgDebug("Add mapping for %s on %s to ppp0\n", device_names[i].name, try);
+ for (j = 0; j < device_names[i].max; j++) {
+ char try[FILENAME_MAX];
+
+ switch(device_names[i].type) {
+ case DEVICE_TYPE_CDROM:
+ fd = deviceTry(device_names[i], try, j);
+ if (fd >= 0 || errno == EBUSY) { /* EBUSY if already mounted */
+ if (fd >= 0) close(fd);
+ (void)deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
+ DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM,
+ mediaShutdownCDROM, NULL);
+ msgDebug("Found a CDROM device for %s\n", try);
+ }
+ break;
+
+ case DEVICE_TYPE_TAPE:
+ fd = deviceTry(device_names[i], try, j);
+ if (fd >= 0) {
+ close(fd);
+ deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
+ DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaShutdownTape, NULL);
+ msgDebug("Found a TAPE device for %s\n", try);
+ }
+ break;
+
+ case DEVICE_TYPE_DISK:
+ /* We do this just for the side-effect of creating the device entries. The actual registration
+ is done through the libdisk API later. */
+ fd = deviceTry(device_names[i], try, j);
+ if (fd >= 0)
+ close(fd);
+ break;
+
+ case DEVICE_TYPE_FLOPPY:
+ fd = deviceTry(device_names[i], try, j);
+ if (fd >= 0) {
+ close(fd);
+ deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
+ DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy,
+ mediaShutdownFloppy, NULL);
+ msgDebug("Found a floppy device for %s\n", try);
+ }
+ break;
+
+ case DEVICE_TYPE_NETWORK:
+ fd = deviceTry(device_names[i], try, j);
+ /* The only network devices that you can open this way are serial ones */
+ if (fd >= 0) {
+ char *newdesc, *cp;
+
+ close(fd);
+ cp = device_names[i].description;
+ /* Serial devices get a slip and ppp device each, if supported */
+ newdesc = safe_malloc(strlen(cp) + 40);
+ sprintf(newdesc, cp, "SLIP interface", try, j + 1);
+ deviceRegister("sl0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
+ NULL, mediaShutdownNetwork, NULL);
+ msgDebug("Add mapping for %s to sl0\n", try);
+ newdesc = safe_malloc(strlen(cp) + 50);
+ sprintf(newdesc, cp, "PPP interface", try, j + 1);
+ deviceRegister("ppp0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
+ NULL, mediaShutdownNetwork, NULL);
+ msgDebug("Add mapping for %s to ppp0\n", try);
+ }
+ break;
+
+ default:
+ break;
}
- break;
+ }
+ }
+
+ /* Finally, go get the disks and look for DOS partitions to register */
+ if ((names = Disk_Names()) != NULL) {
+ int i;
+
+ for (i = 0; names[i]; i++) {
+ Chunk *c1;
+ Disk *d;
- default:
- break;
+ d = Open_Disk(names[i]);
+ if (!d)
+ msgFatal("Unable to open disk %s", names[i]);
+
+ deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE,
+ dummyInit, dummyGet, dummyShutdown, d);
+ msgDebug("Found a disk device named %s\n", names[i]);
+
+ /* Look for existing DOS partitions to register as "DOS media devices" */
+ for (c1 = d->chunks->part; c1; c1 = c1->next) {
+ if (c1->type == fat || c1->type == extended) {
+ Device *dev;
+ char devname[80];
+
+ /* Got one! */
+ snprintf(devname, sizeof devname, "/dev/%s", c1->name);
+ dev = deviceRegister(c1->name, c1->name, strdup(devname), DEVICE_TYPE_DOS, TRUE,
+ mediaInitDOS, mediaGetDOS, mediaShutdownDOS, NULL);
+ dev->private = c1;
+ msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
+ }
+ }
}
+ free(names);
}
}
diff --git a/release/sysinstall/floppy.c b/release/sysinstall/floppy.c
index c5bae4a..ec3f70c 100644
--- a/release/sysinstall/floppy.c
+++ b/release/sysinstall/floppy.c
@@ -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.26 1998/01/16 15:07:54 jkh Exp $
+ * $Id: floppy.c,v 1.27 1998/02/08 20:18:19 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -53,23 +53,10 @@
#undef MSDOSFS
#include <ufs/ufs/ufsmount.h>
-static Device *floppyDev;
static Boolean floppyMounted;
char *distWanted;
-/* For finding floppies */
-static int
-floppyChoiceHook(dialogMenuItem *self)
-{
- Device **devs;
-
- devs = deviceFind(self->prompt, DEVICE_TYPE_FLOPPY);
- if (devs)
- floppyDev = devs[0];
- return devs ? DITEM_LEAVE_MENU : DITEM_FAILURE;
-}
-
Boolean
mediaInitFloppy(Device *dev)
{
diff --git a/release/sysinstall/install.c b/release/sysinstall/install.c
index 2a7d183..6c989f9 100644
--- a/release/sysinstall/install.c
+++ b/release/sysinstall/install.c
@@ -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.203 1997/12/29 20:07:17 jkh Exp $
+ * $Id: install.c,v 1.204 1998/01/16 15:07:55 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -874,7 +874,7 @@ installFilesystems(dialogMenuItem *self)
if (rootdev && RunningAsInit) {
/* Next, create and/or mount the root device */
- sprintf(dname, "/dev/r%sa", rootdev->disk->name);
+ sprintf(dname, "/dev/r%s", rootdev->name);
if (!Fake && (!MakeDevChunk(rootdev, "/dev") || !file_readable(dname))) {
msgConfirm("Unable to make device node for %s in /dev!\n"
"The creation of filesystems will be aborted.", dname);
@@ -907,7 +907,7 @@ installFilesystems(dialogMenuItem *self)
}
/* Switch to block device */
- sprintf(dname, "/dev/%sa", rootdev->disk->name);
+ sprintf(dname, "/dev/%s", rootdev->name);
if (Mount("/mnt", dname)) {
msgConfirm("Unable to mount the root file system on %s! Giving up.", dname);
return DITEM_FAILURE;
diff --git a/release/sysinstall/menus.c b/release/sysinstall/menus.c
index 323947e..87959a7 100644
--- a/release/sysinstall/menus.c
+++ b/release/sysinstall/menus.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: menus.c,v 1.151 1997/11/26 22:48:24 joerg Exp $
+ * $Id: menus.c,v 1.152 1998/01/27 14:01:19 yokota Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -632,8 +632,8 @@ DMenu MenuNetworkDevice = {
"If you're using SLIP over a serial device then the expectation is\n"
"that you have a HARDWIRED connection.\n\n"
"You can also install over a parallel port using a special \"laplink\"\n"
- "cable to another machine running a fairly recent (2.0R or later) version\n"
- "of FreeBSD.",
+ "cable to another machine running a fairly recent (2.0R or later)\n"
+ "version of FreeBSD.",
"Press F1 to read network configuration manual",
"network_device",
{ { NULL } },
diff --git a/usr.sbin/sade/devices.c b/usr.sbin/sade/devices.c
index 8e34985..aebfe66 100644
--- a/usr.sbin/sade/devices.c
+++ b/usr.sbin/sade/devices.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: devices.c,v 1.67 1998/01/21 19:25:49 jkh Exp $
+ * $Id: devices.c,v 1.68 1998/01/22 21:14:31 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -52,50 +52,50 @@
static Device *Devices[DEV_MAX];
static int numDevs;
-static struct {
+static struct _devname {
DeviceType type;
char *name;
char *description;
+ int major, minor, delta, max;
+ char dev_type;
} device_names[] = {
- { DEVICE_TYPE_CDROM, "cd0a", "SCSI CDROM drive" },
- { DEVICE_TYPE_CDROM, "mcd0a", "Mitsumi (old model) CDROM drive" },
- { DEVICE_TYPE_CDROM, "scd0a", "Sony CDROM drive - CDU31/33A type", },
- { DEVICE_TYPE_CDROM, "matcd0a", "Matsushita CDROM ('sound blaster' type)" },
- { DEVICE_TYPE_CDROM, "wcd0c", "ATAPI IDE CDROM" },
- { DEVICE_TYPE_TAPE, "rst0", "SCSI tape drive" },
- { DEVICE_TYPE_TAPE, "rsa0", "SCSI tape drive (CAM)" },
- { DEVICE_TYPE_TAPE, "rft0", "Floppy tape drive (QIC-02)" },
- { DEVICE_TYPE_TAPE, "rwt0", "Wangtek tape drive" },
- { DEVICE_TYPE_DISK, "sd", "SCSI disk device" },
- { DEVICE_TYPE_DISK, "da", "SCSI disk device (CAM)" },
- { DEVICE_TYPE_DISK, "wd", "IDE/ESDI/MFM/ST506 disk device" },
- { DEVICE_TYPE_DISK, "wfd", "ATAPI floppy (LS-120) device" },
- { DEVICE_TYPE_DISK, "od", "SCSI optical disk device" },
- { DEVICE_TYPE_FLOPPY, "fd0", "floppy drive unit A" },
- { DEVICE_TYPE_FLOPPY, "fd1", "floppy drive unit B" },
- { DEVICE_TYPE_FLOPPY, "od0", "SCSI optical disk/floppy format" },
- { DEVICE_TYPE_NETWORK, "cuaa0", "%s on serial port 0 (COM1)" },
- { DEVICE_TYPE_NETWORK, "cuaa1", "%s on serial port 1 (COM2)" },
- { DEVICE_TYPE_NETWORK, "cuaa2", "%s on serial port 2 (COM3)" },
- { DEVICE_TYPE_NETWORK, "cuaa3", "%s on serial port 3 (COM4)" },
- { DEVICE_TYPE_NETWORK, "lp0", "Parallel Port IP (PLIP) using laplink cable" },
- { DEVICE_TYPE_NETWORK, "lo", "Loop-back (local) network interface" },
- { DEVICE_TYPE_NETWORK, "de", "DEC DE435 PCI NIC or other DC21040-AA based card" },
- { DEVICE_TYPE_NETWORK, "fxp", "Intel EtherExpress Pro/100B PCI Fast Ethernet card" },
- { DEVICE_TYPE_NETWORK, "ed", "WD/SMC 80xx; Novell NE1000/2000; 3Com 3C503 card" },
- { DEVICE_TYPE_NETWORK, "ep", "3Com 3C509 ethernet card" },
- { DEVICE_TYPE_NETWORK, "el", "3Com 3C501 ethernet card" },
- { DEVICE_TYPE_NETWORK, "ex", "Intel EtherExpress Pro/10 ethernet card" },
- { DEVICE_TYPE_NETWORK, "fe", "Fujitsu MB86960A/MB86965A ethernet card" },
- { DEVICE_TYPE_NETWORK, "ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210" },
- { DEVICE_TYPE_NETWORK, "ix", "Intel Etherexpress ethernet card" },
- { DEVICE_TYPE_NETWORK, "le", "DEC EtherWorks 2 or 3 ethernet card" },
- { DEVICE_TYPE_NETWORK, "lnc", "Lance/PCnet (Isolan/Novell NE2100/NE32-VL) ethernet" },
- { DEVICE_TYPE_NETWORK, "tx", "SMC 9432TX ethernet card" },
- { DEVICE_TYPE_NETWORK, "vx", "3COM 3c590 / 3c595 / 3c9xx ethernet card" },
- { DEVICE_TYPE_NETWORK, "ze", "IBM/National Semiconductor PCMCIA ethernet card" },
- { DEVICE_TYPE_NETWORK, "zp", "3Com Etherlink III PCMCIA ethernet card" },
- { NULL },
+ { DEVICE_TYPE_CDROM, "cd%dc", "SCSI CDROM drive", 6, 2, 8, 4, 'b' },
+ { DEVICE_TYPE_CDROM, "mcd%dc", "Mitsumi (old model) CDROM drive", 7, 2, 8, 4, 'b' },
+ { DEVICE_TYPE_CDROM, "scd%dc", "Sony CDROM drive - CDU31/33A type", 16, 2, 8, 4, 'b' },
+ { DEVICE_TYPE_CDROM, "matcd%dc", "Matsushita CDROM ('sound blaster' type)", 17, 2, 8, 4, 'b' },
+ { DEVICE_TYPE_CDROM, "wcd%dc", "ATAPI IDE CDROM", 19, 2, 8, 4, 'b' },
+ { DEVICE_TYPE_TAPE, "rst%d", "SCSI tape drive", 14, 0, 16, 4, 'c' },
+ { DEVICE_TYPE_TAPE, "rft%d", "Floppy tape drive (QIC-02)", 9, 32, 64, 4, 'c' },
+ { DEVICE_TYPE_TAPE, "rwt%d", "Wangtek tape drive", 10, 0, 1, 4, 'c' },
+ { DEVICE_TYPE_DISK, "sd%d", "SCSI disk device", 4, 65538, 8, 32, 'b' },
+ { DEVICE_TYPE_DISK, "rsd%d", "SCSI disk device", 13, 65538, 8, 32, 'c' },
+ { DEVICE_TYPE_DISK, "wd%d", "IDE/ESDI/MFM/ST506 disk device", 0, 65538, 8, 32, 'b' },
+ { DEVICE_TYPE_DISK, "rwd%d", "IDE/ESDI/MFM/ST506 disk device", 3, 65538, 8, 32, 'c' },
+ { DEVICE_TYPE_DISK, "od%d", "SCSI optical disk device", 20, 65538, 8, 4, 'b' },
+ { DEVICE_TYPE_DISK, "rod%d", "SCSI optical disk device", 70, 65538, 8, 4, 'c' },
+ { DEVICE_TYPE_DISK, "wfd%d", "ATAPI FLOPPY (LS-120) device", 24, 65538, 8, 4, 'b' },
+ { DEVICE_TYPE_DISK, "rwfd%d", "ATAPI FLOPPY (LS-120) device", 87, 65538, 8, 4, 'c' },
+ { DEVICE_TYPE_FLOPPY, "fd%d", "floppy drive unit A", 2, 0, 64, 4, 'b' },
+ { DEVICE_TYPE_FLOPPY, "worm%d", "SCSI optical disk / CDR", 23, 0, 1, 4, 'b' },
+ { DEVICE_TYPE_NETWORK, "cuaa%d", "%s on device %s (COM%d)", 28, 128, 1, 16, 'c' },
+ { DEVICE_TYPE_NETWORK, "lp", "Parallel Port IP (PLIP) peer connection" },
+ { DEVICE_TYPE_NETWORK, "lo", "Loop-back (local) network interface" },
+ { DEVICE_TYPE_NETWORK, "de", "DEC DE435 PCI NIC or other DC21040-AA based card" },
+ { DEVICE_TYPE_NETWORK, "fxp", "Intel EtherExpress Pro/100B PCI Fast Ethernet card" },
+ { DEVICE_TYPE_NETWORK, "ed", "WD/SMC 80xx; Novell NE1000/2000; 3Com 3C503 card" },
+ { DEVICE_TYPE_NETWORK, "ep", "3Com 3C509 ethernet card" },
+ { DEVICE_TYPE_NETWORK, "el", "3Com 3C501 ethernet card" },
+ { DEVICE_TYPE_NETWORK, "ex", "Intel EtherExpress Pro/10 ethernet card" },
+ { DEVICE_TYPE_NETWORK, "fe", "Fujitsu MB86960A/MB86965A ethernet card" },
+ { DEVICE_TYPE_NETWORK, "ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210" },
+ { DEVICE_TYPE_NETWORK, "ix", "Intel Etherexpress ethernet card" },
+ { DEVICE_TYPE_NETWORK, "le", "DEC EtherWorks 2 or 3 ethernet card" },
+ { DEVICE_TYPE_NETWORK, "lnc", "Lance/PCnet (Isolan/Novell NE2100/NE32-VL) ethernet" },
+ { DEVICE_TYPE_NETWORK, "tx", "SMC 9432TX ethernet card" },
+ { DEVICE_TYPE_NETWORK, "vx", "3COM 3c590 / 3c595 / 3c9xx ethernet card" },
+ { DEVICE_TYPE_NETWORK, "ze", "IBM/National Semiconductor PCMCIA ethernet card" },
+ { DEVICE_TYPE_NETWORK, "zp", "3Com Etherlink III PCMCIA ethernet card" },
+ { 0 },
};
Device *
@@ -130,17 +130,30 @@ dummyShutdown(Device *dev)
}
static int
-deviceTry(char *name, char *try)
+deviceTry(struct _devname dev, char *try, int i)
{
int fd;
-
- snprintf(try, FILENAME_MAX, "/dev/%s", name);
+ char unit[80];
+ mode_t m;
+ dev_t d;
+ int fail;
+
+ snprintf(unit, sizeof unit, dev.name, i);
+ snprintf(try, FILENAME_MAX, "/dev/%s", unit);
+ m = 0666;
+ if (dev.dev_type == 'c')
+ m |= S_IFCHR;
+ else
+ m |= S_IFBLK;
+ d = makedev(dev.major, dev.minor + (i * dev.delta));
+ fail = mknod(try, m, d);
fd = open(try, O_RDONLY);
if (fd > 0)
return fd;
- if (errno == EBUSY)
- return -1;
- snprintf(try, FILENAME_MAX, "/mnt/dev/%s", name);
+ else if (!fail)
+ (void)unlink(try);
+ /* Don't try a "make-under" here since we're using a fixit floppy in this case */
+ snprintf(try, FILENAME_MAX, "/mnt/dev/%s", unit);
fd = open(try, O_RDONLY);
return fd;
}
@@ -175,47 +188,14 @@ deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean e
void
deviceGetAll(void)
{
- int i, fd, s;
+ int i, j, fd, s;
struct ifconf ifc;
struct ifreq *ifptr, *end;
int ifflags;
char buffer[INTERFACE_MAX * sizeof(struct ifreq)];
char **names;
- /* Try and get the disks first */
- if ((names = Disk_Names()) != NULL) {
- int i;
-
- for (i = 0; names[i]; i++) {
- Chunk *c1;
- Disk *d;
-
- d = Open_Disk(names[i]);
- if (!d)
- msgFatal("Unable to open disk %s", names[i]);
-
- (void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE, NULL, NULL, NULL, d);
- msgDebug("Found a disk device named %s\n", names[i]);
-
- /* Look for existing DOS partitions to register */
- for (c1 = d->chunks->part; c1; c1 = c1->next) {
- if (c1->type == fat || c1->type == extended) {
- Device *dev;
- char devname[80];
-
- /* Got one! */
- sprintf(devname, "/dev/%s", c1->name);
- dev = deviceRegister(c1->name, c1->name, strdup(devname), DEVICE_TYPE_DOS, TRUE,
- mediaInitDOS, mediaGetDOS, mediaShutdownDOS, NULL);
- dev->private = c1;
- msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
- }
- }
- }
- free(names);
- }
-
- /* Now go for the network interfaces. Stolen shamelessly from ifconfig! */
+ /* First go for the network interfaces. Stolen shamelessly from ifconfig! */
ifc.ifc_len = sizeof(buffer);
ifc.ifc_buf = buffer;
@@ -238,7 +218,7 @@ deviceGetAll(void)
continue;
/* Eliminate network devices that don't make sense */
- if (!strncmp(ifptr->ifr_name, "lo0", 3))
+ if (!strncmp(ifptr->ifr_name, "lo", 2))
continue;
/* If we have a slip device, don't register it */
@@ -253,7 +233,9 @@ deviceGetAll(void)
for (i = 0, descr = NULL; device_names[i].name; i++) {
int len = strlen(device_names[i].name);
- if (!strncmp(ifptr->ifr_name, device_names[i].name, len)) {
+ if (!ifptr->ifr_name || !ifptr->ifr_name[0])
+ continue;
+ else if (!strncmp(ifptr->ifr_name, device_names[i].name, len)) {
descr = device_names[i].description;
break;
}
@@ -274,71 +256,114 @@ deviceGetAll(void)
}
skipif:
- /* Finally, try to find all the types of devices one might need
+ /* Next, try to find all the types of devices one might need
* during the second stage of the installation.
*/
for (i = 0; device_names[i].name; i++) {
- char try[FILENAME_MAX];
-
- switch(device_names[i].type) {
- case DEVICE_TYPE_CDROM:
- fd = deviceTry(device_names[i].name, try);
- msgDebug("Try for %s returns errno %d\n", device_names[i].name, errno);
- if (fd >= 0 || errno == EBUSY) { /* EBUSY if already mounted */
- if (fd >= 0) close(fd);
- (void)deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
- DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM,
- mediaShutdownCDROM, NULL);
- msgDebug("Found a CDROM device named %s\n", device_names[i].name);
- }
- break;
-
- case DEVICE_TYPE_TAPE:
- fd = deviceTry(device_names[i].name, try);
- if (fd >= 0) {
- close(fd);
- deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
- DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaShutdownTape, NULL);
- msgDebug("Found a TAPE device named %s\n", device_names[i].name);
- }
- break;
-
- case DEVICE_TYPE_FLOPPY:
- fd = deviceTry(device_names[i].name, try);
- if (fd >= 0) {
- close(fd);
- deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
- DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy,
- mediaShutdownFloppy, NULL);
- msgDebug("Found a floppy device named %s\n", device_names[i].name);
- }
- break;
-
- case DEVICE_TYPE_NETWORK:
- fd = deviceTry(device_names[i].name, try);
- /* The only network devices that you can open this way are serial ones */
- if (fd >= 0) {
- char *newdesc, *cp;
-
- close(fd);
- cp = device_names[i].description;
- /* Serial devices get a slip and ppp device each, if supported */
- newdesc = safe_malloc(strlen(cp) + 40);
- sprintf(newdesc, cp, "SLIP interface");
- deviceRegister("sl0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
- NULL, mediaShutdownNetwork, NULL);
- msgDebug("Add mapping for %s on %s to sl0\n", device_names[i].name, try);
- newdesc = safe_malloc(strlen(cp) + 50);
- sprintf(newdesc, cp, "PPP interface");
- deviceRegister("ppp0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
- NULL, mediaShutdownNetwork, NULL);
- msgDebug("Add mapping for %s on %s to ppp0\n", device_names[i].name, try);
+ for (j = 0; j < device_names[i].max; j++) {
+ char try[FILENAME_MAX];
+
+ switch(device_names[i].type) {
+ case DEVICE_TYPE_CDROM:
+ fd = deviceTry(device_names[i], try, j);
+ if (fd >= 0 || errno == EBUSY) { /* EBUSY if already mounted */
+ if (fd >= 0) close(fd);
+ (void)deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
+ DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM,
+ mediaShutdownCDROM, NULL);
+ msgDebug("Found a CDROM device for %s\n", try);
+ }
+ break;
+
+ case DEVICE_TYPE_TAPE:
+ fd = deviceTry(device_names[i], try, j);
+ if (fd >= 0) {
+ close(fd);
+ deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
+ DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaShutdownTape, NULL);
+ msgDebug("Found a TAPE device for %s\n", try);
+ }
+ break;
+
+ case DEVICE_TYPE_DISK:
+ /* We do this just for the side-effect of creating the device entries. The actual registration
+ is done through the libdisk API later. */
+ fd = deviceTry(device_names[i], try, j);
+ if (fd >= 0)
+ close(fd);
+ break;
+
+ case DEVICE_TYPE_FLOPPY:
+ fd = deviceTry(device_names[i], try, j);
+ if (fd >= 0) {
+ close(fd);
+ deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
+ DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy,
+ mediaShutdownFloppy, NULL);
+ msgDebug("Found a floppy device for %s\n", try);
+ }
+ break;
+
+ case DEVICE_TYPE_NETWORK:
+ fd = deviceTry(device_names[i], try, j);
+ /* The only network devices that you can open this way are serial ones */
+ if (fd >= 0) {
+ char *newdesc, *cp;
+
+ close(fd);
+ cp = device_names[i].description;
+ /* Serial devices get a slip and ppp device each, if supported */
+ newdesc = safe_malloc(strlen(cp) + 40);
+ sprintf(newdesc, cp, "SLIP interface", try, j + 1);
+ deviceRegister("sl0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
+ NULL, mediaShutdownNetwork, NULL);
+ msgDebug("Add mapping for %s to sl0\n", try);
+ newdesc = safe_malloc(strlen(cp) + 50);
+ sprintf(newdesc, cp, "PPP interface", try, j + 1);
+ deviceRegister("ppp0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
+ NULL, mediaShutdownNetwork, NULL);
+ msgDebug("Add mapping for %s to ppp0\n", try);
+ }
+ break;
+
+ default:
+ break;
}
- break;
+ }
+ }
+
+ /* Finally, go get the disks and look for DOS partitions to register */
+ if ((names = Disk_Names()) != NULL) {
+ int i;
+
+ for (i = 0; names[i]; i++) {
+ Chunk *c1;
+ Disk *d;
- default:
- break;
+ d = Open_Disk(names[i]);
+ if (!d)
+ msgFatal("Unable to open disk %s", names[i]);
+
+ deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE,
+ dummyInit, dummyGet, dummyShutdown, d);
+ msgDebug("Found a disk device named %s\n", names[i]);
+
+ /* Look for existing DOS partitions to register as "DOS media devices" */
+ for (c1 = d->chunks->part; c1; c1 = c1->next) {
+ if (c1->type == fat || c1->type == extended) {
+ Device *dev;
+ char devname[80];
+
+ /* Got one! */
+ snprintf(devname, sizeof devname, "/dev/%s", c1->name);
+ dev = deviceRegister(c1->name, c1->name, strdup(devname), DEVICE_TYPE_DOS, TRUE,
+ mediaInitDOS, mediaGetDOS, mediaShutdownDOS, NULL);
+ dev->private = c1;
+ msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
+ }
+ }
}
+ free(names);
}
}
diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c
index 2a7d183..6c989f9 100644
--- a/usr.sbin/sade/install.c
+++ b/usr.sbin/sade/install.c
@@ -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.203 1997/12/29 20:07:17 jkh Exp $
+ * $Id: install.c,v 1.204 1998/01/16 15:07:55 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -874,7 +874,7 @@ installFilesystems(dialogMenuItem *self)
if (rootdev && RunningAsInit) {
/* Next, create and/or mount the root device */
- sprintf(dname, "/dev/r%sa", rootdev->disk->name);
+ sprintf(dname, "/dev/r%s", rootdev->name);
if (!Fake && (!MakeDevChunk(rootdev, "/dev") || !file_readable(dname))) {
msgConfirm("Unable to make device node for %s in /dev!\n"
"The creation of filesystems will be aborted.", dname);
@@ -907,7 +907,7 @@ installFilesystems(dialogMenuItem *self)
}
/* Switch to block device */
- sprintf(dname, "/dev/%sa", rootdev->disk->name);
+ sprintf(dname, "/dev/%s", rootdev->name);
if (Mount("/mnt", dname)) {
msgConfirm("Unable to mount the root file system on %s! Giving up.", dname);
return DITEM_FAILURE;
diff --git a/usr.sbin/sade/menus.c b/usr.sbin/sade/menus.c
index 323947e..87959a7 100644
--- a/usr.sbin/sade/menus.c
+++ b/usr.sbin/sade/menus.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: menus.c,v 1.151 1997/11/26 22:48:24 joerg Exp $
+ * $Id: menus.c,v 1.152 1998/01/27 14:01:19 yokota Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -632,8 +632,8 @@ DMenu MenuNetworkDevice = {
"If you're using SLIP over a serial device then the expectation is\n"
"that you have a HARDWIRED connection.\n\n"
"You can also install over a parallel port using a special \"laplink\"\n"
- "cable to another machine running a fairly recent (2.0R or later) version\n"
- "of FreeBSD.",
+ "cable to another machine running a fairly recent (2.0R or later)\n"
+ "version of FreeBSD.",
"Press F1 to read network configuration manual",
"network_device",
{ { NULL } },
diff --git a/usr.sbin/sysinstall/devices.c b/usr.sbin/sysinstall/devices.c
index 8e34985..aebfe66 100644
--- a/usr.sbin/sysinstall/devices.c
+++ b/usr.sbin/sysinstall/devices.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: devices.c,v 1.67 1998/01/21 19:25:49 jkh Exp $
+ * $Id: devices.c,v 1.68 1998/01/22 21:14:31 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -52,50 +52,50 @@
static Device *Devices[DEV_MAX];
static int numDevs;
-static struct {
+static struct _devname {
DeviceType type;
char *name;
char *description;
+ int major, minor, delta, max;
+ char dev_type;
} device_names[] = {
- { DEVICE_TYPE_CDROM, "cd0a", "SCSI CDROM drive" },
- { DEVICE_TYPE_CDROM, "mcd0a", "Mitsumi (old model) CDROM drive" },
- { DEVICE_TYPE_CDROM, "scd0a", "Sony CDROM drive - CDU31/33A type", },
- { DEVICE_TYPE_CDROM, "matcd0a", "Matsushita CDROM ('sound blaster' type)" },
- { DEVICE_TYPE_CDROM, "wcd0c", "ATAPI IDE CDROM" },
- { DEVICE_TYPE_TAPE, "rst0", "SCSI tape drive" },
- { DEVICE_TYPE_TAPE, "rsa0", "SCSI tape drive (CAM)" },
- { DEVICE_TYPE_TAPE, "rft0", "Floppy tape drive (QIC-02)" },
- { DEVICE_TYPE_TAPE, "rwt0", "Wangtek tape drive" },
- { DEVICE_TYPE_DISK, "sd", "SCSI disk device" },
- { DEVICE_TYPE_DISK, "da", "SCSI disk device (CAM)" },
- { DEVICE_TYPE_DISK, "wd", "IDE/ESDI/MFM/ST506 disk device" },
- { DEVICE_TYPE_DISK, "wfd", "ATAPI floppy (LS-120) device" },
- { DEVICE_TYPE_DISK, "od", "SCSI optical disk device" },
- { DEVICE_TYPE_FLOPPY, "fd0", "floppy drive unit A" },
- { DEVICE_TYPE_FLOPPY, "fd1", "floppy drive unit B" },
- { DEVICE_TYPE_FLOPPY, "od0", "SCSI optical disk/floppy format" },
- { DEVICE_TYPE_NETWORK, "cuaa0", "%s on serial port 0 (COM1)" },
- { DEVICE_TYPE_NETWORK, "cuaa1", "%s on serial port 1 (COM2)" },
- { DEVICE_TYPE_NETWORK, "cuaa2", "%s on serial port 2 (COM3)" },
- { DEVICE_TYPE_NETWORK, "cuaa3", "%s on serial port 3 (COM4)" },
- { DEVICE_TYPE_NETWORK, "lp0", "Parallel Port IP (PLIP) using laplink cable" },
- { DEVICE_TYPE_NETWORK, "lo", "Loop-back (local) network interface" },
- { DEVICE_TYPE_NETWORK, "de", "DEC DE435 PCI NIC or other DC21040-AA based card" },
- { DEVICE_TYPE_NETWORK, "fxp", "Intel EtherExpress Pro/100B PCI Fast Ethernet card" },
- { DEVICE_TYPE_NETWORK, "ed", "WD/SMC 80xx; Novell NE1000/2000; 3Com 3C503 card" },
- { DEVICE_TYPE_NETWORK, "ep", "3Com 3C509 ethernet card" },
- { DEVICE_TYPE_NETWORK, "el", "3Com 3C501 ethernet card" },
- { DEVICE_TYPE_NETWORK, "ex", "Intel EtherExpress Pro/10 ethernet card" },
- { DEVICE_TYPE_NETWORK, "fe", "Fujitsu MB86960A/MB86965A ethernet card" },
- { DEVICE_TYPE_NETWORK, "ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210" },
- { DEVICE_TYPE_NETWORK, "ix", "Intel Etherexpress ethernet card" },
- { DEVICE_TYPE_NETWORK, "le", "DEC EtherWorks 2 or 3 ethernet card" },
- { DEVICE_TYPE_NETWORK, "lnc", "Lance/PCnet (Isolan/Novell NE2100/NE32-VL) ethernet" },
- { DEVICE_TYPE_NETWORK, "tx", "SMC 9432TX ethernet card" },
- { DEVICE_TYPE_NETWORK, "vx", "3COM 3c590 / 3c595 / 3c9xx ethernet card" },
- { DEVICE_TYPE_NETWORK, "ze", "IBM/National Semiconductor PCMCIA ethernet card" },
- { DEVICE_TYPE_NETWORK, "zp", "3Com Etherlink III PCMCIA ethernet card" },
- { NULL },
+ { DEVICE_TYPE_CDROM, "cd%dc", "SCSI CDROM drive", 6, 2, 8, 4, 'b' },
+ { DEVICE_TYPE_CDROM, "mcd%dc", "Mitsumi (old model) CDROM drive", 7, 2, 8, 4, 'b' },
+ { DEVICE_TYPE_CDROM, "scd%dc", "Sony CDROM drive - CDU31/33A type", 16, 2, 8, 4, 'b' },
+ { DEVICE_TYPE_CDROM, "matcd%dc", "Matsushita CDROM ('sound blaster' type)", 17, 2, 8, 4, 'b' },
+ { DEVICE_TYPE_CDROM, "wcd%dc", "ATAPI IDE CDROM", 19, 2, 8, 4, 'b' },
+ { DEVICE_TYPE_TAPE, "rst%d", "SCSI tape drive", 14, 0, 16, 4, 'c' },
+ { DEVICE_TYPE_TAPE, "rft%d", "Floppy tape drive (QIC-02)", 9, 32, 64, 4, 'c' },
+ { DEVICE_TYPE_TAPE, "rwt%d", "Wangtek tape drive", 10, 0, 1, 4, 'c' },
+ { DEVICE_TYPE_DISK, "sd%d", "SCSI disk device", 4, 65538, 8, 32, 'b' },
+ { DEVICE_TYPE_DISK, "rsd%d", "SCSI disk device", 13, 65538, 8, 32, 'c' },
+ { DEVICE_TYPE_DISK, "wd%d", "IDE/ESDI/MFM/ST506 disk device", 0, 65538, 8, 32, 'b' },
+ { DEVICE_TYPE_DISK, "rwd%d", "IDE/ESDI/MFM/ST506 disk device", 3, 65538, 8, 32, 'c' },
+ { DEVICE_TYPE_DISK, "od%d", "SCSI optical disk device", 20, 65538, 8, 4, 'b' },
+ { DEVICE_TYPE_DISK, "rod%d", "SCSI optical disk device", 70, 65538, 8, 4, 'c' },
+ { DEVICE_TYPE_DISK, "wfd%d", "ATAPI FLOPPY (LS-120) device", 24, 65538, 8, 4, 'b' },
+ { DEVICE_TYPE_DISK, "rwfd%d", "ATAPI FLOPPY (LS-120) device", 87, 65538, 8, 4, 'c' },
+ { DEVICE_TYPE_FLOPPY, "fd%d", "floppy drive unit A", 2, 0, 64, 4, 'b' },
+ { DEVICE_TYPE_FLOPPY, "worm%d", "SCSI optical disk / CDR", 23, 0, 1, 4, 'b' },
+ { DEVICE_TYPE_NETWORK, "cuaa%d", "%s on device %s (COM%d)", 28, 128, 1, 16, 'c' },
+ { DEVICE_TYPE_NETWORK, "lp", "Parallel Port IP (PLIP) peer connection" },
+ { DEVICE_TYPE_NETWORK, "lo", "Loop-back (local) network interface" },
+ { DEVICE_TYPE_NETWORK, "de", "DEC DE435 PCI NIC or other DC21040-AA based card" },
+ { DEVICE_TYPE_NETWORK, "fxp", "Intel EtherExpress Pro/100B PCI Fast Ethernet card" },
+ { DEVICE_TYPE_NETWORK, "ed", "WD/SMC 80xx; Novell NE1000/2000; 3Com 3C503 card" },
+ { DEVICE_TYPE_NETWORK, "ep", "3Com 3C509 ethernet card" },
+ { DEVICE_TYPE_NETWORK, "el", "3Com 3C501 ethernet card" },
+ { DEVICE_TYPE_NETWORK, "ex", "Intel EtherExpress Pro/10 ethernet card" },
+ { DEVICE_TYPE_NETWORK, "fe", "Fujitsu MB86960A/MB86965A ethernet card" },
+ { DEVICE_TYPE_NETWORK, "ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210" },
+ { DEVICE_TYPE_NETWORK, "ix", "Intel Etherexpress ethernet card" },
+ { DEVICE_TYPE_NETWORK, "le", "DEC EtherWorks 2 or 3 ethernet card" },
+ { DEVICE_TYPE_NETWORK, "lnc", "Lance/PCnet (Isolan/Novell NE2100/NE32-VL) ethernet" },
+ { DEVICE_TYPE_NETWORK, "tx", "SMC 9432TX ethernet card" },
+ { DEVICE_TYPE_NETWORK, "vx", "3COM 3c590 / 3c595 / 3c9xx ethernet card" },
+ { DEVICE_TYPE_NETWORK, "ze", "IBM/National Semiconductor PCMCIA ethernet card" },
+ { DEVICE_TYPE_NETWORK, "zp", "3Com Etherlink III PCMCIA ethernet card" },
+ { 0 },
};
Device *
@@ -130,17 +130,30 @@ dummyShutdown(Device *dev)
}
static int
-deviceTry(char *name, char *try)
+deviceTry(struct _devname dev, char *try, int i)
{
int fd;
-
- snprintf(try, FILENAME_MAX, "/dev/%s", name);
+ char unit[80];
+ mode_t m;
+ dev_t d;
+ int fail;
+
+ snprintf(unit, sizeof unit, dev.name, i);
+ snprintf(try, FILENAME_MAX, "/dev/%s", unit);
+ m = 0666;
+ if (dev.dev_type == 'c')
+ m |= S_IFCHR;
+ else
+ m |= S_IFBLK;
+ d = makedev(dev.major, dev.minor + (i * dev.delta));
+ fail = mknod(try, m, d);
fd = open(try, O_RDONLY);
if (fd > 0)
return fd;
- if (errno == EBUSY)
- return -1;
- snprintf(try, FILENAME_MAX, "/mnt/dev/%s", name);
+ else if (!fail)
+ (void)unlink(try);
+ /* Don't try a "make-under" here since we're using a fixit floppy in this case */
+ snprintf(try, FILENAME_MAX, "/mnt/dev/%s", unit);
fd = open(try, O_RDONLY);
return fd;
}
@@ -175,47 +188,14 @@ deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean e
void
deviceGetAll(void)
{
- int i, fd, s;
+ int i, j, fd, s;
struct ifconf ifc;
struct ifreq *ifptr, *end;
int ifflags;
char buffer[INTERFACE_MAX * sizeof(struct ifreq)];
char **names;
- /* Try and get the disks first */
- if ((names = Disk_Names()) != NULL) {
- int i;
-
- for (i = 0; names[i]; i++) {
- Chunk *c1;
- Disk *d;
-
- d = Open_Disk(names[i]);
- if (!d)
- msgFatal("Unable to open disk %s", names[i]);
-
- (void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE, NULL, NULL, NULL, d);
- msgDebug("Found a disk device named %s\n", names[i]);
-
- /* Look for existing DOS partitions to register */
- for (c1 = d->chunks->part; c1; c1 = c1->next) {
- if (c1->type == fat || c1->type == extended) {
- Device *dev;
- char devname[80];
-
- /* Got one! */
- sprintf(devname, "/dev/%s", c1->name);
- dev = deviceRegister(c1->name, c1->name, strdup(devname), DEVICE_TYPE_DOS, TRUE,
- mediaInitDOS, mediaGetDOS, mediaShutdownDOS, NULL);
- dev->private = c1;
- msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
- }
- }
- }
- free(names);
- }
-
- /* Now go for the network interfaces. Stolen shamelessly from ifconfig! */
+ /* First go for the network interfaces. Stolen shamelessly from ifconfig! */
ifc.ifc_len = sizeof(buffer);
ifc.ifc_buf = buffer;
@@ -238,7 +218,7 @@ deviceGetAll(void)
continue;
/* Eliminate network devices that don't make sense */
- if (!strncmp(ifptr->ifr_name, "lo0", 3))
+ if (!strncmp(ifptr->ifr_name, "lo", 2))
continue;
/* If we have a slip device, don't register it */
@@ -253,7 +233,9 @@ deviceGetAll(void)
for (i = 0, descr = NULL; device_names[i].name; i++) {
int len = strlen(device_names[i].name);
- if (!strncmp(ifptr->ifr_name, device_names[i].name, len)) {
+ if (!ifptr->ifr_name || !ifptr->ifr_name[0])
+ continue;
+ else if (!strncmp(ifptr->ifr_name, device_names[i].name, len)) {
descr = device_names[i].description;
break;
}
@@ -274,71 +256,114 @@ deviceGetAll(void)
}
skipif:
- /* Finally, try to find all the types of devices one might need
+ /* Next, try to find all the types of devices one might need
* during the second stage of the installation.
*/
for (i = 0; device_names[i].name; i++) {
- char try[FILENAME_MAX];
-
- switch(device_names[i].type) {
- case DEVICE_TYPE_CDROM:
- fd = deviceTry(device_names[i].name, try);
- msgDebug("Try for %s returns errno %d\n", device_names[i].name, errno);
- if (fd >= 0 || errno == EBUSY) { /* EBUSY if already mounted */
- if (fd >= 0) close(fd);
- (void)deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
- DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM,
- mediaShutdownCDROM, NULL);
- msgDebug("Found a CDROM device named %s\n", device_names[i].name);
- }
- break;
-
- case DEVICE_TYPE_TAPE:
- fd = deviceTry(device_names[i].name, try);
- if (fd >= 0) {
- close(fd);
- deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
- DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaShutdownTape, NULL);
- msgDebug("Found a TAPE device named %s\n", device_names[i].name);
- }
- break;
-
- case DEVICE_TYPE_FLOPPY:
- fd = deviceTry(device_names[i].name, try);
- if (fd >= 0) {
- close(fd);
- deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
- DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy,
- mediaShutdownFloppy, NULL);
- msgDebug("Found a floppy device named %s\n", device_names[i].name);
- }
- break;
-
- case DEVICE_TYPE_NETWORK:
- fd = deviceTry(device_names[i].name, try);
- /* The only network devices that you can open this way are serial ones */
- if (fd >= 0) {
- char *newdesc, *cp;
-
- close(fd);
- cp = device_names[i].description;
- /* Serial devices get a slip and ppp device each, if supported */
- newdesc = safe_malloc(strlen(cp) + 40);
- sprintf(newdesc, cp, "SLIP interface");
- deviceRegister("sl0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
- NULL, mediaShutdownNetwork, NULL);
- msgDebug("Add mapping for %s on %s to sl0\n", device_names[i].name, try);
- newdesc = safe_malloc(strlen(cp) + 50);
- sprintf(newdesc, cp, "PPP interface");
- deviceRegister("ppp0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
- NULL, mediaShutdownNetwork, NULL);
- msgDebug("Add mapping for %s on %s to ppp0\n", device_names[i].name, try);
+ for (j = 0; j < device_names[i].max; j++) {
+ char try[FILENAME_MAX];
+
+ switch(device_names[i].type) {
+ case DEVICE_TYPE_CDROM:
+ fd = deviceTry(device_names[i], try, j);
+ if (fd >= 0 || errno == EBUSY) { /* EBUSY if already mounted */
+ if (fd >= 0) close(fd);
+ (void)deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
+ DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM,
+ mediaShutdownCDROM, NULL);
+ msgDebug("Found a CDROM device for %s\n", try);
+ }
+ break;
+
+ case DEVICE_TYPE_TAPE:
+ fd = deviceTry(device_names[i], try, j);
+ if (fd >= 0) {
+ close(fd);
+ deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
+ DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaShutdownTape, NULL);
+ msgDebug("Found a TAPE device for %s\n", try);
+ }
+ break;
+
+ case DEVICE_TYPE_DISK:
+ /* We do this just for the side-effect of creating the device entries. The actual registration
+ is done through the libdisk API later. */
+ fd = deviceTry(device_names[i], try, j);
+ if (fd >= 0)
+ close(fd);
+ break;
+
+ case DEVICE_TYPE_FLOPPY:
+ fd = deviceTry(device_names[i], try, j);
+ if (fd >= 0) {
+ close(fd);
+ deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
+ DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy,
+ mediaShutdownFloppy, NULL);
+ msgDebug("Found a floppy device for %s\n", try);
+ }
+ break;
+
+ case DEVICE_TYPE_NETWORK:
+ fd = deviceTry(device_names[i], try, j);
+ /* The only network devices that you can open this way are serial ones */
+ if (fd >= 0) {
+ char *newdesc, *cp;
+
+ close(fd);
+ cp = device_names[i].description;
+ /* Serial devices get a slip and ppp device each, if supported */
+ newdesc = safe_malloc(strlen(cp) + 40);
+ sprintf(newdesc, cp, "SLIP interface", try, j + 1);
+ deviceRegister("sl0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
+ NULL, mediaShutdownNetwork, NULL);
+ msgDebug("Add mapping for %s to sl0\n", try);
+ newdesc = safe_malloc(strlen(cp) + 50);
+ sprintf(newdesc, cp, "PPP interface", try, j + 1);
+ deviceRegister("ppp0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
+ NULL, mediaShutdownNetwork, NULL);
+ msgDebug("Add mapping for %s to ppp0\n", try);
+ }
+ break;
+
+ default:
+ break;
}
- break;
+ }
+ }
+
+ /* Finally, go get the disks and look for DOS partitions to register */
+ if ((names = Disk_Names()) != NULL) {
+ int i;
+
+ for (i = 0; names[i]; i++) {
+ Chunk *c1;
+ Disk *d;
- default:
- break;
+ d = Open_Disk(names[i]);
+ if (!d)
+ msgFatal("Unable to open disk %s", names[i]);
+
+ deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE,
+ dummyInit, dummyGet, dummyShutdown, d);
+ msgDebug("Found a disk device named %s\n", names[i]);
+
+ /* Look for existing DOS partitions to register as "DOS media devices" */
+ for (c1 = d->chunks->part; c1; c1 = c1->next) {
+ if (c1->type == fat || c1->type == extended) {
+ Device *dev;
+ char devname[80];
+
+ /* Got one! */
+ snprintf(devname, sizeof devname, "/dev/%s", c1->name);
+ dev = deviceRegister(c1->name, c1->name, strdup(devname), DEVICE_TYPE_DOS, TRUE,
+ mediaInitDOS, mediaGetDOS, mediaShutdownDOS, NULL);
+ dev->private = c1;
+ msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
+ }
+ }
}
+ free(names);
}
}
diff --git a/usr.sbin/sysinstall/floppy.c b/usr.sbin/sysinstall/floppy.c
index c5bae4a..ec3f70c 100644
--- a/usr.sbin/sysinstall/floppy.c
+++ b/usr.sbin/sysinstall/floppy.c
@@ -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.26 1998/01/16 15:07:54 jkh Exp $
+ * $Id: floppy.c,v 1.27 1998/02/08 20:18:19 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -53,23 +53,10 @@
#undef MSDOSFS
#include <ufs/ufs/ufsmount.h>
-static Device *floppyDev;
static Boolean floppyMounted;
char *distWanted;
-/* For finding floppies */
-static int
-floppyChoiceHook(dialogMenuItem *self)
-{
- Device **devs;
-
- devs = deviceFind(self->prompt, DEVICE_TYPE_FLOPPY);
- if (devs)
- floppyDev = devs[0];
- return devs ? DITEM_LEAVE_MENU : DITEM_FAILURE;
-}
-
Boolean
mediaInitFloppy(Device *dev)
{
diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c
index 2a7d183..6c989f9 100644
--- a/usr.sbin/sysinstall/install.c
+++ b/usr.sbin/sysinstall/install.c
@@ -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.203 1997/12/29 20:07:17 jkh Exp $
+ * $Id: install.c,v 1.204 1998/01/16 15:07:55 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -874,7 +874,7 @@ installFilesystems(dialogMenuItem *self)
if (rootdev && RunningAsInit) {
/* Next, create and/or mount the root device */
- sprintf(dname, "/dev/r%sa", rootdev->disk->name);
+ sprintf(dname, "/dev/r%s", rootdev->name);
if (!Fake && (!MakeDevChunk(rootdev, "/dev") || !file_readable(dname))) {
msgConfirm("Unable to make device node for %s in /dev!\n"
"The creation of filesystems will be aborted.", dname);
@@ -907,7 +907,7 @@ installFilesystems(dialogMenuItem *self)
}
/* Switch to block device */
- sprintf(dname, "/dev/%sa", rootdev->disk->name);
+ sprintf(dname, "/dev/%s", rootdev->name);
if (Mount("/mnt", dname)) {
msgConfirm("Unable to mount the root file system on %s! Giving up.", dname);
return DITEM_FAILURE;
diff --git a/usr.sbin/sysinstall/menus.c b/usr.sbin/sysinstall/menus.c
index 323947e..87959a7 100644
--- a/usr.sbin/sysinstall/menus.c
+++ b/usr.sbin/sysinstall/menus.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: menus.c,v 1.151 1997/11/26 22:48:24 joerg Exp $
+ * $Id: menus.c,v 1.152 1998/01/27 14:01:19 yokota Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -632,8 +632,8 @@ DMenu MenuNetworkDevice = {
"If you're using SLIP over a serial device then the expectation is\n"
"that you have a HARDWIRED connection.\n\n"
"You can also install over a parallel port using a special \"laplink\"\n"
- "cable to another machine running a fairly recent (2.0R or later) version\n"
- "of FreeBSD.",
+ "cable to another machine running a fairly recent (2.0R or later)\n"
+ "version of FreeBSD.",
"Press F1 to read network configuration manual",
"network_device",
{ { NULL } },
OpenPOWER on IntegriCloud