Use a menu when asking for the install disk (fixes PR install/20121).
Make disk_desc[], disk and numdisks local to get_disks (instead of globals). Fix a little fallout from the above. A bit of mbr.c was missing #ifdef BOOTSEL...
This commit is contained in:
parent
8e56a9f2a2
commit
e64fcd4452
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: md.c,v 1.11 2003/06/13 11:57:29 dsl Exp $ */
|
||||
/* $NetBSD: md.c,v 1.12 2003/07/11 15:29:00 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -138,7 +138,7 @@ md_get_info(void)
|
|||
struct filecore_bootblock *fcbb = (struct filecore_bootblock *)bb;
|
||||
int offset = 0;
|
||||
|
||||
if (strncmp(disk->dd_name, "wd", 2) == 0)
|
||||
if (strncmp(diskdev, "wd", 2) == 0)
|
||||
disktype = "ST506";
|
||||
else
|
||||
disktype = "SCSI";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: md.c,v 1.12 2003/06/13 11:57:29 dsl Exp $ */
|
||||
/* $NetBSD: md.c,v 1.13 2003/07/11 15:29:01 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -137,7 +137,7 @@ md_get_info(void)
|
|||
struct filecore_bootblock *fcbb = (struct filecore_bootblock *)bb;
|
||||
int offset = 0;
|
||||
|
||||
if (strncmp(disk->dd_name, "wd", 2) == 0)
|
||||
if (strncmp(diskdev, "wd", 2) == 0)
|
||||
disktype = "ST506";
|
||||
else
|
||||
disktype = "SCSI";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: md.c,v 1.13 2003/06/13 22:27:05 dsl Exp $ */
|
||||
/* $NetBSD: md.c,v 1.14 2003/07/11 15:29:01 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -114,9 +114,10 @@ md_make_bsd_partitions(void)
|
|||
/*
|
||||
* Setup the disktype so /etc/disktab gets proper info
|
||||
*/
|
||||
if (strncmp (disk->dd_name, "sd", 2) == 0)
|
||||
disktype = "SCSI";
|
||||
else disktype = "ST506";
|
||||
if (strncmp (diskdev, "sd", 2) == 0)
|
||||
disktype = "SCSI";
|
||||
else
|
||||
disktype = "ST506";
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: md.c,v 1.10 2003/06/13 11:57:30 dsl Exp $ */
|
||||
/* $NetBSD: md.c,v 1.11 2003/07/11 15:29:02 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -66,7 +66,7 @@ md_get_info (void)
|
|||
#endif
|
||||
int offset = 0;
|
||||
|
||||
if (strncmp(disk->dd_name, "wd", 2) == 0)
|
||||
if (strncmp(diskdev, "wd", 2) == 0)
|
||||
disktype = "ST506";
|
||||
else
|
||||
disktype = "SCSI";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: md.c,v 1.11 2003/06/13 11:57:30 dsl Exp $ */
|
||||
/* $NetBSD: md.c,v 1.12 2003/07/11 15:29:02 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -60,7 +60,7 @@ md_get_info(void)
|
|||
int fd;
|
||||
char devname[100];
|
||||
|
||||
if (strncmp(disk->dd_name, "wd", 2) == 0)
|
||||
if (strncmp(diskdev, "wd", 2) == 0)
|
||||
disktype = "ST506";
|
||||
else
|
||||
disktype = "SCSI";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: md.c,v 1.36 2003/07/07 12:30:26 dsl Exp $ */
|
||||
/* $NetBSD: md.c,v 1.37 2003/07/11 15:29:03 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -740,12 +740,11 @@ md_get_info()
|
|||
/*
|
||||
* Setup the disktype so /etc/disktab gets proper info
|
||||
*/
|
||||
if (strncmp (disk->dd_name, "sd", 2) == 0) {
|
||||
disktype = "SCSI";
|
||||
doessf = "sf:";
|
||||
}
|
||||
else
|
||||
disktype = "IDE";
|
||||
if (strncmp(diskdev, "sd", 2) == 0) {
|
||||
disktype = "SCSI";
|
||||
doessf = "sf:";
|
||||
} else
|
||||
disktype = "IDE";
|
||||
|
||||
return edit_diskmap();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: md.c,v 1.11 2003/06/13 11:57:35 dsl Exp $ */
|
||||
/* $NetBSD: md.c,v 1.12 2003/07/11 15:29:04 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -60,7 +60,7 @@ md_get_info(void)
|
|||
int fd;
|
||||
char devname[100];
|
||||
|
||||
if (strncmp(disk->dd_name, "wd", 2) == 0)
|
||||
if (strncmp(diskdev, "wd", 2) == 0)
|
||||
disktype = "ST506";
|
||||
else
|
||||
disktype = "SCSI";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: defs.h,v 1.95 2003/07/08 17:38:54 dsl Exp $ */
|
||||
/* $NetBSD: defs.h,v 1.96 2003/07/11 15:28:58 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -175,40 +175,16 @@ EXTERN FILE *script;
|
|||
EXTERN unsigned long ramsize INIT(0);
|
||||
EXTERN unsigned int rammb INIT(0);
|
||||
|
||||
/* Disk descriptions */
|
||||
#define MAX_DISKS 15
|
||||
struct disk_desc {
|
||||
char dd_name[SSTRSIZE];
|
||||
struct disk_geom {
|
||||
int dg_cyl;
|
||||
int dg_head;
|
||||
int dg_sec;
|
||||
int dg_secsize;
|
||||
int dg_totsec;
|
||||
} dg;
|
||||
};
|
||||
#define dd_cyl dg.dg_cyl
|
||||
#define dd_head dg.dg_head
|
||||
#define dd_sec dg.dg_sec
|
||||
#define dd_secsize dg.dg_secsize
|
||||
#define dd_totsec dg.dg_totsec
|
||||
|
||||
EXTERN struct disk_desc disks[MAX_DISKS];
|
||||
|
||||
EXTERN struct disk_desc *disk;
|
||||
EXTERN int sectorsize;
|
||||
|
||||
/* Actual name of the disk. */
|
||||
EXTERN char diskdev[SSTRSIZE] INIT("");
|
||||
EXTERN int rootpart; /* partition we install into */
|
||||
EXTERN char disknames[STRSIZE];
|
||||
EXTERN int numdisks;
|
||||
EXTERN char *disktype INIT("unknown"); /* ST506, SCSI, ... */
|
||||
|
||||
/* Area of disk we can allocate, start and size in disk sectors. */
|
||||
EXTERN int ptstart, ptsize;
|
||||
|
||||
/* Actual values for current disk - set by md_get_info() */
|
||||
/* Actual values for current disk - set by find_disks() or md_get_info() */
|
||||
EXTERN int sectorsize;
|
||||
EXTERN int dlcyl, dlhead, dlsec, dlsize, dlcylsize;
|
||||
EXTERN int current_cylsize;
|
||||
EXTERN int root_limit;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disks.c,v 1.63 2003/07/08 17:38:55 dsl Exp $ */
|
||||
/* $NetBSD: disks.c,v 1.64 2003/07/11 15:28:58 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -61,10 +61,25 @@
|
|||
#include "menu_defs.h"
|
||||
#include "txtwalk.h"
|
||||
|
||||
|
||||
/* Disk descriptions */
|
||||
#define MAX_DISKS 15
|
||||
struct disk_desc {
|
||||
char dd_name[SSTRSIZE];
|
||||
struct disk_geom {
|
||||
int dg_cyl;
|
||||
int dg_head;
|
||||
int dg_sec;
|
||||
int dg_secsize;
|
||||
int dg_totsec;
|
||||
} dg;
|
||||
};
|
||||
#define dd_cyl dg.dg_cyl
|
||||
#define dd_head dg.dg_head
|
||||
#define dd_sec dg.dg_sec
|
||||
#define dd_secsize dg.dg_secsize
|
||||
#define dd_totsec dg.dg_totsec
|
||||
|
||||
/* Local prototypes */
|
||||
static void get_disks (void);
|
||||
static void foundffs(struct data *, size_t);
|
||||
static int do_fsck(const char *);
|
||||
static int fsck_root(void);
|
||||
|
@ -78,21 +93,19 @@ static int target_mount_with_error_menu(const char *, char *, const char *);
|
|||
#define DISK_NAMES "wd", "sd", "ld"
|
||||
#endif
|
||||
|
||||
static char *disk_names[] = { DISK_NAMES, NULL };
|
||||
static char *disk_names[] = { DISK_NAMES, "vnd", NULL };
|
||||
|
||||
static void
|
||||
get_disks(void)
|
||||
static int
|
||||
get_disks(struct disk_desc *dd)
|
||||
{
|
||||
char **xd;
|
||||
char d_name[SSTRSIZE];
|
||||
struct disklabel l;
|
||||
struct disk_desc *dd;
|
||||
int i;
|
||||
int numdisks;
|
||||
|
||||
/* initialize */
|
||||
disknames[0] = 0;
|
||||
numdisks = 0;
|
||||
dd = disks;
|
||||
|
||||
for (xd = disk_names; *xd != NULL; xd++) {
|
||||
for (i = 0; i < MAX_DISKS; i++) {
|
||||
|
@ -102,9 +115,7 @@ get_disks(void)
|
|||
break;
|
||||
continue;
|
||||
}
|
||||
strncpy(dd->dd_name, d_name, sizeof dd->dd_name);
|
||||
strlcat(disknames, d_name, sizeof disknames);
|
||||
strlcat(disknames, " ", sizeof disknames);
|
||||
strlcpy(dd->dd_name, d_name, sizeof dd->dd_name);
|
||||
dd->dd_cyl = l.d_ncylinders;
|
||||
dd->dd_head = l.d_ntracks;
|
||||
dd->dd_sec = l.d_nsectors;
|
||||
|
@ -113,22 +124,32 @@ get_disks(void)
|
|||
dd++;
|
||||
numdisks++;
|
||||
if (numdisks >= MAX_DISKS)
|
||||
return;
|
||||
return numdisks;
|
||||
}
|
||||
}
|
||||
return numdisks;
|
||||
}
|
||||
|
||||
static int
|
||||
set_dsk_select(menudesc *m, menu_ent *opt, void *arg)
|
||||
{
|
||||
*(int *)arg = m->cursel;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
find_disks(const char *doingwhat)
|
||||
{
|
||||
char *tp;
|
||||
const char *prompt;
|
||||
char defname[STRSIZE];
|
||||
int i;
|
||||
struct disk_desc disks[MAX_DISKS];
|
||||
menu_ent dsk_menu[nelem(disks)];
|
||||
struct disk_desc *disk;
|
||||
int i;
|
||||
int numdisks;
|
||||
int selected_disk = 0;
|
||||
int menu_no;
|
||||
|
||||
/* Find disks. */
|
||||
get_disks();
|
||||
numdisks = get_disks(disks);
|
||||
|
||||
/* need a redraw here, kernel messages hose everything */
|
||||
touchwin(stdscr);
|
||||
|
@ -144,43 +165,37 @@ find_disks(const char *doingwhat)
|
|||
|
||||
if (numdisks == 1) {
|
||||
/* One disk found! */
|
||||
/* Remove that space we added. */
|
||||
disknames[strlen(disknames) - 1] = 0;
|
||||
msg_display(MSG_onedisk, disknames, doingwhat);
|
||||
msg_display(MSG_onedisk, disks[0].dd_name, doingwhat);
|
||||
process_menu(MENU_ok, NULL);
|
||||
strlcpy(diskdev, disknames, sizeof diskdev);
|
||||
} else {
|
||||
/* Multiple disks found! */
|
||||
strcpy(defname, disknames);
|
||||
tp = defname;
|
||||
strsep(&tp, " ");
|
||||
prompt = MSG_askdisk;
|
||||
do {
|
||||
msg_prompt(prompt, defname, diskdev, 10, disknames);
|
||||
prompt = MSG_badname;
|
||||
tp = diskdev;
|
||||
strsep(&tp, " ");
|
||||
diskdev[strlen(diskdev) + 1] = 0;
|
||||
diskdev[strlen(diskdev)] = ' ';
|
||||
tp = strstr(disknames, diskdev);
|
||||
} while (tp == NULL || (tp != disknames && tp[-1] != ' '));
|
||||
|
||||
/* Remove that space we added. */
|
||||
diskdev[strlen(diskdev) - 1] = 0;
|
||||
for (i = 0; i < numdisks; i++) {
|
||||
dsk_menu[i].opt_name = disks[i].dd_name;
|
||||
dsk_menu[i].opt_menu = OPT_NOMENU;
|
||||
dsk_menu[i].opt_flags = OPT_EXIT;
|
||||
dsk_menu[i].opt_action = set_dsk_select;
|
||||
}
|
||||
menu_no = new_menu(MSG_Available_disks,
|
||||
dsk_menu, numdisks, -1, 4, 0, 0,
|
||||
MC_SCROLL | MC_NOEXITOPT,
|
||||
NULL, NULL, NULL, NULL, NULL);
|
||||
if (menu_no == -1)
|
||||
return -1;
|
||||
msg_display(MSG_ask_disk);
|
||||
process_menu(menu_no, &selected_disk);
|
||||
free_menu(menu_no);
|
||||
}
|
||||
|
||||
/* Set disk. */
|
||||
for (i = 0; i < numdisks; i++)
|
||||
if (strcmp(diskdev, disks[i].dd_name) == 0)
|
||||
disk = &disks[i];
|
||||
disk = disks + selected_disk;
|
||||
strlcpy(diskdev, disk->dd_name, sizeof diskdev);
|
||||
|
||||
sectorsize = disk->dd_secsize;
|
||||
if (disk->dd_totsec == 0)
|
||||
disk->dd_totsec = disk->dd_cyl * disk->dd_head * disk->dd_sec;
|
||||
dlcyl = disk->dd_cyl;
|
||||
dlhead = disk->dd_head;
|
||||
dlsec = disk->dd_sec;
|
||||
dlsize = disk->dd_totsec;
|
||||
if (dlsize == 0)
|
||||
dlsize = disk->dd_cyl * disk->dd_head * disk->dd_sec;
|
||||
dlcylsize = dlhead * dlsec;
|
||||
|
||||
/* Get existing/default label */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mbr.c,v 1.46 2003/07/08 17:38:56 dsl Exp $ */
|
||||
/* $NetBSD: mbr.c,v 1.47 2003/07/11 15:28:58 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -1294,10 +1294,12 @@ read_mbr(const char *disk, mbr_info_t *mbri)
|
|||
} else {
|
||||
mbri->last_mounted[i] = strdup(get_last_mounted(
|
||||
fd, mbri->sector + mbrp->mbrp_start));
|
||||
#if BOOTSEL
|
||||
if (ombri->install == 0 &&
|
||||
strcmp(mbri->last_mounted[i], "/") == 0)
|
||||
ombri->install = mbri->sector +
|
||||
mbrp->mbrp_start;
|
||||
#endif
|
||||
}
|
||||
#if BOOTSEL
|
||||
if (mbri->nametab[i][0] != 0 && bootkey-- == 0)
|
||||
|
@ -1503,7 +1505,7 @@ guess_biosgeom_from_mbr(mbr_info_t *mbri, int *cyl, int *head, int *sec)
|
|||
if (xcylinders > MAXCYL || xheads > MAXHEAD || xsectors > MAXSECTOR) {
|
||||
xsectors = MAXSECTOR;
|
||||
xheads = MAXHEAD;
|
||||
xcylinders = disk->dd_totsec / (MAXSECTOR * MAXHEAD);
|
||||
xcylinders = dlsize / (MAXSECTOR * MAXHEAD);
|
||||
if (xcylinders > MAXCYL)
|
||||
xcylinders = MAXCYL;
|
||||
}
|
||||
|
@ -1541,7 +1543,7 @@ guess_biosgeom_from_mbr(mbr_info_t *mbri, int *cyl, int *head, int *sec)
|
|||
* Estimate the number of cylinders.
|
||||
* XXX relies on get_disks having been called.
|
||||
*/
|
||||
xcylinders = disk->dd_totsec / xheads / xsectors;
|
||||
xcylinders = dlsize / xheads / xsectors;
|
||||
|
||||
/* Now verify consistency with each of the partition table entries.
|
||||
* Be willing to shove cylinders up a little bit to make things work,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: msg.mi.en,v 1.112 2003/07/08 17:38:57 dsl Exp $ */
|
||||
/* $NetBSD: msg.mi.en,v 1.113 2003/07/11 15:28:59 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -123,14 +123,11 @@ message onedisk
|
|||
Therefore I assume you want to %s NetBSD on it.
|
||||
}
|
||||
|
||||
message askdisk
|
||||
{I have found the following disks: %s
|
||||
\nOn which disk do you want to install NetBSD? }
|
||||
message ask_disk
|
||||
{On which disk do you want to install NetBSD? }
|
||||
|
||||
message badname
|
||||
{You did not choose one of the listed disks. Please try again.
|
||||
The following disks are available: %s
|
||||
\nOn which disk do you want to install NetBSD? }
|
||||
message Available_disks
|
||||
{Available disks}
|
||||
|
||||
message pleasemountroot
|
||||
{The root device is not mounted. Please mount it.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: msg.mi.fr,v 1.62 2003/07/08 17:38:57 dsl Exp $ */
|
||||
/* $NetBSD: msg.mi.fr,v 1.63 2003/07/11 15:28:59 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -130,15 +130,11 @@ message onedisk
|
|||
NetBSD dessus.
|
||||
}
|
||||
|
||||
message askdisk
|
||||
{J'ai trouvé les disques suivants : %s
|
||||
\nSur quel disque voulez vous installer NetBSD ?}
|
||||
message ask_disk
|
||||
{Sur quel disque voulez vous installer NetBSD ?}
|
||||
|
||||
|
||||
message badname
|
||||
{Vous n'avez pas choisi un disque dans la liste. Veuillez en choisir un..
|
||||
Les disques suivants sont disponibles : %s
|
||||
\nSur quel disque voulez vous installer NetBSD ?}
|
||||
message Available_disks /* XXX translate */
|
||||
{Available disks}
|
||||
|
||||
message pleasemountroot
|
||||
{Le système de fichiers racine n'est pas monté. Veuillez le monter.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: msg.mi.pl,v 1.24 2003/07/08 17:38:58 dsl Exp $ */
|
||||
/* $NetBSD: msg.mi.pl,v 1.25 2003/07/11 15:29:00 dsl Exp $ */
|
||||
/* Based on english version: */
|
||||
/* NetBSD: msg.mi.en,v 1.86 2002/04/04 14:26:44 ad Exp */
|
||||
|
||||
|
@ -126,14 +126,11 @@ message onedisk
|
|||
NetBSD wlasnie na nim.
|
||||
}
|
||||
|
||||
message askdisk
|
||||
{Znalazlem nastepujace dyski: %s
|
||||
\nNa ktorym z nich chcesz zainstalowac NetBSD? }
|
||||
message ask_disk
|
||||
{Na ktorym z nich chcesz zainstalowac NetBSD? }
|
||||
|
||||
message badname
|
||||
{Nie wybrales dysku z listy. Sprobuj jeszcze raz.
|
||||
Nastepujace dyski sa dostepne: %s
|
||||
\nNa ktorym z nich chcesz zainstalowac NetBSD? }
|
||||
message Available_disks /* XXX translate */
|
||||
{Available disks}
|
||||
|
||||
message pleasemountroot
|
||||
{Glowny dysk nie jest zamountowany. Zamountuj go.
|
||||
|
|
Loading…
Reference in New Issue