summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sade
diff options
context:
space:
mode:
authorfjoe <fjoe@FreeBSD.org>2011-11-24 15:47:01 +0000
committerfjoe <fjoe@FreeBSD.org>2011-11-24 15:47:01 +0000
commit785264a30f01132975737fa8e81af24c6eb6bc33 (patch)
treef1f897508e11ba08deb50d9b7260a3ed443ed257 /usr.sbin/sade
parent72a7edb085ebac224c61145a65bfe1a7a1de8ceb (diff)
downloadFreeBSD-src-785264a30f01132975737fa8e81af24c6eb6bc33.zip
FreeBSD-src-785264a30f01132975737fa8e81af24c6eb6bc33.tar.gz
Disk selection dialog is now a normal menu, not a checkboxed menu:
checkboxed menu is confusing and also can not be implemented in new libdialog.
Diffstat (limited to 'usr.sbin/sade')
-rw-r--r--usr.sbin/sade/devices.c10
-rw-r--r--usr.sbin/sade/disks.c124
-rw-r--r--usr.sbin/sade/install.c139
-rw-r--r--usr.sbin/sade/label.c271
-rw-r--r--usr.sbin/sade/menus.c8
-rw-r--r--usr.sbin/sade/sade.h13
6 files changed, 215 insertions, 350 deletions
diff --git a/usr.sbin/sade/devices.c b/usr.sbin/sade/devices.c
index fec9bba..12581e4 100644
--- a/usr.sbin/sade/devices.c
+++ b/usr.sbin/sade/devices.c
@@ -122,7 +122,7 @@ deviceTry(struct _devname dev, char *try, int i)
/* Register a new device in the devices array */
Device *
-deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
+deviceRegister(char *name, char *desc, char *devname, DeviceType type,
Boolean (*init)(Device *), FILE * (*get)(Device *, char *, Boolean),
void (*shutdown)(Device *), void *private)
{
@@ -135,7 +135,6 @@ deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean e
newdev->description = desc;
newdev->devname = devname;
newdev->type = type;
- newdev->enabled = enabled;
newdev->init = init ? init : dummyInit;
newdev->get = get ? get : dummyGet;
newdev->shutdown = shutdown ? shutdown : dummyShutdown;
@@ -223,7 +222,7 @@ deviceGetAll(void)
continue;
}
- deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE,
+ deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK,
dummyInit, dummyGet, dummyShutdown, d);
if (isDebug())
msgDebug("Found a disk device named %s\n", names[i]);
@@ -237,7 +236,7 @@ deviceGetAll(void)
/* Got one! */
snprintf(devname, sizeof devname, "/dev/%s", c1->name);
- dev = deviceRegister(c1->name, c1->name, strdup(devname), DEVICE_TYPE_DOS, TRUE,
+ dev = deviceRegister(c1->name, c1->name, strdup(devname), DEVICE_TYPE_DOS,
mediaInitDOS, mediaGetDOS, mediaShutdownDOS, NULL);
dev->private = c1;
if (isDebug())
@@ -314,7 +313,7 @@ deviceCount(Device **devs)
* menu is cloned.
*/
DMenu *
-deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d), int (*check)(dialogMenuItem *d))
+deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d))
{
Device **devs;
int numdevs;
@@ -338,7 +337,6 @@ deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d), i
if (j == numDevs)
tmp->items[i].title = "<unknown device type>";
tmp->items[i].fire = hook;
- tmp->items[i].checked = check;
}
tmp->items[i].title = NULL;
return tmp;
diff --git a/usr.sbin/sade/disks.c b/usr.sbin/sade/disks.c
index 3158ff3..bf091d4 100644
--- a/usr.sbin/sade/disks.c
+++ b/usr.sbin/sade/disks.c
@@ -305,25 +305,6 @@ getBootMgr(char *dname, u_char **bootCode, size_t *bootCodeSize)
#endif
#endif /* WITH_SLICES */
-int
-diskGetSelectCount(Device ***devs)
-{
- int i, cnt, enabled;
- char *cp;
- Device **dp;
-
- cp = variable_get(VAR_DISK);
- dp = *devs = deviceFind(cp, DEVICE_TYPE_DISK);
- cnt = deviceCount(dp);
- if (!cnt)
- return -1;
- for (i = 0, enabled = 0; i < cnt; i++) {
- if (dp[i]->enabled)
- ++enabled;
- }
- return enabled;
-}
-
#ifdef WITH_SLICES
void
diskPartition(Device *dev)
@@ -641,7 +622,7 @@ diskPartition(Device *dev)
Set_Boot_Mgr(d, mbrContents, mbrSize);
#endif
- if (DITEM_STATUS(diskPartitionWrite(NULL)) != DITEM_SUCCESS)
+ if (DITEM_STATUS(diskPartitionWrite(dev)) != DITEM_SUCCESS)
msgConfirm("Disk partition write returned an error status!");
else
msgConfirm("Wrote FDISK partition information out successfully.");
@@ -770,7 +751,7 @@ bootalloc(char *name, size_t *size)
}
#endif /* !__ia64__ */
-#ifdef WITH_SLICES
+#ifdef WITH_SLICES
static int
partitionHook(dialogMenuItem *selected)
{
@@ -781,58 +762,28 @@ partitionHook(dialogMenuItem *selected)
msgConfirm("Unable to find disk %s!", selected->prompt);
return DITEM_FAILURE;
}
- /* Toggle enabled status? */
- if (!devs[0]->enabled) {
- devs[0]->enabled = TRUE;
- diskPartition(devs[0]);
- }
- else
- devs[0]->enabled = FALSE;
+ diskPartition(devs[0]);
return DITEM_SUCCESS;
}
-static int
-partitionCheck(dialogMenuItem *selected)
-{
- Device **devs = NULL;
-
- devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK);
- if (!devs || devs[0]->enabled == FALSE)
- return FALSE;
- return TRUE;
-}
-
int
diskPartitionEditor(dialogMenuItem *self)
{
DMenu *menu;
Device **devs;
- int i, cnt, devcnt;
- cnt = diskGetSelectCount(&devs);
- devcnt = deviceCount(devs);
- if (cnt == -1) {
+ devs = deviceFind(variable_get(VAR_DISK), DEVICE_TYPE_DISK);
+ if (devs == NULL) {
msgConfirm("No disks found! Please verify that your disk controller is being\n"
"properly probed at boot time. See the Hardware Guide on the\n"
"Documentation menu for clues on diagnosing this type of problem.");
return DITEM_FAILURE;
}
- else if (cnt) {
- /* Some are already selected */
- for (i = 0; i < devcnt; i++) {
- if (devs[i]->enabled) {
- if (variable_get(VAR_NONINTERACTIVE) &&
- !variable_get(VAR_DISKINTERACTIVE))
- diskPartitionNonInteractive(devs[i]);
- else
- diskPartition(devs[i]);
- }
- }
- }
else {
/* No disks are selected, fall-back case now */
- if (devcnt == 1) {
- devs[0]->enabled = TRUE;
+ int cnt = deviceCount(devs);
+
+ if (cnt == 1) {
if (variable_get(VAR_NONINTERACTIVE) &&
!variable_get(VAR_DISKINTERACTIVE))
diskPartitionNonInteractive(devs[0]);
@@ -841,7 +792,9 @@ diskPartitionEditor(dialogMenuItem *self)
return DITEM_SUCCESS;
}
else {
- menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, partitionHook, partitionCheck);
+ int result;
+
+ menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, partitionHook);
if (!menu) {
msgConfirm("No devices suitable for installation found!\n\n"
"Please verify that your disk controller (and attached drives)\n"
@@ -850,11 +803,10 @@ diskPartitionEditor(dialogMenuItem *self)
"the boot messages. Press [Scroll Lock] again to return.");
return DITEM_FAILURE;
}
- else {
- i = dmenuOpenSimple(menu, FALSE) ? DITEM_SUCCESS : DITEM_FAILURE;
- free(menu);
- }
- return i;
+
+ result = dmenuOpenSimple(menu, FALSE) ? DITEM_SUCCESS : DITEM_FAILURE;
+ free(menu);
+ return result;
}
}
return DITEM_SUCCESS;
@@ -862,48 +814,34 @@ diskPartitionEditor(dialogMenuItem *self)
#endif /* WITH_SLICES */
int
-diskPartitionWrite(dialogMenuItem *self)
+diskPartitionWrite(Device *dev)
{
- Device **devs;
- int i;
-
- if (!variable_cmp(DISK_PARTITIONED, "written"))
- return DITEM_SUCCESS;
-
- devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("Unable to find any disks to write to??");
- return DITEM_FAILURE;
- }
- if (isDebug())
- msgDebug("diskPartitionWrite: Examining %d devices\n", deviceCount(devs));
- for (i = 0; devs[i]; i++) {
- Disk *d = (Disk *)devs[i]->private;
+ Disk *d = (Disk *)dev->private;
#if !defined(__ia64__)
- static u_char *boot1;
+ static u_char *boot1;
#endif
#if defined(__i386__) || defined(__amd64__)
- static u_char *boot2;
+ static u_char *boot2;
#endif
- if (!devs[i]->enabled)
- continue;
+ if (!variable_cmp(DISK_PARTITIONED, "written"))
+ return DITEM_SUCCESS;
#if defined(__i386__) || defined(__amd64__)
- if (!boot1) boot1 = bootalloc("boot1", NULL);
- if (!boot2) boot2 = bootalloc("boot2", NULL);
- Set_Boot_Blocks(d, boot1, boot2);
+ if (!boot1) boot1 = bootalloc("boot1", NULL);
+ if (!boot2) boot2 = bootalloc("boot2", NULL);
+ Set_Boot_Blocks(d, boot1, boot2);
#elif !defined(__ia64__)
- if (!boot1) boot1 = bootalloc("boot1", NULL);
- Set_Boot_Blocks(d, boot1, NULL);
+ if (!boot1) boot1 = bootalloc("boot1", NULL);
+ Set_Boot_Blocks(d, boot1, NULL);
#endif
- msgNotify("Writing partition information to drive %s", d->name);
- if (!Fake && Write_Disk(d)) {
- msgConfirm("ERROR: Unable to write data to disk %s!", d->name);
- return DITEM_FAILURE;
- }
+ msgNotify("Writing partition information to drive %s", d->name);
+ if (!Fake && Write_Disk(d)) {
+ msgConfirm("ERROR: Unable to write data to disk %s!", d->name);
+ return DITEM_FAILURE;
}
+
/* Now it's not "yes", but "written" */
variable_set2(DISK_PARTITIONED, "written", 0);
return DITEM_SUCCESS | DITEM_RESTORE;
diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c
index 952ae93..fb95998 100644
--- a/usr.sbin/sade/install.c
+++ b/usr.sbin/sade/install.c
@@ -113,12 +113,10 @@ performNewfs(PartInfo *pi, char *dname, int queue)
/* Go newfs and/or mount all the filesystems we've been asked to */
int
-installFilesystems(dialogMenuItem *self)
+installFilesystems(Device *dev)
{
- int i;
- Disk *disk;
+ Disk *disk = (Disk *)dev->private;
Chunk *c1, *c2;
- Device **devs;
PartInfo *root;
char dname[80];
Boolean upgrade = FALSE;
@@ -136,84 +134,77 @@ installFilesystems(dialogMenuItem *self)
command_clear();
/* Now buzz through the rest of the partitions and mount them too */
- devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- for (i = 0; devs[i]; i++) {
- if (!devs[i]->enabled)
- continue;
-
- disk = (Disk *)devs[i]->private;
- if (!disk->chunks) {
- msgConfirm("No chunk list found for %s!", disk->name);
- return DITEM_FAILURE | DITEM_RESTORE;
- }
- for (c1 = disk->chunks->part; c1; c1 = c1->next) {
+ if (!disk->chunks) {
+ msgConfirm("No chunk list found for %s!", disk->name);
+ return DITEM_FAILURE | DITEM_RESTORE;
+ }
+ for (c1 = disk->chunks->part; c1; c1 = c1->next) {
#ifdef __ia64__
- if (c1->type == part) {
- c2 = c1;
- {
+ if (c1->type == part) {
+ c2 = c1;
+ {
#elif defined(__powerpc__)
- if (c1->type == apple) {
- for (c2 = c1->part; c2; c2 = c2->next) {
+ if (c1->type == apple) {
+ for (c2 = c1->part; c2; c2 = c2->next) {
#else
- if (c1->type == freebsd) {
- for (c2 = c1->part; c2; c2 = c2->next) {
+ if (c1->type == freebsd) {
+ for (c2 = c1->part; c2; c2 = c2->next) {
#endif
- if (c2->type == part && c2->subtype != FS_SWAP && c2->private_data) {
- PartInfo *tmp = (PartInfo *)c2->private_data;
-
- /* Already did root */
- if (c2 == RootChunk)
- continue;
-
- sprintf(dname, "/dev/%s", c2->name);
-
- if (tmp->do_newfs && (!upgrade ||
- !msgNoYes("You are upgrading - are you SURE you"
- " want to newfs /dev/%s?", c2->name)))
- performNewfs(tmp, dname, QUEUE_YES);
- else
- command_shell_add(tmp->mountpoint,
- "fsck_ffs -y /dev/%s", c2->name);
- command_func_add(tmp->mountpoint, Mount, c2->name);
- }
- else if (c2->type == part && c2->subtype == FS_SWAP) {
- char fname[80];
- int i;
-
- if (c2 == SwapChunk)
- continue;
- sprintf(fname, "/dev/%s", c2->name);
- i = (Fake || swapon(fname));
- if (!i) {
- dialog_clear_norefresh();
- msgNotify("Added %s as an additional swap device", fname);
- }
- else {
- msgConfirm("Unable to add %s as a swap device: %s", fname, strerror(errno));
- }
- }
- }
- }
- else if (c1->type == fat && c1->private_data &&
- (root->do_newfs || upgrade)) {
- char name[FILENAME_MAX];
-
- sprintf(name, "/%s", ((PartInfo *)c1->private_data)->mountpoint);
- Mkdir(name);
- }
+ if (c2->type == part && c2->subtype != FS_SWAP && c2->private_data) {
+ PartInfo *tmp = (PartInfo *)c2->private_data;
+
+ /* Already did root */
+ if (c2 == RootChunk)
+ continue;
+
+ sprintf(dname, "/dev/%s", c2->name);
+
+ if (tmp->do_newfs && (!upgrade ||
+ !msgNoYes("You are upgrading - are you SURE you"
+ " want to newfs /dev/%s?", c2->name)))
+ performNewfs(tmp, dname, QUEUE_YES);
+ else
+ command_shell_add(tmp->mountpoint,
+ "fsck_ffs -y /dev/%s", c2->name);
+ command_func_add(tmp->mountpoint, Mount, c2->name);
+ }
+ else if (c2->type == part && c2->subtype == FS_SWAP) {
+ char fname[80];
+ int i;
+
+ if (c2 == SwapChunk)
+ continue;
+ sprintf(fname, "/dev/%s", c2->name);
+ i = (Fake || swapon(fname));
+ if (!i) {
+ dialog_clear_norefresh();
+ msgNotify("Added %s as an additional swap device", fname);
+ }
+ else {
+ msgConfirm("Unable to add %s as a swap device: %s", fname, strerror(errno));
+ }
+ }
+ }
+ }
+ else if (c1->type == fat && c1->private_data &&
+ (root->do_newfs || upgrade)) {
+ char name[FILENAME_MAX];
+
+ sprintf(name, "/%s", ((PartInfo *)c1->private_data)->mountpoint);
+ Mkdir(name);
+ }
#if defined(__ia64__)
- else if (c1->type == efi && c1->private_data) {
- PartInfo *pi = (PartInfo *)c1->private_data;
+ else if (c1->type == efi && c1->private_data) {
+ PartInfo *pi = (PartInfo *)c1->private_data;
- sprintf(dname, "/dev/%s", c1->name);
+ sprintf(dname, "/dev/%s", c1->name);
- if (pi->do_newfs && (!upgrade ||
- !msgNoYes("You are upgrading - are you SURE you want to "
- "newfs /dev/%s?", c1->name)))
- performNewfs(pi, dname, QUEUE_YES);
- }
+ if (pi->do_newfs && (!upgrade ||
+ !msgNoYes("You are upgrading - are you SURE you want to "
+ "newfs /dev/%s?", c1->name)))
+ performNewfs(pi, dname, QUEUE_YES);
+ }
#endif
- }
}
command_sort();
diff --git a/usr.sbin/sade/label.c b/usr.sbin/sade/label.c
index 3f20450..ad62164 100644
--- a/usr.sbin/sade/label.c
+++ b/usr.sbin/sade/label.c
@@ -110,7 +110,7 @@ static int label_focus = 0, pslice_focus = 0;
static int diskLabel(Device *dev);
static int diskLabelNonInteractive(Device *dev);
-static char *try_auto_label(Device **devs, Device *dev, int perc, int *req);
+static char *try_auto_label(Device *dev, int perc, int *req);
static int
labelHook(dialogMenuItem *selected)
@@ -122,86 +122,59 @@ labelHook(dialogMenuItem *selected)
msgConfirm("Unable to find disk %s!", selected->prompt);
return DITEM_FAILURE;
}
- /* Toggle enabled status? */
- if (!devs[0]->enabled) {
- devs[0]->enabled = TRUE;
- diskLabel(devs[0]);
- }
- else
- devs[0]->enabled = FALSE;
+ diskLabel(devs[0]);
return DITEM_SUCCESS;
}
-static int
-labelCheck(dialogMenuItem *selected)
-{
- Device **devs = NULL;
-
- devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK);
- if (!devs || devs[0]->enabled == FALSE)
- return FALSE;
- return TRUE;
-}
-
int
diskLabelEditor(dialogMenuItem *self)
{
DMenu *menu;
Device **devs;
- int i, cnt;
+ int result;
- i = 0;
- cnt = diskGetSelectCount(&devs);
- if (cnt == -1) {
+ devs = deviceFind(variable_get(VAR_DISK), DEVICE_TYPE_DISK);
+ if (devs == NULL) {
msgConfirm("No disks found! Please verify that your disk controller is being\n"
"properly probed at boot time. See the Hardware Guide on the\n"
"Documentation menu for clues on diagnosing this type of problem.");
return DITEM_FAILURE;
}
- else if (cnt) {
- /* Some are already selected */
- if (variable_get(VAR_NONINTERACTIVE) &&
- !variable_get(VAR_DISKINTERACTIVE))
- i = diskLabelNonInteractive(NULL);
- else
- i = diskLabel(NULL);
- }
else {
/* No disks are selected, fall-back case now */
- cnt = deviceCount(devs);
+ int cnt = deviceCount(devs);
if (cnt == 1) {
- devs[0]->enabled = TRUE;
if (variable_get(VAR_NONINTERACTIVE) &&
!variable_get(VAR_DISKINTERACTIVE))
- i = diskLabelNonInteractive(devs[0]);
+ result = diskLabelNonInteractive(devs[0]);
else
- i = diskLabel(devs[0]);
+ result = diskLabel(devs[0]);
}
else {
- menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, labelHook, labelCheck);
+ menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, labelHook);
if (!menu) {
msgConfirm("No devices suitable for installation found!\n\n"
"Please verify that your disk controller (and attached drives)\n"
"were detected properly. This can be done by pressing the\n"
"[Scroll Lock] key and using the Arrow keys to move back to\n"
"the boot messages. Press [Scroll Lock] again to return.");
- i = DITEM_FAILURE;
+ result = DITEM_FAILURE;
}
else {
- i = dmenuOpenSimple(menu, FALSE) ? DITEM_SUCCESS : DITEM_FAILURE;
+ result = dmenuOpenSimple(menu, FALSE) ? DITEM_SUCCESS : DITEM_FAILURE;
free(menu);
}
}
}
- if (DITEM_STATUS(i) != DITEM_FAILURE) {
+ if (DITEM_STATUS(result) != DITEM_FAILURE) {
if (variable_cmp(DISK_LABELLED, "written"))
variable_set2(DISK_LABELLED, "yes", 0);
}
- return i;
+ return result;
}
int
-diskLabelCommit(dialogMenuItem *self)
+diskLabelCommit(Device *dev)
{
char *cp;
int i;
@@ -214,9 +187,9 @@ diskLabelCommit(dialogMenuItem *self)
i = DITEM_FAILURE;
}
/* The routine will guard against redundant writes, just as this one does */
- else if (DITEM_STATUS(diskPartitionWrite(self)) != DITEM_SUCCESS)
+ else if (DITEM_STATUS(diskPartitionWrite(dev)) != DITEM_SUCCESS)
i = DITEM_FAILURE;
- else if (DITEM_STATUS(installFilesystems(self)) != DITEM_SUCCESS)
+ else if (DITEM_STATUS(installFilesystems(dev)) != DITEM_SUCCESS)
i = DITEM_FAILURE;
else {
msgInfo("All filesystem information written successfully.");
@@ -258,98 +231,87 @@ space_free(struct chunk *c)
/* Snapshot the current situation into the displayed chunks structure */
static void
-record_label_chunks(Device **devs, Device *dev)
+record_label_chunks(Device *dev)
{
- int i, j, p;
+ int j, p;
struct chunk *c1, *c2;
- Disk *d;
+ Disk *d = (Disk *)dev->private;
j = p = 0;
/* First buzz through and pick up the FreeBSD slices */
- for (i = 0; devs[i]; i++) {
- if ((dev && devs[i] != dev) || !devs[i]->enabled)
- continue;
- d = (Disk *)devs[i]->private;
- if (!d->chunks)
- msgFatal("No chunk list found for %s!", d->name);
+ if (!d->chunks)
+ msgFatal("No chunk list found for %s!", d->name);
#ifdef __ia64__
- label_chunk_info[j].type = PART_SLICE;
- label_chunk_info[j].c = d->chunks;
- j++;
+ label_chunk_info[j].type = PART_SLICE;
+ label_chunk_info[j].c = d->chunks;
+ j++;
#endif
- /* Put the slice entries first */
- for (c1 = d->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- label_chunk_info[j].type = PART_SLICE;
- label_chunk_info[j].c = c1;
- ++j;
- }
+ /* Put the slice entries first */
+ for (c1 = d->chunks->part; c1; c1 = c1->next) {
+ if (c1->type == freebsd) {
+ label_chunk_info[j].type = PART_SLICE;
+ label_chunk_info[j].c = c1;
+ ++j;
+ }
#ifdef __powerpc__
- if (c1->type == apple) {
- label_chunk_info[j].type = PART_SLICE;
- label_chunk_info[j].c = c1;
- ++j;
- }
+ if (c1->type == apple) {
+ label_chunk_info[j].type = PART_SLICE;
+ label_chunk_info[j].c = c1;
+ ++j;
+ }
#endif
- }
}
- /* Now run through again and get the FreeBSD partition entries */
- for (i = 0; devs[i]; i++) {
- if (!devs[i]->enabled)
- continue;
- d = (Disk *)devs[i]->private;
- /* Then buzz through and pick up the partitions */
- for (c1 = d->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- for (c2 = c1->part; c2; c2 = c2->next) {
- if (c2->type == part) {
- if (c2->subtype == FS_SWAP)
- label_chunk_info[j].type = PART_SWAP;
- else
- label_chunk_info[j].type = PART_FILESYSTEM;
- label_chunk_info[j].c = c2;
- ++j;
- }
- }
- }
- else if (c1->type == fat) {
- label_chunk_info[j].type = PART_FAT;
- label_chunk_info[j].c = c1;
- ++j;
- }
+ /* Then buzz through and pick up the partitions */
+ for (c1 = d->chunks->part; c1; c1 = c1->next) {
+ if (c1->type == freebsd) {
+ for (c2 = c1->part; c2; c2 = c2->next) {
+ if (c2->type == part) {
+ if (c2->subtype == FS_SWAP)
+ label_chunk_info[j].type = PART_SWAP;
+ else
+ label_chunk_info[j].type = PART_FILESYSTEM;
+ label_chunk_info[j].c = c2;
+ ++j;
+ }
+ }
+ }
+ else if (c1->type == fat) {
+ label_chunk_info[j].type = PART_FAT;
+ label_chunk_info[j].c = c1;
+ ++j;
+ }
#ifdef __ia64__
- else if (c1->type == efi) {
- label_chunk_info[j].type = PART_EFI;
- label_chunk_info[j].c = c1;
- ++j;
- }
- else if (c1->type == part) {
- if (c1->subtype == FS_SWAP)
- label_chunk_info[j].type = PART_SWAP;
- else
- label_chunk_info[j].type = PART_FILESYSTEM;
- label_chunk_info[j].c = c1;
- ++j;
- }
+ else if (c1->type == efi) {
+ label_chunk_info[j].type = PART_EFI;
+ label_chunk_info[j].c = c1;
+ ++j;
+ }
+ else if (c1->type == part) {
+ if (c1->subtype == FS_SWAP)
+ label_chunk_info[j].type = PART_SWAP;
+ else
+ label_chunk_info[j].type = PART_FILESYSTEM;
+ label_chunk_info[j].c = c1;
+ ++j;
+ }
#endif
#ifdef __powerpc__
- else if (c1->type == apple) {
- for (c2 = c1->part; c2; c2 = c2->next) {
- if (c2->type == part) {
- if (c2->subtype == FS_SWAP)
- label_chunk_info[j].type = PART_SWAP;
- else
- label_chunk_info[j].type = PART_FILESYSTEM;
- label_chunk_info[j].c = c2;
- ++j;
- }
- }
- }
+ else if (c1->type == apple) {
+ for (c2 = c1->part; c2; c2 = c2->next) {
+ if (c2->type == part) {
+ if (c2->subtype == FS_SWAP)
+ label_chunk_info[j].type = PART_SWAP;
+ else
+ label_chunk_info[j].type = PART_FILESYSTEM;
+ label_chunk_info[j].c = c2;
+ ++j;
+ }
+ }
+ }
#endif
- }
}
label_chunk_info[j].c = NULL;
if (here >= j) {
@@ -845,22 +807,15 @@ diskLabel(Device *dev)
char *msg = NULL;
PartInfo *p, *oldp;
PartType type;
- Device **devs;
WINDOW *w = savescr();
label_focus = 0;
pslice_focus = 0;
here = 0;
- devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("No disks found!");
- restorescr(w);
- return DITEM_FAILURE;
- }
labeling = TRUE;
keypad(stdscr, TRUE);
- record_label_chunks(devs, dev);
+ record_label_chunks(dev);
clear();
while (labeling) {
@@ -883,7 +838,6 @@ diskLabel(Device *dev)
refresh();
key = getch();
switch (toupper(key)) {
- int i;
static char _msg[40];
case '\014': /* ^L */
@@ -972,7 +926,7 @@ diskLabel(Device *dev)
for (perc = 100; perc > 0; perc -= 5) {
req = 0; /* reset for each loop */
- if ((msg = try_auto_label(devs, dev, perc, &req)) == NULL)
+ if ((msg = try_auto_label(dev, perc, &req)) == NULL)
break;
}
if (msg) {
@@ -1114,7 +1068,7 @@ diskLabel(Device *dev)
tmp->private_free = safe_free;
if (variable_cmp(DISK_LABELLED, "written"))
variable_set2(DISK_LABELLED, "yes", 0);
- record_label_chunks(devs, dev);
+ record_label_chunks(dev);
clear_wins();
/* This is where we assign focus to new label so it shows. */
{
@@ -1151,7 +1105,7 @@ diskLabel(Device *dev)
Delete_Chunk2(label_chunk_info[here].c->disk, label_chunk_info[here].c, rflags);
if (variable_cmp(DISK_LABELLED, "written"))
variable_set2(DISK_LABELLED, "yes", 0);
- record_label_chunks(devs, dev);
+ record_label_chunks(dev);
break;
case 'M': /* mount */
@@ -1183,7 +1137,7 @@ diskLabel(Device *dev)
}
if (variable_cmp(DISK_LABELLED, "written"))
variable_set2(DISK_LABELLED, "yes", 0);
- record_label_chunks(devs, dev);
+ record_label_chunks(dev);
clear_wins();
break;
@@ -1252,22 +1206,18 @@ diskLabel(Device *dev)
"it's too late to undo!");
}
else if (!msgNoYes("Are you SURE you want to Undo everything?")) {
+ Disk *d;
+
variable_unset(DISK_PARTITIONED);
variable_unset(DISK_LABELLED);
- for (i = 0; devs[i]; i++) {
- Disk *d;
-
- if (!devs[i]->enabled)
- continue;
- else if ((d = Open_Disk(devs[i]->name)) != NULL) {
- Free_Disk(devs[i]->private);
- devs[i]->private = d;
+ if ((d = Open_Disk(dev->name)) != NULL) {
+ Free_Disk(dev->private);
+ dev->private = d;
#ifdef WITH_SLICES
- diskPartition(devs[i]);
+ diskPartition(dev);
#endif
- }
}
- record_label_chunks(devs, dev);
+ record_label_chunks(dev);
}
clear_wins();
break;
@@ -1282,7 +1232,7 @@ diskLabel(Device *dev)
"installation.\n\n"
"Are you absolutely sure you want to continue?")) {
variable_set2(DISK_LABELLED, "yes", 0);
- diskLabelCommit(NULL);
+ diskLabelCommit(dev);
}
clear_wins();
break;
@@ -1301,25 +1251,16 @@ diskLabel(Device *dev)
if (!msgNoYes("Are you sure you want to go into Wizard mode?\n\n"
"This is an entirely undocumented feature which you are not\n"
"expected to understand!")) {
- int i;
- Device **devs;
-
dialog_clear();
end_dialog();
DialogActive = FALSE;
- devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("Can't find any disk devices!");
- break;
- }
- for (i = 0; devs[i] && ((Disk *)devs[i]->private); i++) {
- if (devs[i]->enabled)
- slice_wizard(((Disk *)devs[i]->private));
+ if (dev->private) {
+ slice_wizard(((Disk *)dev->private));
}
if (variable_cmp(DISK_LABELLED, "written"))
variable_set2(DISK_LABELLED, "yes", 0);
DialogActive = TRUE;
- record_label_chunks(devs, dev);
+ record_label_chunks(dev);
clear_wins();
}
else
@@ -1378,7 +1319,7 @@ requested_part_size(char *varName, daddr_t nom, int def, int perc)
* and /home. /home receives any extra left over disk space.
*/
static char *
-try_auto_label(Device **devs, Device *dev, int perc, int *req)
+try_auto_label(Device *dev, int perc, int *req)
{
daddr_t sz;
Chunk *AutoHome, *AutoRoot, *AutoSwap;
@@ -1413,7 +1354,7 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req)
AutoEfi->private_data = new_part(PART_EFI, "/efi", TRUE);
AutoEfi->private_free = safe_free;
AutoEfi->flags |= CHUNK_NEWFS;
- record_label_chunks(devs, dev);
+ record_label_chunks(dev);
}
#endif
@@ -1431,7 +1372,7 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req)
AutoRoot->private_data = new_part(PART_FILESYSTEM, "/", TRUE);
AutoRoot->private_free = safe_free;
AutoRoot->flags |= CHUNK_NEWFS;
- record_label_chunks(devs, dev);
+ record_label_chunks(dev);
}
if (SwapChunk == NULL) {
sz = requested_part_size(VAR_SWAP_SIZE, 0, 0, perc);
@@ -1461,7 +1402,7 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req)
}
AutoSwap->private_data = 0;
AutoSwap->private_free = safe_free;
- record_label_chunks(devs, dev);
+ record_label_chunks(dev);
}
if (VarChunk == NULL) {
/* Work out how much extra space we want for a crash dump */
@@ -1492,7 +1433,7 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req)
AutoVar->private_data = new_part(PART_FILESYSTEM, "/var", TRUE);
AutoVar->private_free = safe_free;
AutoVar->flags |= CHUNK_NEWFS;
- record_label_chunks(devs, dev);
+ record_label_chunks(dev);
}
if (TmpChunk == NULL && !variable_get(VAR_NO_TMP)) {
sz = requested_part_size(VAR_TMP_SIZE, TMP_NOMINAL_SIZE, TMP_DEFAULT_SIZE, perc);
@@ -1509,7 +1450,7 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req)
AutoTmp->private_data = new_part(PART_FILESYSTEM, "/tmp", TRUE);
AutoTmp->private_free = safe_free;
AutoTmp->flags |= CHUNK_NEWFS;
- record_label_chunks(devs, dev);
+ record_label_chunks(dev);
}
if (UsrChunk == NULL && !variable_get(VAR_NO_USR)) {
sz = requested_part_size(VAR_USR_SIZE, USR_NOMINAL_SIZE, USR_DEFAULT_SIZE, perc);
@@ -1535,7 +1476,7 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req)
AutoUsr->private_data = new_part(PART_FILESYSTEM, "/usr", TRUE);
AutoUsr->private_free = safe_free;
AutoUsr->flags |= CHUNK_NEWFS;
- record_label_chunks(devs, dev);
+ record_label_chunks(dev);
}
}
#if AUTO_HOME == 1
@@ -1562,7 +1503,7 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req)
AutoHome->private_data = new_part(PART_FILESYSTEM, "/home", TRUE);
AutoHome->private_free = safe_free;
AutoHome->flags |= CHUNK_NEWFS;
- record_label_chunks(devs, dev);
+ record_label_chunks(dev);
}
}
#endif
@@ -1585,7 +1526,7 @@ done:
Delete_Chunk(AutoUsr->disk, AutoUsr);
if (AutoHome != NULL)
Delete_Chunk(AutoHome->disk, AutoHome);
- record_label_chunks(devs, dev);
+ record_label_chunks(dev);
}
return(msg);
}
@@ -1616,7 +1557,7 @@ diskLabelNonInteractive(Device *dev)
d = dev->private;
else
d = devs[0]->private;
- record_label_chunks(devs, dev);
+ record_label_chunks(dev);
for (i = 0; label_chunk_info[i].c; i++) {
Chunk *c1 = label_chunk_info[i].c;
diff --git a/usr.sbin/sade/menus.c b/usr.sbin/sade/menus.c
index df51804..b25796b 100644
--- a/usr.sbin/sade/menus.c
+++ b/usr.sbin/sade/menus.c
@@ -42,14 +42,14 @@ static const char rcsid[] =
*/
DMenu MenuDiskDevices = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
+ DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
"Select Drive(s)",
- "Please select the drive, or drives, on which you wish to perform\n"
- "this operation. If you are attempting to install a boot partition\n"
+ "Please select the drive on which you wish to perform this\n"
+ "operation. If you are attempting to install a boot partition\n"
"on a drive other than the first one or have multiple operating\n"
"systems on your machine, you will have the option to install a boot\n"
"manager later. To select a drive, use the arrow keys to move to it\n"
- "and press [SPACE] or [ENTER]. To de-select it, press it again.\n\n"
+ "and press [SPACE] or [ENTER].\n\n"
"Use [TAB] to get to the buttons and leave this menu.",
"Press F1 for important information regarding disk geometry!",
"drives",
diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h
index fbd6cd3..3c58790 100644
--- a/usr.sbin/sade/sade.h
+++ b/usr.sbin/sade/sade.h
@@ -184,7 +184,6 @@ typedef struct _device {
char *description;
char *devname;
DeviceType type;
- Boolean enabled;
Boolean (*init)(struct _device *dev);
FILE * (*get)(struct _device *dev, char *file, Boolean probe);
void (*shutdown)(struct _device *dev);
@@ -302,8 +301,7 @@ extern void command_shell_add(char *key, const char *fmt, ...) __printflike(2, 3
extern void command_func_add(char *key, commandFunc func, void *data);
/* devices.c */
-extern DMenu *deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d),
- int (*check)(dialogMenuItem *d));
+extern DMenu *deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d));
extern void deviceGetAll(void);
extern void deviceReset(void);
extern void deviceRescan(void);
@@ -311,7 +309,7 @@ extern Device **deviceFind(char *name, DeviceType type);
extern Device **deviceFindDescr(char *name, char *desc, DeviceType class);
extern int deviceCount(Device **devs);
extern Device *new_device(char *name);
-extern Device *deviceRegister(char *name, char *desc, char *devicename, DeviceType type, Boolean enabled,
+extern Device *deviceRegister(char *name, char *desc, char *devicename, DeviceType type,
Boolean (*init)(Device *mediadev),
FILE * (*get)(Device *dev, char *file, Boolean probe),
void (*shutDown)(Device *mediadev),
@@ -325,8 +323,7 @@ extern void dummyShutdown(Device *dev);
extern void diskPartition(Device *dev);
extern int diskPartitionEditor(dialogMenuItem *self);
#endif
-extern int diskPartitionWrite(dialogMenuItem *self);
-extern int diskGetSelectCount(Device ***devs);
+extern int diskPartitionWrite(Device *dev);
/* dispatch.c */
extern int dispatchCommand(char *command);
@@ -366,7 +363,7 @@ extern void globalsInit(void);
extern Boolean checkLabels(Boolean whinge);
extern int installCommit(dialogMenuItem *self);
extern int installCustomCommit(dialogMenuItem *self);
-extern int installFilesystems(dialogMenuItem *self);
+extern int installFilesystems(Device *dev);
extern int installVarDefaults(dialogMenuItem *self);
extern void installEnvironment(void);
extern Boolean copySelf(void);
@@ -376,7 +373,7 @@ extern int kget(char *out);
/* label.c */
extern int diskLabelEditor(dialogMenuItem *self);
-extern int diskLabelCommit(dialogMenuItem *self);
+extern int diskLabelCommit(Device *dev);
/* misc.c */
extern Boolean file_readable(char *fname);
OpenPOWER on IntegriCloud