A rototil of the partition size requesting code.
This commit is contained in:
parent
9c3b5e7aec
commit
d19795892c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.31 2003/06/03 11:54:53 dsl Exp $ */
|
||||
/* $NetBSD: md.c,v 1.32 2003/06/04 20:05:14 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -986,7 +986,7 @@ md_make_bsd_partitions(void)
|
||||
bsdlabel[i].pi_fstype = FS_UNUSED;
|
||||
bsdlabel[i].pi_bsize = 0;
|
||||
bsdlabel[i].pi_fsize = 0;
|
||||
fsmount[i][0] = '\0';
|
||||
bsdlabel[i].pi_mount[0] = 0;
|
||||
}
|
||||
bsdlabel[RAW_PART].pi_size = dlsize;
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: bsddisklabel.c,v 1.11 2003/06/03 11:54:48 dsl Exp $ */
|
||||
/* $NetBSD: bsddisklabel.c,v 1.12 2003/06/04 20:05:12 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -83,19 +83,19 @@
|
||||
#ifndef DEFUSRSIZE
|
||||
#define DEFUSRSIZE 128
|
||||
#endif
|
||||
#ifndef STDNEEDMB
|
||||
#define STDNEEDMB 100
|
||||
#endif
|
||||
|
||||
int make_bsd_partitions (void);
|
||||
|
||||
static int
|
||||
save_ptn(int ptn, int start, int size, int fstype, const char *mountpt)
|
||||
{
|
||||
int maxptn;
|
||||
static int maxptn;
|
||||
int p;
|
||||
|
||||
if (ptn == -1) {
|
||||
if (maxptn == 0)
|
||||
maxptn = getmaxpartitions();
|
||||
|
||||
if (ptn < 0 || bsdlabel[ptn].pi_fstype != FS_UNUSED) {
|
||||
ptn = getrawpartition() + 1;
|
||||
#ifdef PART_FIRST_FREE
|
||||
if (ptn < PART_FIRST_FREE)
|
||||
@ -120,13 +120,279 @@ save_ptn(int ptn, int start, int size, int fstype, const char *mountpt)
|
||||
if (fstype == FS_BSDFFS) {
|
||||
bsdlabel[ptn].pi_bsize = 8192;
|
||||
bsdlabel[ptn].pi_fsize = 1024;
|
||||
bsdlabel[ptn].pi_newfs = 1;
|
||||
}
|
||||
|
||||
if (mountpt != NULL) {
|
||||
for (p = 0; p < maxptn; p++)
|
||||
if (strcmp(bsdlabel[p].pi_mount, mountpt) == 0)
|
||||
bsdlabel[p].pi_mount[0] = 0;
|
||||
strlcpy(bsdlabel[ptn].pi_mount, mountpt,
|
||||
sizeof bsdlabel[0].pi_mount);
|
||||
}
|
||||
if (mountpt)
|
||||
strlcpy(fsmount[ptn], mountpt, sizeof fsmount[0]);
|
||||
|
||||
return ptn;
|
||||
}
|
||||
|
||||
struct ptn_info {
|
||||
struct ptn_size {
|
||||
int ptn_id;
|
||||
char mount[20];
|
||||
int dflt_size;
|
||||
int size;
|
||||
} ptn_sizes[MAXPARTITIONS];
|
||||
int free_parts;
|
||||
int free_space;
|
||||
struct ptn_size *pool_part;
|
||||
int menu_no;
|
||||
WINDOW *msg_win;
|
||||
menu_ent ptn_menus[MAXPARTITIONS + 1];
|
||||
char ptn_titles[MAXPARTITIONS + 1][70];
|
||||
char exit_msg[70];
|
||||
};
|
||||
|
||||
static int set_ptn_size(menudesc *, menu_ent *, void *);
|
||||
|
||||
static void
|
||||
set_ptn_menu_texts(struct ptn_info *pi)
|
||||
{
|
||||
struct ptn_size *p;
|
||||
menu_ent *m;
|
||||
int i;
|
||||
int sm = MEG / sectorsize;
|
||||
int size;
|
||||
|
||||
for (i = 0; i < MAXPARTITIONS; i++) {
|
||||
p = &pi->ptn_sizes[i];
|
||||
m = &pi->ptn_menus[i];
|
||||
m->opt_menu = OPT_NOMENU;
|
||||
m->opt_flags = 0;
|
||||
m->opt_action = set_ptn_size;
|
||||
if (p->mount[0] == 0)
|
||||
break;
|
||||
size = p->size;
|
||||
snprintf(pi->ptn_titles[i], sizeof pi->ptn_titles[0],
|
||||
"%6u%10u%10u %c %s",
|
||||
size / sm, size / dlcylsize, size,
|
||||
p == pi->pool_part ? '+' : ' ',
|
||||
p->mount);
|
||||
}
|
||||
|
||||
if (pi->free_parts > 0) {
|
||||
snprintf(pi->ptn_titles[i], sizeof pi->ptn_titles[0], "%s",
|
||||
msg_string(MSG_add_another_ptn));
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i < MAXPARTITIONS) { /* it always is... */
|
||||
m = &pi->ptn_menus[i];
|
||||
current_cylsize = dlcylsize;
|
||||
m->opt_menu = MENU_sizechoice;
|
||||
m->opt_flags = OPT_SUB;
|
||||
m->opt_action = NULL;
|
||||
snprintf(pi->ptn_titles[i], sizeof pi->ptn_titles[0], "%s",
|
||||
msg_string(MSG_askunits));
|
||||
i++;
|
||||
}
|
||||
|
||||
if (pi->free_space >= 0)
|
||||
snprintf(pi->exit_msg, sizeof pi->exit_msg,
|
||||
msg_string(MSG_fssizesok),
|
||||
pi->free_space / sizemult, multname, pi->free_parts);
|
||||
else
|
||||
snprintf(pi->exit_msg, sizeof pi->exit_msg,
|
||||
msg_string(MSG_fssizesbad),
|
||||
-pi->free_space / sizemult, multname, -pi->free_space);
|
||||
|
||||
set_menu_numopts(pi->menu_no, i);
|
||||
}
|
||||
|
||||
static int
|
||||
set_ptn_size(menudesc *m, menu_ent *opt, void *arg)
|
||||
{
|
||||
struct ptn_info *pi = arg;
|
||||
struct ptn_size *p;
|
||||
char answer[20];
|
||||
char *cp;
|
||||
int size;
|
||||
int mult;
|
||||
|
||||
p = pi->ptn_sizes + (opt - m->opts);
|
||||
|
||||
if (p->mount[0] == 0) {
|
||||
msg_prompt_win(MSG_askfsmount, pi->msg_win,
|
||||
NULL, p->mount, sizeof p->mount);
|
||||
if (p->mount[0] == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
size = p->size;
|
||||
if (size == 0)
|
||||
size = p->dflt_size;
|
||||
size /= sizemult;
|
||||
snprintf(answer, sizeof answer, "%d", size);
|
||||
|
||||
msg_prompt_win(MSG_askfssize, pi->msg_win,
|
||||
answer, answer, sizeof answer,
|
||||
p->mount, multname);
|
||||
size = strtoul(answer, &cp, 0);
|
||||
mult = sizemult;
|
||||
switch (*cp++) {
|
||||
default:
|
||||
continue;
|
||||
case 's':
|
||||
mult = 1;
|
||||
break;
|
||||
case 'c':
|
||||
mult = dlcylsize;
|
||||
break;
|
||||
case 'm':
|
||||
mult = MEG / sectorsize;
|
||||
break;
|
||||
case '+':
|
||||
cp--;
|
||||
if (cp != answer)
|
||||
break;
|
||||
mult = 1;
|
||||
size = p->size;
|
||||
break;
|
||||
case 0:
|
||||
cp--;
|
||||
break;
|
||||
}
|
||||
if (*cp == 0 || *cp == '+')
|
||||
break;
|
||||
}
|
||||
|
||||
size = NUMSEC(size, mult, dlcylsize);
|
||||
if (pi->free_parts == 0 && size != 0 && p->size == 0)
|
||||
/* Don't allow 'free_parts' to go negative */
|
||||
return 0;
|
||||
if (p == pi->pool_part)
|
||||
pi->pool_part = NULL;
|
||||
if (size != 0 && *cp == '+')
|
||||
pi->pool_part = p;
|
||||
pi->free_space += p->size - size;
|
||||
if (size == 0) {
|
||||
if (p->size != 0)
|
||||
pi->free_parts++;
|
||||
if (p->ptn_id == -2)
|
||||
memmove(p, p + 1,
|
||||
(char *)&pi->ptn_sizes[MAXPARTITIONS - 1]
|
||||
- (char *)p);
|
||||
} else {
|
||||
if (p->size == 0)
|
||||
pi->free_parts--;
|
||||
if (pi->free_space < mult && -pi->free_space < mult
|
||||
&& mult > 1) {
|
||||
size += pi->free_space;
|
||||
pi->free_space = 0;
|
||||
}
|
||||
}
|
||||
p->size = size;
|
||||
|
||||
set_ptn_menu_texts(pi);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
get_ptn_sizes(int layoutkind, int part_start, int sectors)
|
||||
{
|
||||
int i;
|
||||
int maxpart = getmaxpartitions();
|
||||
int sm; /* sectors in 1MB */
|
||||
struct ptn_size *p;
|
||||
int size;
|
||||
|
||||
#define ROOT_SIZE (DEFROOTSIZE + DEFUSRSIZE)
|
||||
struct ptn_info pi = { {
|
||||
{ PART_ROOT, "/", ROOT_SIZE, ROOT_SIZE },
|
||||
{ PART_SWAP, "swap", 128, 128 },
|
||||
{ PART_USR, "/usr", DEFUSRSIZE },
|
||||
{ -1, "/var", DEFVARSIZE },
|
||||
{ -1, "/home", 0 },
|
||||
{ -2 }, { -2 }, { -2 }, { -2 }, { -2 }, { -2 },
|
||||
{ -2 }, { -2 }, { -2 }, { -2 }, { -2 },
|
||||
} };
|
||||
menu_ent *m;
|
||||
|
||||
if (maxpart > MAXPARTITIONS)
|
||||
maxpart = MAXPARTITIONS; /* sanity */
|
||||
|
||||
/* If installing X increase default size of /usr */
|
||||
if (layoutkind == 2) {
|
||||
pi.ptn_sizes[0].dflt_size += XNEEDMB;
|
||||
pi.ptn_sizes[2].dflt_size += XNEEDMB;
|
||||
}
|
||||
|
||||
/* Change preset size from MB to sectors */
|
||||
sm = MEG / sectorsize;
|
||||
pi.free_space = sectors;
|
||||
for (p = pi.ptn_sizes; p->mount[0]; p++) {
|
||||
p->size = NUMSEC(p->size, sm, dlcylsize);
|
||||
p->dflt_size = NUMSEC(p->dflt_size, sm, dlcylsize);
|
||||
pi.free_space -= p->size;
|
||||
}
|
||||
|
||||
/* Count free partition slots */
|
||||
pi.free_parts = -2; /* allow for root and swap */
|
||||
for (i = 0; i < maxpart; i++) {
|
||||
if (bsdlabel[i].pi_size == 0)
|
||||
pi.free_parts++;
|
||||
}
|
||||
|
||||
/* Give free space to one of the partitions */
|
||||
pi.pool_part = &pi.ptn_sizes[0];
|
||||
|
||||
pi.msg_win = newwin(3, getmaxx(stdscr) - 30, getmaxy(stdscr) - 4, 15);
|
||||
if (pi.msg_win == NULL)
|
||||
return;
|
||||
if (has_colors()) {
|
||||
/*
|
||||
* XXX This color trick should be done so much better,
|
||||
* but is it worth it?
|
||||
*/
|
||||
wbkgd(pi.msg_win, COLOR_PAIR(1));
|
||||
wattrset(pi.msg_win, COLOR_PAIR(1));
|
||||
}
|
||||
|
||||
/* Link data areas together for menu */
|
||||
for (i = 0; i < MAXPARTITIONS; i++) {
|
||||
m = &pi.ptn_menus[i];
|
||||
m->opt_name = pi.ptn_titles[i];
|
||||
}
|
||||
msg_display(MSG_ptnsizes);
|
||||
msg_table_add(MSG_ptnheaders);
|
||||
|
||||
pi.menu_no = new_menu(0, pi.ptn_menus, MAXPARTITIONS,
|
||||
0, 9, 12, sizeof pi.ptn_titles[0],
|
||||
MC_SCROLL | MC_NOBOX | MC_NOCLEAR, NULL, NULL,
|
||||
"help", pi.exit_msg);
|
||||
if (pi.menu_no < 0)
|
||||
return;
|
||||
|
||||
do {
|
||||
set_ptn_menu_texts(&pi);
|
||||
process_menu(pi.menu_no, &pi);
|
||||
} while (pi.free_space < 0 || pi.free_parts < 0);
|
||||
free_menu(pi.menu_no);
|
||||
|
||||
for (p = pi.ptn_sizes; p->mount[0]; p++, part_start += size) {
|
||||
size = p->size;
|
||||
if (p == pi.pool_part)
|
||||
size += pi.free_space;
|
||||
if (size == 0)
|
||||
continue;
|
||||
if (p->ptn_id == PART_SWAP) {
|
||||
save_ptn(p->ptn_id, part_start, size, FS_SWAP, NULL);
|
||||
continue;
|
||||
}
|
||||
save_ptn(p->ptn_id, part_start, size, FS_BSDFFS, p->mount);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* md back-end code for menu-driven BSD disklabel editor.
|
||||
*/
|
||||
@ -135,14 +401,12 @@ make_bsd_partitions(void)
|
||||
{
|
||||
int i;
|
||||
int part;
|
||||
int remain;
|
||||
char isize[20];
|
||||
int maxpart = getmaxpartitions();
|
||||
struct disklabel l;
|
||||
int varsz = 0, swapsz = 0;
|
||||
int partstart;
|
||||
int part_raw, part_bsd;
|
||||
int partstart, partsize;
|
||||
int ptend;
|
||||
struct partition *p;
|
||||
|
||||
/*
|
||||
* Initialize global variables that track space used on this disk.
|
||||
@ -156,18 +420,6 @@ make_bsd_partitions(void)
|
||||
partstart = ptstart;
|
||||
ptend = ptstart + ptsize;
|
||||
|
||||
/* Ask for layout type -- standard or special */
|
||||
msg_display(MSG_layout,
|
||||
(1.0*ptsize*sectorsize)/MEG,
|
||||
(1.0*minfsdmb*sectorsize)/MEG,
|
||||
(1.0*minfsdmb*sectorsize)/MEG+rammb+XNEEDMB);
|
||||
process_menu(MENU_layout, NULL);
|
||||
|
||||
if (layoutkind == 3)
|
||||
ask_sizemult(dlcylsize);
|
||||
else
|
||||
md_set_sizemultname();
|
||||
|
||||
/* Build standard partitions */
|
||||
emptylabel(bsdlabel);
|
||||
|
||||
@ -183,6 +435,7 @@ make_bsd_partitions(void)
|
||||
bsdlabel[part_raw].pi_size = dlsize;
|
||||
|
||||
if (part_raw == D) {
|
||||
/* Probably a system that expects an i386 style mbr */
|
||||
part_bsd = C;
|
||||
bsdlabel[C].pi_offset = ptstart;
|
||||
bsdlabel[C].pi_size = ptsize;
|
||||
@ -191,21 +444,20 @@ make_bsd_partitions(void)
|
||||
}
|
||||
|
||||
#if defined(PART_BOOT) && defined(BOOT_SIZE)
|
||||
partsize = BOOT_SIZE;
|
||||
if (partsize >= 1024) {
|
||||
i = BOOT_SIZE;
|
||||
if (i >= 1024) {
|
||||
/* Treat big numbers as a byte count */
|
||||
partsize = (partsize + dlcylsize * sectorsize - 1)
|
||||
/ (dlcylsize * sectorsize);
|
||||
partsize *= dlcylsize;
|
||||
i = (i + dlcylsize * sectorsize - 1) / (dlcylsize * sectorsize);
|
||||
i *= dlcylsize;
|
||||
}
|
||||
bsdlabel[PART_BOOT].pi_fstype = FS_BOOT;
|
||||
bsdlabel[PART_BOOT].pi_size = partsize;
|
||||
bsdlabel[PART_BOOT].pi_size = i;
|
||||
#ifdef BOOT_HIGH
|
||||
bsdlabel[PART_BOOT].pi_offset = ptend - partsize;
|
||||
ptend -= partsize;
|
||||
bsdlabel[PART_BOOT].pi_offset = ptend - i;
|
||||
ptend -= i;
|
||||
#else
|
||||
bsdlabel[PART_BOOT].pi_offset = ptstart;
|
||||
partstart += partsize;
|
||||
partstart += i;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -214,231 +466,57 @@ make_bsd_partitions(void)
|
||||
bsdlabel[PART_REST].pi_size = ptstart;
|
||||
#endif
|
||||
|
||||
switch (layoutkind) {
|
||||
case 1: /* standard: a root, b swap, c "unused", PART_USR /usr */
|
||||
case 2: /* standard X: as above, but with larger swap, and more
|
||||
* space in /usr */
|
||||
/* Ask for layout type -- standard or special */
|
||||
msg_display(MSG_layout,
|
||||
(1.0*ptsize*sectorsize)/MEG,
|
||||
(1.0*minfsdmb*sectorsize)/MEG,
|
||||
(1.0*minfsdmb*sectorsize)/MEG+rammb+XNEEDMB);
|
||||
|
||||
/*
|
||||
* Defaults:
|
||||
* root - always (PART_ROOT)
|
||||
* swap - ask, default (PART_SWAP)
|
||||
* /usr - ask, default (PART_USR)
|
||||
* /var - ask (PART_FIRST_FREE != PART_USR)
|
||||
* /home - ask (PART_FIRST_FREE+1 != PART_USR)
|
||||
* /tmp - ask mfs
|
||||
*/
|
||||
layout_swap = layout_usr = 1;
|
||||
layout_var = layout_home = layout_tmp = 0;
|
||||
process_menu(MENU_layoutparts, NULL);
|
||||
process_menu(MENU_layout, NULL);
|
||||
|
||||
/* Root */
|
||||
if (layout_usr == 0 && layout_home == 0) {
|
||||
if (layout_swap) {
|
||||
i = NUMSEC(layoutkind * 2 *
|
||||
(rammb < DEFSWAPRAM ? DEFSWAPRAM : rammb),
|
||||
MEG/sectorsize, dlcylsize);
|
||||
swapsz = NUMSEC(i/(MEG/sectorsize)+1,
|
||||
MEG/sectorsize, dlcylsize);
|
||||
}
|
||||
if (layout_var)
|
||||
varsz = NUMSEC(DEFVARSIZE, MEG/sectorsize,
|
||||
dlcylsize);
|
||||
partsize = ptsize - swapsz - varsz;
|
||||
} else if (layout_usr)
|
||||
partsize = NUMSEC(DEFROOTSIZE, MEG/sectorsize,
|
||||
dlcylsize);
|
||||
else if (layoutkind == 2)
|
||||
partsize = NUMSEC(STDNEEDMB + XNEEDMB, MEG/sectorsize,
|
||||
dlcylsize);
|
||||
else
|
||||
partsize = NUMSEC(STDNEEDMB, MEG/sectorsize, dlcylsize);
|
||||
|
||||
save_ptn(PART_ROOT, partstart, partsize, FS_BSDFFS, "/");
|
||||
partstart += partsize;
|
||||
#if notyet
|
||||
if (partstart > ptend)
|
||||
error ...
|
||||
#endif
|
||||
if (layoutkind == 3)
|
||||
reask_sizemult(dlcylsize);
|
||||
else
|
||||
md_set_sizemultname();
|
||||
|
||||
/* swap */
|
||||
if (layout_swap) {
|
||||
if (swapsz)
|
||||
partsize = swapsz;
|
||||
else {
|
||||
i = NUMSEC(layoutkind * 2 *
|
||||
(rammb < DEFSWAPRAM ? DEFSWAPRAM : rammb),
|
||||
MEG/sectorsize, dlcylsize) + partstart;
|
||||
partsize = NUMSEC(i/(MEG/sectorsize)+1,
|
||||
MEG/sectorsize, dlcylsize) - partstart;
|
||||
}
|
||||
save_ptn(PART_SWAP, partstart, partsize, FS_SWAP, 0);
|
||||
partstart += partsize;
|
||||
#if notyet
|
||||
if (partstart > ptend)
|
||||
error ...
|
||||
#endif
|
||||
}
|
||||
|
||||
/* var */
|
||||
if (layout_var) {
|
||||
if (varsz)
|
||||
partsize = varsz;
|
||||
else
|
||||
partsize = NUMSEC(DEFVARSIZE, MEG/sectorsize,
|
||||
dlcylsize);
|
||||
save_ptn(-1, partstart, partsize, FS_BSDFFS, "/var");
|
||||
partstart += partsize;
|
||||
#if notyet
|
||||
if (partstart > ptend)
|
||||
error ...
|
||||
#endif
|
||||
}
|
||||
|
||||
/* /usr */
|
||||
if (layout_usr) {
|
||||
if (layout_home) {
|
||||
if (layoutkind == 2)
|
||||
partsize = NUMSEC(DEFUSRSIZE + XNEEDMB,
|
||||
MEG/sectorsize, dlcylsize);
|
||||
else
|
||||
partsize = NUMSEC(DEFUSRSIZE,
|
||||
MEG/sectorsize, dlcylsize);
|
||||
} else
|
||||
partsize = ptend - partstart;
|
||||
save_ptn(PART_USR, partstart, partsize, FS_BSDFFS, "/usr");
|
||||
partstart += partsize;
|
||||
#if notyet
|
||||
if (partstart > ptend)
|
||||
error ...
|
||||
#endif
|
||||
}
|
||||
|
||||
/* home */
|
||||
if (layout_home) {
|
||||
partsize = ptend - partstart;
|
||||
save_ptn(-1, partstart, partsize, FS_BSDFFS, "/home");
|
||||
partstart += partsize;
|
||||
#if notyet
|
||||
if (partstart > ptend)
|
||||
error ...
|
||||
#endif
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 3: /* custom: ask user for all sizes */
|
||||
ask_sizemult(dlcylsize);
|
||||
/* root */
|
||||
remain = ptend - partstart;
|
||||
partsize = NUMSEC(DEFROOTSIZE, MEG/sectorsize, dlcylsize);
|
||||
snprintf(isize, 20, "%d", partsize/sizemult);
|
||||
msg_prompt(MSG_askfsroot, isize, isize, 20,
|
||||
remain/sizemult, multname);
|
||||
partsize = NUMSEC(atoi(isize), sizemult, dlcylsize);
|
||||
/* If less than a 'unit' left, also use it */
|
||||
if (remain - partsize < sizemult)
|
||||
partsize = remain;
|
||||
save_ptn(PART_ROOT, partstart, partsize, FS_BSDFFS, "/");
|
||||
partstart += partsize;
|
||||
|
||||
/* swap */
|
||||
remain = ptend - partstart;
|
||||
if (remain > 0) {
|
||||
i = NUMSEC(2 *
|
||||
(rammb < DEFSWAPRAM ? DEFSWAPRAM : rammb),
|
||||
MEG/sectorsize, dlcylsize) + partstart;
|
||||
partsize = NUMSEC(i/(MEG/sectorsize)+1, MEG/sectorsize,
|
||||
dlcylsize) - partstart;
|
||||
if (partsize > remain)
|
||||
partsize = remain;
|
||||
snprintf(isize, 20, "%d", partsize/sizemult);
|
||||
msg_prompt_add(MSG_askfsswap, isize, isize, 20,
|
||||
remain/sizemult, multname);
|
||||
partsize = NUMSEC(atoi(isize), sizemult, dlcylsize);
|
||||
if (partsize) {
|
||||
/* If less than a 'unit' left, also use it */
|
||||
if (remain - partsize < sizemult)
|
||||
partsize = remain;
|
||||
save_ptn(PART_SWAP, partstart, partsize, FS_SWAP, 0);
|
||||
partstart += partsize;
|
||||
}
|
||||
}
|
||||
|
||||
/* /usr */
|
||||
remain = ptend - partstart;
|
||||
if (remain > 0) {
|
||||
partsize = remain;
|
||||
snprintf(isize, 20, "%d", partsize/sizemult);
|
||||
msg_prompt_add(MSG_askfsusr, isize, isize, 20,
|
||||
remain/sizemult, multname);
|
||||
partsize = NUMSEC(atoi(isize), sizemult, dlcylsize);
|
||||
if (partsize) {
|
||||
/* If less than a 'unit' left, also use it */
|
||||
if (remain - partsize < sizemult)
|
||||
partsize = remain;
|
||||
save_ptn(PART_USR, partstart, partsize, FS_BSDFFS, "/usr");
|
||||
partstart += partsize;
|
||||
}
|
||||
}
|
||||
|
||||
/* Others ... */
|
||||
remain = ptend - partstart;
|
||||
if (remain > 0)
|
||||
msg_display(MSG_otherparts);
|
||||
part = save_ptn(-1, 0, 0, FS_UNUSED, 0);
|
||||
for (; remain > 0 && part < maxpart; ++part) {
|
||||
if (bsdlabel[part].pi_fstype != FS_UNUSED)
|
||||
continue;
|
||||
partsize = ptend - partstart;
|
||||
snprintf(isize, 20, "%d", partsize/sizemult);
|
||||
msg_prompt_add(MSG_askfspart, isize, isize, 20,
|
||||
diskdev, partition_name(part),
|
||||
remain/sizemult, multname);
|
||||
partsize = NUMSEC(atoi(isize), sizemult, dlcylsize);
|
||||
/* If less than a 'unit' left, also use it */
|
||||
if (remain - partsize < sizemult)
|
||||
partsize = remain;
|
||||
save_ptn(-1, partstart, partsize, FS_BSDFFS, 0);
|
||||
msg_prompt_add(MSG_mountpoint, NULL, fsmount[part], 20);
|
||||
partstart += partsize;
|
||||
remain = ptend - partstart;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 4: /* use existing disklabel */
|
||||
|
||||
if (get_real_geom(diskdev, &l) == 0) {
|
||||
if (get_real_geom(diskdev, &l) == 0) {
|
||||
if (layoutkind == 4) {
|
||||
/* Must have an old label to do 'existing' */
|
||||
msg_display(MSG_abort); /* XXX more informative */
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < maxpart; i++) {
|
||||
#define p l.d_partitions[i]
|
||||
if (i == part_raw || i == part_bsd)
|
||||
} else {
|
||||
/*
|
||||
* Save any partitions that are outside the area we are
|
||||
* going to use.
|
||||
* In particular this saves details of the other MBR
|
||||
* partitons on a multiboot i386 system.
|
||||
*/
|
||||
for (i = MIN(l.d_npartitions, maxpart); i--;) {
|
||||
if (bsdlabel[i].pi_size != 0)
|
||||
/* Don't overwrite special partitions */
|
||||
continue;
|
||||
#ifdef PART_BOOT
|
||||
if (i == PART_BOOT)
|
||||
p = &l.d_partitions[i];
|
||||
if (p->p_fstype == FS_UNUSED || p->p_size == 0)
|
||||
continue;
|
||||
#endif
|
||||
#ifdef PART_REST
|
||||
if (i == PART_REST)
|
||||
if (layoutkind != 4 &&
|
||||
p->p_offset < ptstart + ptsize &&
|
||||
p->p_offset + p->p_size > ptstart)
|
||||
/* Not outside area we are allocating */
|
||||
continue;
|
||||
#endif
|
||||
bsdlabel[i].pi_size = p.p_size;
|
||||
bsdlabel[i].pi_offset = p.p_offset;
|
||||
bsdlabel[i].pi_fstype = p.p_fstype;
|
||||
bsdlabel[i].pi_bsize = p.p_fsize * p.p_frag;
|
||||
bsdlabel[i].pi_fsize = p.p_fsize;
|
||||
/* menu to get fsmount[] entry */
|
||||
#undef p
|
||||
}
|
||||
msg_display(MSG_postuseexisting);
|
||||
getchar();
|
||||
break;
|
||||
bsdlabel[i].pi_size = p->p_size;
|
||||
bsdlabel[i].pi_offset = p->p_offset;
|
||||
bsdlabel[i].pi_fstype = p->p_fstype;
|
||||
bsdlabel[i].pi_bsize = p->p_fsize * p->p_frag;
|
||||
bsdlabel[i].pi_fsize = p->p_fsize;
|
||||
/* XXX get 'last mounted' */
|
||||
}
|
||||
}
|
||||
|
||||
if (layoutkind != 4)
|
||||
get_ptn_sizes(layoutkind, partstart, ptend - partstart);
|
||||
|
||||
|
||||
/*
|
||||
* OK, we have a partition table. Give the user the chance to
|
||||
* edit it and verify it's OK, or abort altogether.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: defs.h,v 1.79 2003/05/29 17:54:22 dsl Exp $ */
|
||||
/* $NetBSD: defs.h,v 1.80 2003/06/04 20:05:12 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -77,11 +77,13 @@ extern const char * const fstypenames[];
|
||||
#define RUN_SYSTEM 0x0010 /* just use system(3) */
|
||||
|
||||
/* Macros */
|
||||
#define nelem(x) (sizeof (x) / sizeof *(x))
|
||||
|
||||
/* Round up to the next full cylinder size */
|
||||
#define NUMSEC(size,sizemult,cylsize) \
|
||||
(((int)(size) == -1) ? -1 : (int)((sizemult == 1) ? (size) : \
|
||||
(((size)*(sizemult)+(cylsize)-1)/(cylsize))*(cylsize)))
|
||||
#define ROUNDUP(n,d) ((((n) + (d) - 1)/(d)) * (d))
|
||||
#define NUMSEC(size, sizemult, cylsize) \
|
||||
((size) == -1 ? -1 : (sizemult) == 1 ? (size) : \
|
||||
ROUNDUP((size) * (sizemult), (cylsize)))
|
||||
|
||||
/* What FS type? */
|
||||
#define PI_ISBSDFS(p) ((p)->pi_fstype == FS_BSDLFS || \
|
||||
@ -95,11 +97,13 @@ typedef struct distinfo {
|
||||
} distinfo;
|
||||
|
||||
typedef struct _partinfo {
|
||||
int pi_size;
|
||||
int pi_offset;
|
||||
int pi_fstype;
|
||||
int pi_bsize;
|
||||
int pi_fsize;
|
||||
int pi_size;
|
||||
int pi_offset;
|
||||
int pi_fstype;
|
||||
int pi_bsize;
|
||||
int pi_fsize;
|
||||
char pi_mount[20];
|
||||
int8_t pi_newfs;
|
||||
} partinfo; /* Single partition from a disklabel */
|
||||
|
||||
/* variables */
|
||||
@ -175,11 +179,8 @@ EXTERN int current_cylsize;
|
||||
/* Information for the NetBSD disklabel */
|
||||
enum DLTR {A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z};
|
||||
#define partition_name(x) ('a' + (x))
|
||||
EXTERN partinfo bsdlabel[16];
|
||||
EXTERN char fsmount[16][20] INIT({""});
|
||||
#define PM_INIT {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
|
||||
EXTERN int preservemount[16] INIT(PM_INIT);
|
||||
#undef PM_INIT
|
||||
EXTERN partinfo bsdlabel[MAXPARTITIONS];
|
||||
|
||||
#define DISKNAME_SIZE 80
|
||||
EXTERN char bsddiskname[DISKNAME_SIZE];
|
||||
EXTERN char *doessf INIT("");
|
||||
@ -262,6 +263,7 @@ EXTERN char fs_mount[MAXFS][STRSIZE];
|
||||
#endif
|
||||
|
||||
/* needed prototypes */
|
||||
void set_menu_numopts(int, int);
|
||||
|
||||
/* Machine dependent functions .... */
|
||||
int md_check_partitions(void);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: disks.c,v 1.53 2003/06/03 11:54:48 dsl Exp $ */
|
||||
/* $NetBSD: disks.c,v 1.54 2003/06/04 20:05:12 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -216,13 +216,13 @@ disp_cur_fspart(int disp, int showall)
|
||||
fstypenames[bsdlabel[i].pi_fstype]);
|
||||
if (PI_ISBSDFS(&bsdlabel[i]))
|
||||
msg_table_add(MSG_fspart_row_end_bsd,
|
||||
bsdlabel[i].pi_bsize,
|
||||
bsdlabel[i].pi_fsize,
|
||||
preservemount[i] ? "Yes" : "No",
|
||||
fsmount[i]);
|
||||
bsdlabel[i].pi_bsize,
|
||||
bsdlabel[i].pi_fsize,
|
||||
bsdlabel[i].pi_newfs ? "No" : "Yes",
|
||||
bsdlabel[i].pi_mount);
|
||||
else if (bsdlabel[i].pi_fstype == FS_MSDOS)
|
||||
msg_table_add(MSG_fspart_row_end_msdos,
|
||||
fsmount[i]);
|
||||
bsdlabel[i].pi_mount);
|
||||
else
|
||||
msg_table_add(MSG_fspart_row_end_other);
|
||||
}
|
||||
@ -270,7 +270,7 @@ make_filesystems(void)
|
||||
*/
|
||||
snprintf(partname, STRSIZE, "%s%c", diskdev, 'a' + i);
|
||||
if (PI_ISBSDFS(&bsdlabel[i]) && !is_active_rootpart(partname)) {
|
||||
error = do_flfs_newfs(partname, i, fsmount[i]);
|
||||
error = do_flfs_newfs(partname, i, bsdlabel[i].pi_mount);
|
||||
if (error)
|
||||
return error;
|
||||
}
|
||||
@ -285,7 +285,7 @@ do_flfs_newfs(const char *partname, int partno, const char *mountpoint)
|
||||
char dev_name[STRSIZE];
|
||||
int error;
|
||||
|
||||
if (*mountpoint && !preservemount[partno])
|
||||
if (*mountpoint && bsdlabel[partno].pi_newfs)
|
||||
error = run_prog(RUN_DISPLAY, MSG_cmdfail, "%s /dev/r%s",
|
||||
bsdlabel[partno].pi_fstype == FS_BSDFFS ?
|
||||
"/sbin/newfs" : "/sbin/newfs_lfs", partname);
|
||||
@ -334,27 +334,27 @@ make_fstab(void)
|
||||
if (bsdlabel[i].pi_fstype == FS_BSDFFS) {
|
||||
char *s = "#";
|
||||
|
||||
if (*fsmount[i] != '\0')
|
||||
if (*bsdlabel[i].pi_mount != '\0')
|
||||
s++;
|
||||
scripting_fprintf(f, "%s/dev/%s%c %s ffs rw 1 %d\n", s,
|
||||
diskdev, 'a' + i, fsmount[i],
|
||||
fsck_num(fsmount[i]));
|
||||
diskdev, 'a' + i, bsdlabel[i].pi_mount,
|
||||
fsck_num(bsdlabel[i].pi_mount));
|
||||
} else if (bsdlabel[i].pi_fstype == FS_BSDLFS) {
|
||||
char *s = "#";
|
||||
|
||||
/* If there is no LFS, just comment it out. */
|
||||
if (!check_lfs_progs() && *fsmount[i] != '\0')
|
||||
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, fsmount[i],
|
||||
fsck_num(fsmount[i]));
|
||||
diskdev, 'a' + i, bsdlabel[i].pi_mount,
|
||||
fsck_num(bsdlabel[i].pi_mount));
|
||||
} else if (bsdlabel[i].pi_fstype == FS_MSDOS) {
|
||||
char *s = "#";
|
||||
|
||||
if (*fsmount[i] != '\0')
|
||||
if (*bsdlabel[i].pi_mount != '\0')
|
||||
s++;
|
||||
scripting_fprintf(f, "%s/dev/%s%c %s msdos rw 0 0\n", s,
|
||||
diskdev, 'a' + i, fsmount[i]);
|
||||
diskdev, 'a' + i, bsdlabel[i].pi_mount);
|
||||
} else if (bsdlabel[i].pi_fstype == FS_SWAP) {
|
||||
if (swap_dev == -1)
|
||||
swap_dev = i;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.31 2003/06/03 11:54:48 dsl Exp $ */
|
||||
/* $NetBSD: main.c,v 1.32 2003/06/04 20:05:12 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -124,6 +124,11 @@ main(argc, argv)
|
||||
* XXX window will be overwritten by menus.
|
||||
*/
|
||||
win = newwin(getmaxy(stdscr) - 2, getmaxx(stdscr) - 2, 1, 1);
|
||||
if (win == NULL) {
|
||||
(void)fprintf(stderr,
|
||||
"sysinst: screen too small\n");
|
||||
exit(1);
|
||||
}
|
||||
if (has_colors()) {
|
||||
/*
|
||||
* XXX This color trick should be done so much better,
|
||||
@ -132,11 +137,6 @@ main(argc, argv)
|
||||
wbkgd(win, COLOR_PAIR(1));
|
||||
wattrset(win, COLOR_PAIR(1));
|
||||
}
|
||||
if (win == NULL) {
|
||||
(void)fprintf(stderr,
|
||||
"sysinst: screen too small\n");
|
||||
exit(1);
|
||||
}
|
||||
if (msg_window(win) != 0) {
|
||||
(void)fprintf(stderr,
|
||||
"sysinst: couldn't initialize message window\n");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: menus.mi,v 1.1 2003/05/16 19:15:00 dsl Exp $ */
|
||||
/* $NetBSD: menus.mi,v 1.2 2003/06/04 20:05:12 dsl Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
@ -55,6 +55,7 @@
|
||||
#define USER_MENU_INIT sysinst_menu_init()
|
||||
#define LAST_MSG ((msg)8192)
|
||||
static struct menudesc menu_def[];
|
||||
static menudesc *menus;
|
||||
|
||||
static int
|
||||
sysinst_menu_init(void)
|
||||
@ -71,6 +72,12 @@ sysinst_menu_init(void)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
set_menu_numopts(int menu, int numopts)
|
||||
{
|
||||
menus[menu].numopts = numopts;
|
||||
}
|
||||
}
|
||||
|
||||
default y=12, no exit, scrollable;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: menus.mi.en,v 1.67 2003/06/03 11:54:49 dsl Exp $ */
|
||||
/* $NetBSD: menus.mi.en,v 1.68 2003/06/04 20:05:12 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -170,18 +170,18 @@ menu edfspart, title "Change what?", exit, y=14;
|
||||
{ if (PI_ISBSDFS(&bsdlabel[editpart]) ||
|
||||
bsdlabel[editpart].pi_fstype == FS_MSDOS) {
|
||||
msg_prompt_add (MSG_mountpoint,
|
||||
fsmount[editpart],
|
||||
fsmount[editpart], 20);
|
||||
if (strcmp(fsmount[editpart], "none") == 0)
|
||||
fsmount[editpart][0] = '\0';
|
||||
bsdlabel[editpart].pi_mount,
|
||||
bsdlabel[editpart].pi_mount,
|
||||
sizeof bsdlabel[editpart].pi_mount);
|
||||
if (strcmp(bsdlabel[editpart].pi_mount, "none") == 0)
|
||||
bsdlabel[editpart].pi_mount[0] = '\0';
|
||||
} else {
|
||||
msg_display (MSG_nomount, 'a'+editpart);
|
||||
process_menu (MENU_ok, NULL);
|
||||
}
|
||||
};
|
||||
option "Preserve", action
|
||||
{ preservemount[editpart] = 1 - preservemount[editpart];
|
||||
};
|
||||
{ bsdlabel[editpart].pi_newfs ^= 1; };
|
||||
|
||||
menu selfskind, title "Select the type", y=15;
|
||||
option "4.2BSD", exit, action
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: menus.mi.fr,v 1.46 2003/06/03 11:54:49 dsl Exp $ */
|
||||
/* $NetBSD: menus.mi.fr,v 1.47 2003/06/04 20:05:13 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -161,18 +161,18 @@ menu edfspart, title "Changer quoi?", exit, y=14;
|
||||
{ if (PI_ISBSDFS(&bsdlabel[editpart]) ||
|
||||
bsdlabel[editpart].pi_fstype == FS_MSDOS) {
|
||||
msg_prompt_add (MSG_mountpoint,
|
||||
fsmount[editpart],
|
||||
fsmount[editpart], 20);
|
||||
if (strcmp(fsmount[editpart], "none") == 0)
|
||||
fsmount[editpart][0] = '\0';
|
||||
bsdlabel[editpart].pi_mount,
|
||||
bsdlabel[editpart].pi_mount,
|
||||
sizeof bsdlabel[editpart].pi_mount);
|
||||
if (strcmp(bsdlabel[editpart].pi_mount, "none") == 0)
|
||||
bsdlabel[editpart].pi_mount[0] = '\0';
|
||||
} else {
|
||||
msg_display (MSG_nomount, 'a'+editpart);
|
||||
process_menu (MENU_ok, NULL);
|
||||
}
|
||||
};
|
||||
option "Preserve", action /* XXX translate me */
|
||||
{ preservemount[editpart] = 1 - preservemount[editpart];
|
||||
};
|
||||
{ bsdlabel[editpart].pi_newfs ^= 1; };
|
||||
|
||||
menu selfskind, title "Selection du type de système de fichier", y=15;
|
||||
option "4.2BSD", exit, action
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: menus.mi.pl,v 1.16 2003/06/03 11:54:49 dsl Exp $ */
|
||||
/* $NetBSD: menus.mi.pl,v 1.17 2003/06/04 20:05:13 dsl Exp $ */
|
||||
/* Based on english version: */
|
||||
/* NetBSD: menus.mi.en,v 1.49 2002/04/04 14:26:44 ad Exp */
|
||||
|
||||
@ -172,18 +172,18 @@ menu edfspart, title "Co zmienic?", exit, y=14;
|
||||
{ if (PI_ISBSDFS(&bsdlabel[editpart]) ||
|
||||
bsdlabel[editpart].pi_fstype == FS_MSDOS) {
|
||||
msg_prompt_add (MSG_mountpoint,
|
||||
fsmount[editpart],
|
||||
fsmount[editpart], 20);
|
||||
if (strcmp(fsmount[editpart], "none") == 0)
|
||||
fsmount[editpart][0] = '\0';
|
||||
bsdlabel[editpart].pi_mount,
|
||||
bsdlabel[editpart].pi_mount,
|
||||
sizeof bsdlabel[editpart].pi_mount);
|
||||
if (strcmp(bsdlabel[editpart].pi_mount, "none") == 0)
|
||||
bsdlabel[editpart].pi_mount[0] = '\0';
|
||||
} else {
|
||||
msg_display (MSG_nomount, 'a'+editpart);
|
||||
process_menu (MENU_ok, NULL);
|
||||
}
|
||||
};
|
||||
option "Ochrona", action
|
||||
{ preservemount[editpart] = 1 - preservemount[editpart];
|
||||
};
|
||||
{ bsdlabel[editpart].pi_newfs ^= 1; };
|
||||
|
||||
menu selfskind, title "Wybierz rodzaj", y=15;
|
||||
option "4.2BSD", exit, action
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: msg.mi.en,v 1.97 2003/05/21 10:05:21 dsl Exp $ */
|
||||
/* $NetBSD: msg.mi.en,v 1.98 2003/06/04 20:05:13 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -210,6 +210,38 @@ message defaultunit
|
||||
at the end of input, sizes and offsets are in %s.
|
||||
}
|
||||
|
||||
message ptnsizes
|
||||
{You can now change the sizes for the system partitions. The default is
|
||||
to allocate all the space to the root filesystem, however you may wish
|
||||
to have separate /usr (additional system files), /var (log files etc)
|
||||
or /home (users' home directories).
|
||||
|
||||
Free space will be added to the partition marked with a '+'.
|
||||
}
|
||||
|
||||
message ptnheaders
|
||||
{
|
||||
MB Cylinders Sectors Filesystem
|
||||
}
|
||||
|
||||
message askfsmount
|
||||
{Mount pount?}
|
||||
|
||||
message askfssize
|
||||
{Size for %s in %s?}
|
||||
|
||||
message askunits
|
||||
{Change input units (sectors/cylinders/MB)}
|
||||
|
||||
message add_another_ptn
|
||||
{Add a user defined partition}
|
||||
|
||||
message fssizesok
|
||||
{Accept partition sizes. Free space %d %s, %d free partitions.}
|
||||
|
||||
message fssizesbad
|
||||
{Reduce partition sizes by %d %s (%d sectors).}
|
||||
|
||||
.if 0
|
||||
message askfsroot
|
||||
{I will be asking for partition sizes and on some, mount points.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sizemultname.c,v 1.1 2003/01/11 19:44:05 christos Exp $ */
|
||||
/* $NetBSD: sizemultname.c,v 1.2 2003/06/04 20:05:13 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -62,7 +62,7 @@ check_partitions()
|
||||
|
||||
for (i = 0; i < getmaxpartitions(); i++)
|
||||
if (PI_ISBSDFS(&bsdlabel[i]) &&
|
||||
fsmount[i][0] == '/' && fsmount[i][1] == '\0')
|
||||
strcmp(bsdlabel[i].pi_mount, "/") == 0)
|
||||
return 1;
|
||||
msg_display(MSG_no_root_fs);
|
||||
getchar();
|
||||
|
Loading…
Reference in New Issue
Block a user