Use dynamic menu to select partition to edit

This commit is contained in:
dsl 2003-06-09 19:06:48 +00:00
parent 3c95a92e07
commit 44fa8ce69d
8 changed files with 262 additions and 79 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.82 2003/06/05 14:30:14 dsl Exp $ */
/* $NetBSD: md.c,v 1.83 2003/06/09 19:06:49 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -217,8 +217,7 @@ md_post_newfs(void)
char bootxx[8192 + 4];
#define bp (*(struct i386_boot_params *)(bootxx + 512 * 2 + 8))
ret = run_prog(RUN_DISPLAY, NULL,
"/bin/cp /usr/mdec/biosboot /mnt/boot");
ret = cp_to_target("/usr/mdec/biosboot", "/boot");
if (ret)
return ret;

View File

@ -1,4 +1,4 @@
/* $NetBSD: defs.h,v 1.83 2003/06/06 21:37:13 dsl Exp $ */
/* $NetBSD: defs.h,v 1.84 2003/06/09 19:06:48 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -281,6 +281,7 @@ void toplevel(void);
/* from disks.c */
int find_disks(void);
void fmt_fspart(char *, size_t, int);
void disp_cur_fspart(int, int);
int write_disklabel(void);
int make_filesystems(void);

View File

@ -1,4 +1,4 @@
/* $NetBSD: disks.c,v 1.56 2003/06/06 21:37:13 dsl Exp $ */
/* $NetBSD: disks.c,v 1.57 2003/06/09 19:06:48 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -185,6 +185,51 @@ find_disks(void)
return numdisks;
}
void
fmt_fspart(char *buf, size_t len, int ptn)
{
int poffset, psize, pend;
int l;
const char *desc;
poffset = bsdlabel[ptn].pi_offset / sizemult;
psize = bsdlabel[ptn].pi_size / sizemult;
if (psize == 0)
pend = 0;
else
pend = (bsdlabel[ptn].pi_offset +
bsdlabel[ptn].pi_size) / sizemult - 1;
desc = fstypenames[bsdlabel[ptn].pi_fstype];
#ifdef PART_BOOT
if (ptn == PART_BOOT)
desc = msg_string(MSG_Boot_partition_cant_change);
#endif
if (ptn == getrawpartition())
desc = msg_string(MSG_Whole_disk_cant_change);
else {
if (ptn == C)
desc = msg_string(MSG_NetBSD_partition_cant_change);
}
l = snprintf(buf, len, msg_string(MSG_fspart_row_start),
poffset, pend, psize, desc);
buf += l;
len -= l;
if (len <= 0)
return;
if (PI_ISBSDFS(&bsdlabel[ptn]))
snprintf(buf, len, msg_string(MSG_fspart_row_end_bsd),
bsdlabel[ptn].pi_bsize,
bsdlabel[ptn].pi_fsize,
bsdlabel[ptn].pi_newfs ? "No" : "Yes",
bsdlabel[ptn].pi_mount);
else if (bsdlabel[ptn].pi_fstype == FS_MSDOS)
snprintf(buf, len, msg_string(MSG_fspart_row_end_msdos),
bsdlabel[ptn].pi_mount);
else
snprintf(buf, len, msg_string(MSG_fspart_row_end_other));
}
void
disp_cur_fspart(int disp, int showall)
@ -211,8 +256,9 @@ disp_cur_fspart(int disp, int showall)
else
pend = (bsdlabel[i].pi_offset +
bsdlabel[i].pi_size) / sizemult - 1;
msg_table_add("%c: ", 'a' + i);
msg_table_add(MSG_fspart_row_start,
'a' + i, poffset, pend, psize,
poffset, pend, psize,
fstypenames[bsdlabel[i].pi_fstype]);
if (PI_ISBSDFS(&bsdlabel[i]))
msg_table_add(MSG_fspart_row_end_bsd,
@ -284,14 +330,28 @@ do_flfs_newfs(const char *partname, int partno, const char *mountpoint)
{
char dev_name[STRSIZE];
int error;
const char *newfs;
if (*mountpoint && bsdlabel[partno].pi_newfs)
if (!*mountpoint)
return 0;
if (bsdlabel[partno].pi_newfs) {
switch (bsdlabel[partno].pi_fstype) {
case FS_BSDFFS:
newfs = "/sbin/newfs";
break;
case FS_BSDLFS:
newfs = "/sbin/newfs_lfs";
break;
default:
return 0;
}
error = run_prog(RUN_DISPLAY, MSG_cmdfail, "%s /dev/r%s",
bsdlabel[partno].pi_fstype == FS_BSDFFS ?
"/sbin/newfs" : "/sbin/newfs_lfs", partname);
else
newfs, partname);
} else
error = 0;
if (*mountpoint && error == 0) {
if (error == 0) {
snprintf(dev_name, sizeof(dev_name), "/dev/%s", partname);
if (partno > 0) /* XXX strcmp(mountpoint, "/") ? XXX */
make_target_dir(mountpoint);
@ -330,37 +390,45 @@ make_fstab(void)
f = stdout;
#endif
}
for (i = 0; i < getmaxpartitions(); i++)
if (bsdlabel[i].pi_fstype == FS_BSDFFS) {
char *s = "#";
if (*bsdlabel[i].pi_mount != '\0')
s++;
scripting_fprintf(f, "%s/dev/%s%c %s ffs rw 1 %d\n", s,
diskdev, 'a' + i, bsdlabel[i].pi_mount,
fsck_num(bsdlabel[i].pi_mount));
} else if (bsdlabel[i].pi_fstype == FS_BSDLFS) {
char *s = "#";
for (i = 0; i < getmaxpartitions(); i++) {
const char *s = "";
const char *mp = bsdlabel[i].pi_mount;
const char *fstype = "ffs";
if (!*mp) {
/*
* No mount point specified, comment out line and
* use /mnt as a placeholder for the mount point.
*/
s = "# ";
mp = "/mnt";
}
switch (bsdlabel[i].pi_fstype) {
case FS_BSDLFS:
/* If there is no LFS, just comment it out. */
if (!check_lfs_progs() && *bsdlabel[i].pi_mount != '\0')
s++;
scripting_fprintf(f, "%s/dev/%s%c %s lfs rw 1 %d\n", s,
diskdev, 'a' + i, bsdlabel[i].pi_mount,
fsck_num(bsdlabel[i].pi_mount));
} else if (bsdlabel[i].pi_fstype == FS_MSDOS) {
char *s = "#";
if (*bsdlabel[i].pi_mount != '\0')
s++;
scripting_fprintf(f, "%s/dev/%s%c %s msdos rw 0 0\n", s,
diskdev, 'a' + i, bsdlabel[i].pi_mount);
} else if (bsdlabel[i].pi_fstype == FS_SWAP) {
if (check_lfs_progs())
s = "# ";
fstype = "lfs";
/* FALLTHROUGH */
case FS_BSDFFS:
scripting_fprintf(f, "%s/dev/%s%c %s %s rw 1 %d\n",
s, diskdev, 'a' + i, mp, fstype, fsck_num(mp));
break;
case FS_MSDOS:
scripting_fprintf(f, "%s/dev/%s%c %s msdos rw 0 0\n",
s, diskdev, 'a' + i, mp);
break;
case FS_SWAP:
if (swap_dev == -1)
swap_dev = i;
scripting_fprintf(f, "/dev/%s%c none swap sw 0 0\n",
diskdev, 'a' + i);
break;
}
}
if (tmp_mfs_size != 0) {
if (swap_dev != -1)
scripting_fprintf(f, "/dev/%s%c /tmp mfs rw,-s=%d\n",
@ -369,15 +437,17 @@ make_fstab(void)
scripting_fprintf(f, "swap /tmp mfs rw,-s=%d\n,
tmp_mfs_size");
}
/* Add /kern to fstab and make mountpoint. */
scripting_fprintf(script, "/kern /kern kernfs rw\n");
make_target_dir("/kern");
scripting_fprintf(NULL, "EOF\n");
#ifndef DEBUG
fclose(f);
fflush(NULL);
#endif
/* We added /kern to fstab, make mountpoint. */
make_target_dir("/kern");
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: label.c,v 1.27 2003/06/03 11:54:48 dsl Exp $ */
/* $NetBSD: label.c,v 1.28 2003/06/09 19:06:48 dsl Exp $ */
/*
* Copyright 1997 Jonathan Stone
@ -36,10 +36,11 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: label.c,v 1.27 2003/06/03 11:54:48 dsl Exp $");
__RCSID("$NetBSD: label.c,v 1.28 2003/06/09 19:06:48 dsl Exp $");
#endif
#include <sys/types.h>
#include <stddef.h>
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
@ -52,6 +53,13 @@ __RCSID("$NetBSD: label.c,v 1.27 2003/06/03 11:54:48 dsl Exp $");
#include "msg_defs.h"
#include "menu_defs.h"
struct ptn_menu_info {
int menu_no;
int flags;
#define PIF_SHOW_UNUSED 1
char texts[MAXPARTITIONS][70];
};
/*
* local prototypes
*/
@ -143,6 +151,71 @@ checklabel(lp, nparts, rawpart, bsdpart, ovly1, ovly2)
return (0);
}
static int
show_all_unused(menudesc *m, menu_ent *opt, void *arg)
{
struct ptn_menu_info *pi = arg;
pi->flags |= PIF_SHOW_UNUSED;
return 0;
}
static int
edit_ptn(menudesc *menu, menu_ent *opt, void *arg)
{
editpart = opt - menu->opts;
process_menu(MENU_edfspart, NULL);
return 0;
}
static void
set_label_texts(menudesc *menu, void *arg)
{
struct ptn_menu_info *pi = arg;
menu_ent *m;
int ptn, last_used_ptn;
int rawptn = getrawpartition();
int maxpart = getmaxpartitions();
msg_display(MSG_fspart, multname);
msg_table_add(MSG_fspart_header);
for (last_used_ptn = 0, ptn = 0; ptn < maxpart; ptn++) {
if (bsdlabel[ptn].pi_fstype != FS_UNUSED)
last_used_ptn = ptn;
m = &menu->opts[ptn];
m->opt_menu = OPT_NOMENU;
m->opt_flags = 0;
m->opt_name = pi->texts[ptn];
if (ptn == rawptn
#ifdef PART_BOOT
|| ptn == PART_BOOT
#endif
|| ptn == C) {
m->opt_action = NULL;
} else
m->opt_action = edit_ptn;
fmt_fspart(pi->texts[ptn], sizeof pi->texts[0], ptn);
}
if (!(pi->flags & PIF_SHOW_UNUSED) && ptn != ++last_used_ptn) {
ptn = last_used_ptn;
m = &menu->opts[ptn];
m->opt_name = msg_string(MSG_show_all_unused_partitions);
m->opt_action = show_all_unused;
ptn++;
}
m = &menu->opts[ptn];
m->opt_menu = MENU_sizechoice;
m->opt_flags = OPT_SUB;
m->opt_action = NULL;
m->opt_name = msg_string(MSG_askunits);
set_menu_numopts(pi->menu_no, ptn + 1);
}
/*
* Check a disklabel.
@ -156,11 +229,34 @@ edit_and_check_label(lp, nparts, rawpart, bsdpart)
int rawpart;
int bsdpart;
{
static struct menu_ent *menu;
static struct ptn_menu_info *pi;
int maxpart = getmaxpartitions();
if (menu == NULL) {
menu = malloc((maxpart + 1) * sizeof *menu);
pi = malloc(offsetof(struct ptn_menu_info, texts[maxpart]) );
if (!menu || !pi)
return 1;
pi->flags = 0;
current_cylsize = dlcylsize;
pi->menu_no = new_menu(0, menu, maxpart + 1,
0, 6, maxpart + 2, 74,
MC_SCROLL | MC_NOBOX | MC_DFLTEXIT,
set_label_texts, NULL, NULL,
msg_string(MSG_partition_sizes_ok));
}
if (pi->menu_no < 0)
return 1;
for (;;) {
int i, j;
/* first give the user the option to edit the label... */
process_menu(MENU_fspartok, NULL);
process_menu(pi->menu_no, pi);
/* User thinks the label is OK. check for overlaps */
if (checklabel(lp, nparts, rawpart, bsdpart, &i, &j) == 0) {
@ -381,30 +477,36 @@ getpartsize(msg_no, partstart, defpartsize)
*/
void
atofsb(str, val, localsizemult)
atofsb(str, p_val, localsizemult)
const char *str;
int *val;
int *p_val;
int *localsizemult;
{
int i;
int val;
*localsizemult = sizemult;
if (str[0] == '\0') {
*val = -1;
*p_val = -1;
return;
}
*val = 0;
val = 0;
for (i = 0; str[i] != '\0'; i++) {
if (str[i] >= '0' && str[i] <= '9') {
*val = (*val) * 10 + str[i] - '0';
val = val * 10 + str[i] - '0';
continue;
}
if (str[i + 1] != '\0') {
/* A non-digit caracter, not at the end */
*val = -1;
val = -1;
return;
}
if (str[i] == 'M') {
if (str[i] == 'G' || str[i] == 'g') {
val *= 1024;
*localsizemult = MEG / sectorsize;
break;
}
if (str[i] == 'M' || str[i] == 'm') {
*localsizemult = MEG / sectorsize;
break;
}
@ -417,9 +519,9 @@ atofsb(str, val, localsizemult)
break;
}
/* not a known unit */
*val = -1;
*p_val = -1;
return;
}
*val = (*val) * (*localsizemult);
*p_val = val * (*localsizemult);
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.mi,v 1.2 2003/06/04 20:05:12 dsl Exp $ */
/* $NetBSD: menus.mi,v 1.3 2003/06/09 19:06:48 dsl Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -72,12 +72,6 @@ sysinst_menu_init(void)
}
return 0;
}
void
set_menu_numopts(int menu, int numopts)
{
menus[menu].numopts = numopts;
}
}
default y=12, no exit, scrollable;

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.en,v 1.100 2003/06/06 18:57:13 dsl Exp $ */
/* $NetBSD: msg.mi.en,v 1.101 2003/06/09 19:06:48 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -176,8 +176,7 @@ message layout
into multiple BSD partitions. You must now set up your BSD disklabel.
You have several choices. They are summarized below.
-- Standard: the BSD disklabel partitions are computed by this program.
-- Standard with X: twice the swap space, space for X binaries.
-- Custom: you specify the sizes of all the BSD disklabel partitions.
-- Standard with X: additional space for X binaries.
-- Use existing: use current partitions. You must assign mount points.
The NetBSD part of your disk is %.2f Megabytes.
@ -198,8 +197,8 @@ cylinder size.
}
message defaultunit
{Unless specified with 'M' (megabytes), 'c' (cylinders) or 's' sector
at the end of input, sizes and offsets are in %s.
{Unless specified with 'M' (megabytes), 'G' (gigabytes), 'c' (cylinders)
or 's' sector at the end of input, sizes and offsets are in %s.
}
message ptnsizes
@ -244,20 +243,21 @@ partition size has been truncated to %d %s.
}
message fspart
{We now have your BSD-disklabel partitions as (Start, End and Size in %s):
{We now have your BSD-disklabel partitions as (Start, End and Size in %s).
This is your last chance to change it.
}
message fspart_header
{ Start End Size FStype Bsize Fsize Preserve Mount point
{ Start End Size FStype Bsize Fsize Preserve Mount point
--------- --------- --------- ------ ----- ----- -------- -----------
}
message fspart_row_start
{%c: %-9d %-9d %-9d %-6s }
{%9d %9d %9d %-6s }
message fspart_row_end_bsd
{%-5d %-5d %-8s %s\n}
{%5d %5d %-8s %s\n}
message fspart_row_end_msdos
{ %s\n}
@ -265,6 +265,12 @@ message fspart_row_end_msdos
message fspart_row_end_other
{\n}
message show_all_unused_partitions
{Show all unused partitions}
message partition_sizes_ok
{Partition sizes ok}
message edfspart
{You should set the file system (FS) kind first. Then set the other values.

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.fr,v 1.50 2003/06/06 18:57:14 dsl Exp $ */
/* $NetBSD: msg.mi.fr,v 1.51 2003/06/09 19:06:48 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -179,8 +179,7 @@ message layout
NetBSD en de multiples partitions BSD. Vous devez maintenant paramétrer le
disklabel BSD. Vous avez différent choix:
-- Standard : les partitions sont calculées par ce programme.
-- Standard avec X : le double de swap plus la taille des binaires X.
-- Personnalisée : vous choisissez la taille des partitions.
-- Standard avec X : plus la taille des binaires X.
-- Use existing: use current partitions. You must assign mount points.
La taille allouée pour NetBSD sur votre disque est de %.2f Megaoctets.
@ -249,18 +248,19 @@ La taille de la partition a
message fspart
{Vos partitions NetBSD sont les suivantes (taille et offset en %s) :
}
message fspart_header
{ Start End Size FStype Bsize Fsize Preserve Mount point
message fspart_header /* XXX translate */
{ Start End Size FStype Bsize Fsize Preserve Mount point
--------- --------- --------- ------ ----- ----- -------- -----------
}
message fspart_row_start
{%c: %-9d %-9d %-9d %-6s }
{%9d %9d %9d %-6s }
message fspart_row_end_bsd
{%-5d %-5d %-8s %s\n}
{%5d %5d %-8s %s\n}
message fspart_row_end_msdos
{ %s\n}
@ -268,6 +268,11 @@ message fspart_row_end_msdos
message fspart_row_end_other
{\n}
message show_all_unused_partitions /* XXX translate */
{Show all unused partitions}
message partition_sizes_ok /* XXX translate */
{Partition sizes ok}
message edfspart
{Vous devez d'abord préciser le type de système de fichier (FS), et ensuite les

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.pl,v 1.13 2003/06/06 18:57:14 dsl Exp $ */
/* $NetBSD: msg.mi.pl,v 1.14 2003/06/09 19:06:48 dsl Exp $ */
/* Based on english version: */
/* NetBSD: msg.mi.en,v 1.86 2002/04/04 14:26:44 ad Exp */
@ -178,8 +178,7 @@ message layout
partycji BSD. Musisz teraz skonfigurowac BSD disklabel.
Masz kilka mozliwosci. Sa one opisane ponizej.
-- Standard: partycje BSD disklabel sa ustawiane przez ten program.
-- Standard z Xami: podwojona partycja wymiany, miejsce na binaria X.
-- Wlasna: sam ustawiasz rozmiary wszystkich partycji BSD disklabel.
-- Standard z Xami: miejsce na binaria X.
-- Uzyj istniejacych: Uzywa aktualnych partycji. Musisz je zamountowac.
Dysk NetBSD to %.2f Megabajtow.
@ -200,8 +199,8 @@ rozmiaru cylindra.
}
message defaultunit
{Jezeli nie wybrales 'M' (megabajty), 'c' (cylindry) lub 's' sektory
rozmiary i przesuniecia podawane sa w %s.
{Jezeli nie wybrales 'M' (megabajty), 'G' (gigabajty), 'c' (cylindry)
lub 's' sektory rozmiary i przesuniecia podawane sa w %s.
}
message ptnsizes /* XXX translate */
@ -248,18 +247,19 @@ twojej partycji zostal zmniejszony do %d %s.
message fspart
{Mamy teraz twoje partycje BSD-disklabel jako (Rozmiar i Przesuniecie w %s):
}
message fspart_header
{ Rozmiar Przesun. Koniec Typ SP Bsize Fsize Ochrona Mountpoint
{ Rozmiar Przesun. Koniec Typ SP Bsize Fsize Ochrona Mountpoint
--------- --------- --------- ------ ----- ----- -------- -----------
}
message fspart_row_start
{%c: %-9d %-9d %-9d %-6s }
{%9d %9d %9d %-6s }
message fspart_row_end_bsd
{%-5d %-5d %-8s %s\n}
{%5d %5d %-8s %s\n}
message fspart_row_end_msdos
{ %s\n}
@ -267,6 +267,12 @@ message fspart_row_end_msdos
message fspart_row_end_other
{\n}
message show_all_unused_partitions /* XXX translate */
{Show all unused partitions}
message partition_sizes_ok /* XXX translate */
{Partition sizes ok}
message edfspart
{Powinienes najpierw ustawic rodzaj systemu plikow (SP). Pozniej inne wartosci.