Handle the 'custom' case in a sane fashion (do not create zero length
partitions under any circumstances, allow no swap, do not *overwrite* /usr when listing additional partitions, and try to abstract at least most of the magic numbers to #defines at the top. Also sync up as much as possible to make this easier in future. Still need to attack the other arch's md.c files.
This commit is contained in:
parent
0536609b97
commit
1e7a66ebab
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.34 1999/08/07 15:56:31 simonb Exp $ */
|
||||
/* $NetBSD: md.c,v 1.35 1999/08/10 15:54:55 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -37,6 +37,7 @@
|
||||
*/
|
||||
|
||||
/* md.c -- pmax machine specific routines */
|
||||
/* This file is in close sync with sparc, vax, and x68k md.c */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
@ -63,13 +64,19 @@ void get_labelname(void)
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Symbolic names for disk partitions.
|
||||
*/
|
||||
#define PART_ROOT A
|
||||
#define PART_SWAP B
|
||||
#define PART_RAW C
|
||||
#define PART_USR D
|
||||
#define PART_USR D /* Can be after PART_FIRST_FREE */
|
||||
#define PART_FIRST_FREE E
|
||||
#define PART_LAST H
|
||||
|
||||
#define DEFSWAPRAM 32 /* Assume at least this RAM for swap calc */
|
||||
#define DEFROOTSIZE 32 /* Default root size */
|
||||
#define STDNEEDMB 140 /* Min space for non X install */
|
||||
|
||||
int
|
||||
md_get_info(void)
|
||||
@ -82,11 +89,16 @@ md_get_info (void)
|
||||
|
||||
fd = open(devname, O_RDONLY, 0);
|
||||
if (fd < 0) {
|
||||
if (logging)
|
||||
(void)fprintf(log, "Can't open %s\n", devname);
|
||||
endwin();
|
||||
fprintf(stderr, "Can't open %s\n", devname);
|
||||
exit(1);
|
||||
}
|
||||
if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
|
||||
if (logging)
|
||||
(void)fprintf(log, "Can't read disklabel on %s.\n",
|
||||
devname);
|
||||
endwin();
|
||||
fprintf(stderr, "Can't read disklabel on %s.\n", devname);
|
||||
close(fd);
|
||||
@ -111,25 +123,25 @@ md_get_info (void)
|
||||
dlsize = disklabel.d_secperunit;
|
||||
|
||||
/* Compute minimum NetBSD partition sizes (in sectors). */
|
||||
minfsdmb = (80 + 4*rammb) * (MEG / sectorsize);
|
||||
minfsdmb = STDNEEDMB * (MEG / sectorsize);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* hook called before editing new disklabel.
|
||||
* hook called before writing new disklabel.
|
||||
*/
|
||||
int md_pre_disklabel (void)
|
||||
int
|
||||
md_pre_disklabel(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* hook called after writing disklabel to new target disk.
|
||||
*/
|
||||
int md_post_disklabel (void)
|
||||
int
|
||||
md_post_disklabel(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -143,7 +155,8 @@ int md_post_disklabel (void)
|
||||
*
|
||||
* On pmax, we take this opportuinty to update the bootblocks.
|
||||
*/
|
||||
int md_post_newfs (void)
|
||||
int
|
||||
md_post_newfs(void)
|
||||
{
|
||||
/* XXX boot blocks ... */
|
||||
if (target_already_root()) {
|
||||
@ -157,15 +170,23 @@ int md_post_newfs (void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* some ports use this to copy the MD filesystem, we do not.
|
||||
*/
|
||||
int
|
||||
md_copy_filesystem(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* md back-end code for menu-driven BSD disklabel editor.
|
||||
*/
|
||||
int md_make_bsd_partitions (void)
|
||||
int
|
||||
md_make_bsd_partitions(void)
|
||||
{
|
||||
FILE *f;
|
||||
int i;
|
||||
int part; /* next available partition */
|
||||
int i, part;
|
||||
int remain;
|
||||
char isize[20];
|
||||
int maxpart = getmaxpartitions();
|
||||
@ -175,9 +196,9 @@ int md_make_bsd_partitions (void)
|
||||
* Standard 4.3BSD 8-partition labels always cover whole disk.
|
||||
*/
|
||||
ptstart = 0;
|
||||
ptsize = dlsize;
|
||||
ptsize = dlsize - ptstart;
|
||||
fsdsize = dlsize; /* actually means `whole disk' */
|
||||
fsptsize = dlsize; /* netbsd partition -- same as above */
|
||||
fsptsize = dlsize - ptstart; /* netbsd partition -- same as above */
|
||||
fsdmb = fsdsize / MEG;
|
||||
|
||||
/* Ask for layout type -- standard or special */
|
||||
@ -205,14 +226,14 @@ int md_make_bsd_partitions (void)
|
||||
|
||||
/* Standard fstypes */
|
||||
bsdlabel[A].pi_fstype = FS_BSDFFS;
|
||||
bsdlabel[B].pi_fstype = FS_SWAP;
|
||||
bsdlabel[B].pi_fstype = FS_UNUSED;
|
||||
/* Conventionally, C is whole disk. */
|
||||
bsdlabel[D].pi_fstype = FS_UNUSED; /* fill out below */
|
||||
bsdlabel[E].pi_fstype = FS_UNUSED;
|
||||
bsdlabel[F].pi_fstype = FS_UNUSED;
|
||||
bsdlabel[G].pi_fstype = FS_UNUSED;
|
||||
bsdlabel[H].pi_fstype = FS_UNUSED;
|
||||
part = D;
|
||||
|
||||
|
||||
switch (layoutkind) {
|
||||
case 1: /* standard: a root, b swap, c "unused", d /usr */
|
||||
@ -220,22 +241,23 @@ int md_make_bsd_partitions (void)
|
||||
partstart = ptstart;
|
||||
|
||||
/* Root */
|
||||
/* By convention, NetBSD/pmax uses a 32Mbyte root */
|
||||
partsize= NUMSEC(32, MEG/sectorsize, dlcylsize);
|
||||
bsdlabel[A].pi_offset = partstart;
|
||||
bsdlabel[A].pi_size = partsize;
|
||||
bsdlabel[A].pi_bsize = 8192;
|
||||
bsdlabel[A].pi_fsize = 1024;
|
||||
strcpy (fsmount[A], "/");
|
||||
partsize = NUMSEC(DEFROOTSIZE, MEG/sectorsize, dlcylsize);
|
||||
bsdlabel[PART_ROOT].pi_offset = partstart;
|
||||
bsdlabel[PART_ROOT].pi_size = partsize;
|
||||
bsdlabel[PART_ROOT].pi_bsize = 8192;
|
||||
bsdlabel[PART_ROOT].pi_fsize = 1024;
|
||||
strcpy(fsmount[PART_ROOT], "/");
|
||||
partstart += partsize;
|
||||
|
||||
/* swap */
|
||||
i = NUMSEC(layoutkind * 2 * (rammb < 32 ? 32 : rammb),
|
||||
i = NUMSEC(layoutkind * 2 *
|
||||
(rammb < DEFSWAPRAM ? DEFSWAPRAM : rammb),
|
||||
MEG/sectorsize, dlcylsize) + partstart;
|
||||
partsize = NUMSEC(i/(MEG/sectorsize)+1, MEG/sectorsize,
|
||||
dlcylsize) - partstart;
|
||||
bsdlabel[B].pi_offset = partstart;
|
||||
bsdlabel[B].pi_size = partsize;
|
||||
bsdlabel[PART_SWAP].pi_fstype = FS_SWAP;
|
||||
bsdlabel[PART_SWAP].pi_offset = partstart;
|
||||
bsdlabel[PART_SWAP].pi_size = partsize;
|
||||
partstart += partsize;
|
||||
|
||||
/* /usr */
|
||||
@ -247,7 +269,6 @@ int md_make_bsd_partitions (void)
|
||||
bsdlabel[PART_USR].pi_fsize = 1024;
|
||||
strcpy(fsmount[PART_USR], "/usr");
|
||||
|
||||
part = E;
|
||||
break;
|
||||
|
||||
case 3: /* custom: ask user for all sizes */
|
||||
@ -255,41 +276,56 @@ int md_make_bsd_partitions (void)
|
||||
/* root */
|
||||
partstart = ptstart;
|
||||
remain = fsdsize - partstart;
|
||||
/* By convention, NetBSD/pmax uses a 32Mbyte root */
|
||||
partsize= NUMSEC(32, MEG/sectorsize, dlcylsize);
|
||||
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);
|
||||
bsdlabel[A].pi_offset = partstart;
|
||||
bsdlabel[A].pi_size = partsize;
|
||||
bsdlabel[A].pi_bsize = 8192;
|
||||
bsdlabel[A].pi_fsize = 1024;
|
||||
strcpy (fsmount[A], "/");
|
||||
/* If less than a 'unit' left, also use it */
|
||||
if (remain - partsize < sizemult)
|
||||
partsize = remain;
|
||||
bsdlabel[PART_ROOT].pi_offset = partstart;
|
||||
bsdlabel[PART_ROOT].pi_size = partsize;
|
||||
bsdlabel[PART_ROOT].pi_bsize = 8192;
|
||||
bsdlabel[PART_ROOT].pi_fsize = 1024;
|
||||
strcpy(fsmount[PART_ROOT], "/");
|
||||
partstart += partsize;
|
||||
|
||||
/* swap */
|
||||
remain = fsdsize - partstart;
|
||||
i = NUMSEC(layoutkind * 2 * (rammb < 32 ? 32 : rammb),
|
||||
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);
|
||||
bsdlabel[B].pi_offset = partstart;
|
||||
bsdlabel[B].pi_size = partsize;
|
||||
if (partsize) {
|
||||
/* If less than a 'unit' left, also use it */
|
||||
if (remain - partsize < sizemult)
|
||||
partsize = remain;
|
||||
bsdlabel[PART_SWAP].pi_fstype = FS_SWAP;
|
||||
bsdlabel[PART_SWAP].pi_offset = partstart;
|
||||
bsdlabel[PART_SWAP].pi_size = partsize;
|
||||
partstart += partsize;
|
||||
}
|
||||
}
|
||||
|
||||
/* /usr */
|
||||
remain = fsdsize - partstart;
|
||||
if (remain > 0) {
|
||||
partsize = fsdsize - partstart;
|
||||
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;
|
||||
bsdlabel[PART_USR].pi_fstype = FS_BSDFFS;
|
||||
@ -300,19 +336,23 @@ int md_make_bsd_partitions (void)
|
||||
strcpy(fsmount[PART_USR], "/usr");
|
||||
partstart += partsize;
|
||||
}
|
||||
}
|
||||
|
||||
/* Others ... */
|
||||
remain = fsdsize - partstart;
|
||||
part = F;
|
||||
if (remain > 0)
|
||||
msg_display(MSG_otherparts);
|
||||
while (remain > 0 && part <= H) {
|
||||
part = PART_FIRST_FREE;
|
||||
for (; remain > 0 && part <= PART_LAST; ++part ) {
|
||||
if (bsdlabel[part].pi_fstype != FS_UNUSED)
|
||||
continue;
|
||||
partsize = fsdsize - partstart;
|
||||
snprintf(isize, 20, "%d", partsize/sizemult);
|
||||
msg_prompt_add(MSG_askfspart, isize, isize, 20,
|
||||
diskdev, partname[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;
|
||||
bsdlabel[part].pi_fstype = FS_BSDFFS;
|
||||
@ -320,14 +360,12 @@ int md_make_bsd_partitions (void)
|
||||
bsdlabel[part].pi_size = partsize;
|
||||
bsdlabel[part].pi_bsize = 8192;
|
||||
bsdlabel[part].pi_fsize = 1024;
|
||||
msg_prompt_add (MSG_mountpoint, NULL,
|
||||
fsmount[part], 20);
|
||||
msg_prompt_add(MSG_mountpoint, NULL, fsmount[part],
|
||||
20);
|
||||
partstart += partsize;
|
||||
remain = fsdsize - partstart;
|
||||
part++;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -380,14 +418,6 @@ int md_make_bsd_partitions (void)
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
int md_copy_filesystem (void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Upgrade support */
|
||||
int
|
||||
md_update(void)
|
||||
@ -404,4 +434,24 @@ md_update(void)
|
||||
void
|
||||
md_cleanup_install(void)
|
||||
{
|
||||
char realfrom[STRSIZE];
|
||||
char realto[STRSIZE];
|
||||
char sedcmd[STRSIZE];
|
||||
|
||||
strncpy(realfrom, target_expand("/etc/rc.conf"), STRSIZE);
|
||||
strncpy(realto, target_expand("/etc/rc.conf.install"), STRSIZE);
|
||||
|
||||
sprintf(sedcmd, "sed 's/rc_configured=NO/rc_configured=YES/' < %s > %s",
|
||||
realfrom, realto);
|
||||
if (logging)
|
||||
(void)fprintf(log, "%s\n", sedcmd);
|
||||
if (scripting)
|
||||
(void)fprintf(script, "%s\n", sedcmd);
|
||||
do_system(sedcmd);
|
||||
|
||||
run_prog(1, 0, NULL, "mv -f %s %s", realto, realfrom);
|
||||
|
||||
run_prog(0, 0, NULL, "rm -f %s", target_expand("/sysinst"));
|
||||
run_prog(0, 0, NULL, "rm -f %s", target_expand("/.termcap"));
|
||||
run_prog(0, 0, NULL, "rm -f %s", target_expand("/.profile"));
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.16 1999/07/14 16:47:37 abs Exp $ */
|
||||
/* $NetBSD: md.c,v 1.17 1999/08/10 15:54:55 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -39,6 +39,7 @@
|
||||
/* changes from the i386 version made by mrg */
|
||||
|
||||
/* md.c -- sparc machine specific routines */
|
||||
/* This file is in close sync with pmax, vax, and x68k md.c */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/disklabel.h>
|
||||
@ -59,11 +60,18 @@
|
||||
* Symbolic names for disk partitions.
|
||||
*/
|
||||
#define PART_ROOT A
|
||||
#define PART_SWAP B
|
||||
#define PART_RAW C
|
||||
#define PART_USR G
|
||||
#define PART_USR G /* Can be after PART_FIRST_FREE */
|
||||
#define PART_FIRST_FREE D
|
||||
#define PART_LAST H
|
||||
|
||||
#define DEFSWAPRAM 32 /* Assume at least this RAM for swap calc */
|
||||
#define DEFROOTSIZE 32 /* Default root size */
|
||||
#define STDNEEDMB 110 /* Min space for non X install */
|
||||
|
||||
int
|
||||
md_get_info()
|
||||
md_get_info(void)
|
||||
{
|
||||
struct disklabel disklabel;
|
||||
int fd;
|
||||
@ -73,11 +81,16 @@ md_get_info()
|
||||
|
||||
fd = open(devname, O_RDONLY, 0);
|
||||
if (fd < 0) {
|
||||
if (logging)
|
||||
(void)fprintf(log, "Can't open %s\n", devname);
|
||||
endwin();
|
||||
fprintf(stderr, "Can't open %s\n", devname);
|
||||
exit(1);
|
||||
}
|
||||
if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
|
||||
if (logging)
|
||||
(void)fprintf(log, "Can't read disklabel on %s.\n",
|
||||
devname);
|
||||
endwin();
|
||||
fprintf(stderr, "Can't read disklabel on %s.\n", devname);
|
||||
close(fd);
|
||||
@ -102,7 +115,7 @@ md_get_info()
|
||||
dlsize = disklabel.d_secperunit;
|
||||
|
||||
/* Compute minimum NetBSD partition sizes (in sectors). */
|
||||
minfsdmb = (80 + 4*rammb) * (MEG / sectorsize);
|
||||
minfsdmb = STDNEEDMB * (MEG / sectorsize);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -111,7 +124,7 @@ md_get_info()
|
||||
* hook called before writing new disklabel.
|
||||
*/
|
||||
int
|
||||
md_pre_disklabel()
|
||||
md_pre_disklabel(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -119,7 +132,8 @@ md_pre_disklabel()
|
||||
/*
|
||||
* hook called after writing disklabel to new target disk.
|
||||
*/
|
||||
int md_post_disklabel (void)
|
||||
int
|
||||
md_post_disklabel(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -127,14 +141,14 @@ int md_post_disklabel (void)
|
||||
/*
|
||||
* MD hook called after upgrade() or install() has finished setting
|
||||
* up the target disk but immediately before the user is given the
|
||||
* ``disks are now set up'' message that, if power fails, they can
|
||||
* ``disks are now set up'' message, so that if power fails, they can
|
||||
* continue installation by booting the target disk and doing an
|
||||
* `upgrade'.
|
||||
*
|
||||
* On the sparc, we use this opportunity to install the boot blocks.
|
||||
*/
|
||||
int
|
||||
md_post_newfs()
|
||||
md_post_newfs(void)
|
||||
{
|
||||
/*
|
||||
* Create a symlink of netbsd to netbsd.GENERIC
|
||||
@ -154,13 +168,16 @@ md_post_newfs()
|
||||
* some ports use this to copy the MD filesystem, we do not.
|
||||
*/
|
||||
int
|
||||
md_copy_filesystem()
|
||||
md_copy_filesystem(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* md back-end code for menu-driven BSD disklabel editor.
|
||||
*/
|
||||
int
|
||||
md_make_bsd_partitions()
|
||||
md_make_bsd_partitions(void)
|
||||
{
|
||||
int i, part;
|
||||
int remain;
|
||||
@ -201,14 +218,13 @@ md_make_bsd_partitions()
|
||||
|
||||
/* Standard fstypes */
|
||||
bsdlabel[A].pi_fstype = FS_BSDFFS;
|
||||
bsdlabel[B].pi_fstype = FS_SWAP;
|
||||
bsdlabel[B].pi_fstype = FS_UNUSED;
|
||||
/* Conventionally, C is whole disk. */
|
||||
bsdlabel[D].pi_fstype = FS_UNUSED; /* fill out below */
|
||||
bsdlabel[E].pi_fstype = FS_UNUSED;
|
||||
bsdlabel[F].pi_fstype = FS_UNUSED;
|
||||
bsdlabel[G].pi_fstype = FS_UNUSED;
|
||||
bsdlabel[H].pi_fstype = FS_UNUSED;
|
||||
part = D;
|
||||
|
||||
|
||||
switch (layoutkind) {
|
||||
@ -217,22 +233,23 @@ md_make_bsd_partitions()
|
||||
partstart = ptstart;
|
||||
|
||||
/* Root */
|
||||
/* By convention, NetBSD/sparc uses a 328Mbyte root */
|
||||
partsize= NUMSEC(32, MEG/sectorsize, dlcylsize);
|
||||
bsdlabel[A].pi_offset = partstart;
|
||||
bsdlabel[A].pi_size = partsize;
|
||||
bsdlabel[A].pi_bsize = 8192;
|
||||
bsdlabel[A].pi_fsize = 1024;
|
||||
strcpy (fsmount[A], "/");
|
||||
partsize = NUMSEC(DEFROOTSIZE, MEG/sectorsize, dlcylsize);
|
||||
bsdlabel[PART_ROOT].pi_offset = partstart;
|
||||
bsdlabel[PART_ROOT].pi_size = partsize;
|
||||
bsdlabel[PART_ROOT].pi_bsize = 8192;
|
||||
bsdlabel[PART_ROOT].pi_fsize = 1024;
|
||||
strcpy(fsmount[PART_ROOT], "/");
|
||||
partstart += partsize;
|
||||
|
||||
/* swap */
|
||||
i = NUMSEC(layoutkind * 2 * (rammb < 32 ? 32 : rammb),
|
||||
i = NUMSEC(layoutkind * 2 *
|
||||
(rammb < DEFSWAPRAM ? DEFSWAPRAM : rammb),
|
||||
MEG/sectorsize, dlcylsize) + partstart;
|
||||
partsize = NUMSEC(i/(MEG/sectorsize)+1, MEG/sectorsize,
|
||||
dlcylsize) - partstart;
|
||||
bsdlabel[B].pi_offset = partstart;
|
||||
bsdlabel[B].pi_size = partsize;
|
||||
bsdlabel[PART_SWAP].pi_fstype = FS_SWAP;
|
||||
bsdlabel[PART_SWAP].pi_offset = partstart;
|
||||
bsdlabel[PART_SWAP].pi_size = partsize;
|
||||
partstart += partsize;
|
||||
|
||||
/* /usr */
|
||||
@ -251,22 +268,26 @@ md_make_bsd_partitions()
|
||||
/* root */
|
||||
partstart = ptstart;
|
||||
remain = fsdsize - partstart;
|
||||
/* By convention, NetBSD/sparc uses a 32Mbyte root */
|
||||
partsize = NUMSEC (32, MEG/sectorsize, dlcylsize);
|
||||
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);
|
||||
bsdlabel[A].pi_offset = partstart;
|
||||
bsdlabel[A].pi_size = partsize;
|
||||
bsdlabel[A].pi_bsize = 8192;
|
||||
bsdlabel[A].pi_fsize = 1024;
|
||||
strcpy (fsmount[A], "/");
|
||||
/* If less than a 'unit' left, also use it */
|
||||
if (remain - partsize < sizemult)
|
||||
partsize = remain;
|
||||
bsdlabel[PART_ROOT].pi_offset = partstart;
|
||||
bsdlabel[PART_ROOT].pi_size = partsize;
|
||||
bsdlabel[PART_ROOT].pi_bsize = 8192;
|
||||
bsdlabel[PART_ROOT].pi_fsize = 1024;
|
||||
strcpy(fsmount[PART_ROOT], "/");
|
||||
partstart += partsize;
|
||||
|
||||
/* swap */
|
||||
remain = fsdsize - partstart;
|
||||
i = NUMSEC(2 * (rammb < 32 ? 32 : rammb),
|
||||
if (remain > 0) {
|
||||
i = NUMSEC(2 *
|
||||
(rammb < DEFSWAPRAM ? DEFSWAPRAM : rammb),
|
||||
MEG/sectorsize, dlcylsize) + partstart;
|
||||
partsize = NUMSEC(i/(MEG/sectorsize)+1, MEG/sectorsize,
|
||||
dlcylsize) - partstart;
|
||||
@ -276,18 +297,27 @@ md_make_bsd_partitions()
|
||||
msg_prompt_add(MSG_askfsswap, isize, isize, 20,
|
||||
remain/sizemult, multname);
|
||||
partsize = NUMSEC(atoi(isize),sizemult, dlcylsize);
|
||||
bsdlabel[B].pi_offset = partstart;
|
||||
bsdlabel[B].pi_size = partsize;
|
||||
if (partsize) {
|
||||
/* If less than a 'unit' left, also use it */
|
||||
if (remain - partsize < sizemult)
|
||||
partsize = remain;
|
||||
bsdlabel[PART_SWAP].pi_fstype = FS_SWAP;
|
||||
bsdlabel[PART_SWAP].pi_offset = partstart;
|
||||
bsdlabel[PART_SWAP].pi_size = partsize;
|
||||
partstart += partsize;
|
||||
}
|
||||
}
|
||||
|
||||
/* /usr */
|
||||
remain = fsdsize - partstart;
|
||||
if (remain >= dlcylsize) {
|
||||
partsize = fsdsize - 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;
|
||||
bsdlabel[PART_USR].pi_fstype = FS_BSDFFS;
|
||||
@ -298,19 +328,23 @@ md_make_bsd_partitions()
|
||||
strcpy(fsmount[PART_USR], "/usr");
|
||||
partstart += partsize;
|
||||
}
|
||||
}
|
||||
|
||||
/* Others ... */
|
||||
remain = fsdsize - partstart;
|
||||
part = F;
|
||||
if (remain > 0)
|
||||
msg_display(MSG_otherparts);
|
||||
while (remain > 0 && part <= H) {
|
||||
part = PART_FIRST_FREE;
|
||||
for (; remain > 0 && part <= PART_LAST; ++part ) {
|
||||
if (bsdlabel[part].pi_fstype != FS_UNUSED)
|
||||
continue;
|
||||
partsize = fsdsize - partstart;
|
||||
snprintf(isize, 20, "%d", partsize/sizemult);
|
||||
msg_prompt_add(MSG_askfspart, isize, isize, 20,
|
||||
diskdev, partname[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;
|
||||
bsdlabel[part].pi_fstype = FS_BSDFFS;
|
||||
@ -318,17 +352,15 @@ md_make_bsd_partitions()
|
||||
bsdlabel[part].pi_size = partsize;
|
||||
bsdlabel[part].pi_bsize = 8192;
|
||||
bsdlabel[part].pi_fsize = 1024;
|
||||
msg_prompt_add (MSG_mountpoint, NULL,
|
||||
fsmount[part], 20);
|
||||
msg_prompt_add(MSG_mountpoint, NULL, fsmount[part],
|
||||
20);
|
||||
partstart += partsize;
|
||||
remain = fsdsize - partstart;
|
||||
part++;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* OK, we have a partition table. Give the user the chance to
|
||||
* edit it and verify it's OK, or abort altogether.
|
||||
@ -344,16 +376,14 @@ md_make_bsd_partitions()
|
||||
/* save label to disk for MI code to update. */
|
||||
(void) savenewlabel(bsdlabel, 8); /* 8 partitions in label */
|
||||
|
||||
|
||||
/* Everything looks OK. */
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Upgrade support */
|
||||
int
|
||||
md_update()
|
||||
md_update(void)
|
||||
{
|
||||
|
||||
endwin();
|
||||
md_copy_filesystem();
|
||||
md_post_newfs();
|
||||
@ -372,6 +402,7 @@ md_cleanup_install(void)
|
||||
|
||||
strncpy(realfrom, target_expand("/etc/rc.conf"), STRSIZE);
|
||||
strncpy(realto, target_expand("/etc/rc.conf.install"), STRSIZE);
|
||||
|
||||
sprintf(sedcmd, "sed 's/rc_configured=NO/rc_configured=YES/' < %s > %s",
|
||||
realfrom, realto);
|
||||
if (logging)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.8 1999/06/22 00:57:10 cgd Exp $ */
|
||||
/* $NetBSD: md.c,v 1.9 1999/08/10 15:54:56 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -39,6 +39,7 @@
|
||||
/* changes from the i386 version made by mrg */
|
||||
|
||||
/* md.c -- vax machine specific routines */
|
||||
/* This file is in close sync with pmax, sparc, and x68k md.c */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/disklabel.h>
|
||||
@ -59,11 +60,18 @@
|
||||
* Symbolic names for disk partitions.
|
||||
*/
|
||||
#define PART_ROOT A
|
||||
#define PART_SWAP B
|
||||
#define PART_RAW C
|
||||
#define PART_USR G
|
||||
#define PART_USR D /* Can be after PART_FIRST_FREE */
|
||||
#define PART_FIRST_FREE E
|
||||
#define PART_LAST H
|
||||
|
||||
#define DEFSWAPRAM 16 /* Assume at least this RAM for swap calc */
|
||||
#define DEFROOTSIZE 32 /* Default root size */
|
||||
#define STDNEEDMB 80 /* Min space for non X install */
|
||||
|
||||
int
|
||||
md_get_info()
|
||||
md_get_info(void)
|
||||
{
|
||||
struct disklabel disklabel;
|
||||
int fd;
|
||||
@ -107,7 +115,7 @@ md_get_info()
|
||||
dlsize = disklabel.d_secperunit;
|
||||
|
||||
/* Compute minimum NetBSD partition sizes (in sectors). */
|
||||
minfsdmb = (80 + 4*rammb) * (MEG / sectorsize);
|
||||
minfsdmb = STDNEEDMB * (MEG / sectorsize);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -116,15 +124,16 @@ md_get_info()
|
||||
* hook called before writing new disklabel.
|
||||
*/
|
||||
int
|
||||
md_pre_disklabel()
|
||||
md_pre_disklabel(void)
|
||||
{
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* hook called after writing disklabel to new target disk.
|
||||
*/
|
||||
int md_post_disklabel (void)
|
||||
int
|
||||
md_post_disklabel(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -132,14 +141,14 @@ int md_post_disklabel (void)
|
||||
/*
|
||||
* MD hook called after upgrade() or install() has finished setting
|
||||
* up the target disk but immediately before the user is given the
|
||||
* ``disks are now set up'' message that, if power fails, they can
|
||||
* ``disks are now set up'' message, so that if power fails, they can
|
||||
* continue installation by booting the target disk and doing an
|
||||
* `upgrade'.
|
||||
*
|
||||
* On the vax, we use this opportunity to install the boot blocks.
|
||||
*/
|
||||
int
|
||||
md_post_newfs()
|
||||
md_post_newfs(void)
|
||||
{
|
||||
|
||||
printf(msg_string(MSG_dobootblks), diskdev);
|
||||
@ -151,13 +160,16 @@ md_post_newfs()
|
||||
* some ports use this to copy the MD filesystem, we do not.
|
||||
*/
|
||||
int
|
||||
md_copy_filesystem()
|
||||
md_copy_filesystem(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* md back-end code for menu-driven BSD disklabel editor.
|
||||
*/
|
||||
int
|
||||
md_make_bsd_partitions()
|
||||
md_make_bsd_partitions(void)
|
||||
{
|
||||
int i, part;
|
||||
int remain;
|
||||
@ -198,14 +210,13 @@ md_make_bsd_partitions()
|
||||
|
||||
/* Standard fstypes */
|
||||
bsdlabel[A].pi_fstype = FS_BSDFFS;
|
||||
bsdlabel[B].pi_fstype = FS_SWAP;
|
||||
bsdlabel[B].pi_fstype = FS_UNUSED;
|
||||
/* Conventionally, C is whole disk. */
|
||||
bsdlabel[D].pi_fstype = FS_UNUSED; /* fill out below */
|
||||
bsdlabel[E].pi_fstype = FS_UNUSED;
|
||||
bsdlabel[F].pi_fstype = FS_UNUSED;
|
||||
bsdlabel[G].pi_fstype = FS_UNUSED;
|
||||
bsdlabel[H].pi_fstype = FS_UNUSED;
|
||||
part = D;
|
||||
|
||||
|
||||
switch (layoutkind) {
|
||||
@ -214,22 +225,23 @@ md_make_bsd_partitions()
|
||||
partstart = ptstart;
|
||||
|
||||
/* Root */
|
||||
/* NetBSD/vax uses a 16 Mbyte root */
|
||||
partsize= NUMSEC(16, MEG/sectorsize, dlcylsize);
|
||||
bsdlabel[A].pi_offset = partstart;
|
||||
bsdlabel[A].pi_size = partsize;
|
||||
bsdlabel[A].pi_bsize = 8192;
|
||||
bsdlabel[A].pi_fsize = 1024;
|
||||
strcpy (fsmount[A], "/");
|
||||
partsize = NUMSEC(DEFROOTSIZE, MEG/sectorsize, dlcylsize);
|
||||
bsdlabel[PART_ROOT].pi_offset = partstart;
|
||||
bsdlabel[PART_ROOT].pi_size = partsize;
|
||||
bsdlabel[PART_ROOT].pi_bsize = 8192;
|
||||
bsdlabel[PART_ROOT].pi_fsize = 1024;
|
||||
strcpy(fsmount[PART_ROOT], "/");
|
||||
partstart += partsize;
|
||||
|
||||
/* swap */
|
||||
i = NUMSEC(layoutkind * 2 * (rammb < 16 ? 16 : rammb),
|
||||
i = NUMSEC(layoutkind * 2 *
|
||||
(rammb < DEFSWAPRAM ? DEFSWAPRAM : rammb),
|
||||
MEG/sectorsize, dlcylsize) + partstart;
|
||||
partsize = NUMSEC(i/(MEG/sectorsize)+1, MEG/sectorsize,
|
||||
dlcylsize) - partstart;
|
||||
bsdlabel[B].pi_offset = partstart;
|
||||
bsdlabel[B].pi_size = partsize;
|
||||
bsdlabel[PART_SWAP].pi_fstype = FS_SWAP;
|
||||
bsdlabel[PART_SWAP].pi_offset = partstart;
|
||||
bsdlabel[PART_SWAP].pi_size = partsize;
|
||||
partstart += partsize;
|
||||
|
||||
/* /usr */
|
||||
@ -248,40 +260,56 @@ md_make_bsd_partitions()
|
||||
/* root */
|
||||
partstart = ptstart;
|
||||
remain = fsdsize - partstart;
|
||||
/* NetBSD/vax uses a 32Mbyte root */
|
||||
partsize = NUMSEC (32, MEG/sectorsize, dlcylsize);
|
||||
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);
|
||||
bsdlabel[A].pi_offset = partstart;
|
||||
bsdlabel[A].pi_size = partsize;
|
||||
bsdlabel[A].pi_bsize = 8192;
|
||||
bsdlabel[A].pi_fsize = 1024;
|
||||
strcpy (fsmount[A], "/");
|
||||
/* If less than a 'unit' left, also use it */
|
||||
if (remain - partsize < sizemult)
|
||||
partsize = remain;
|
||||
bsdlabel[PART_ROOT].pi_offset = partstart;
|
||||
bsdlabel[PART_ROOT].pi_size = partsize;
|
||||
bsdlabel[PART_ROOT].pi_bsize = 8192;
|
||||
bsdlabel[PART_ROOT].pi_fsize = 1024;
|
||||
strcpy(fsmount[PART_ROOT], "/");
|
||||
partstart += partsize;
|
||||
|
||||
/* swap */
|
||||
remain = fsdsize - partstart;
|
||||
i = NUMSEC(2 * (rammb < 32 ? 32 : rammb),
|
||||
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);
|
||||
bsdlabel[B].pi_offset = partstart;
|
||||
bsdlabel[B].pi_size = partsize;
|
||||
if (partsize) {
|
||||
/* If less than a 'unit' left, also use it */
|
||||
if (remain - partsize < sizemult)
|
||||
partsize = remain;
|
||||
bsdlabel[PART_SWAP].pi_fstype = FS_SWAP;
|
||||
bsdlabel[PART_SWAP].pi_offset = partstart;
|
||||
bsdlabel[PART_SWAP].pi_size = partsize;
|
||||
partstart += partsize;
|
||||
}
|
||||
}
|
||||
|
||||
/* /usr */
|
||||
remain = fsdsize - partstart;
|
||||
partsize = fsdsize - 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;
|
||||
bsdlabel[PART_USR].pi_fstype = FS_BSDFFS;
|
||||
@ -291,19 +319,24 @@ md_make_bsd_partitions()
|
||||
bsdlabel[PART_USR].pi_fsize = 1024;
|
||||
strcpy(fsmount[PART_USR], "/usr");
|
||||
partstart += partsize;
|
||||
}
|
||||
}
|
||||
|
||||
/* Others ... */
|
||||
remain = fsdsize - partstart;
|
||||
part = F;
|
||||
if (remain > 0)
|
||||
msg_display(MSG_otherparts);
|
||||
while (remain > 0 && part <= H) {
|
||||
part = PART_FIRST_FREE;
|
||||
for (; remain > 0 && part <= PART_LAST; ++part ) {
|
||||
if (bsdlabel[part].pi_fstype != FS_UNUSED)
|
||||
continue;
|
||||
partsize = fsdsize - partstart;
|
||||
snprintf(isize, 20, "%d", partsize/sizemult);
|
||||
msg_prompt_add(MSG_askfspart, isize, isize, 20,
|
||||
diskdev, partname[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;
|
||||
bsdlabel[part].pi_fstype = FS_BSDFFS;
|
||||
@ -311,17 +344,15 @@ md_make_bsd_partitions()
|
||||
bsdlabel[part].pi_size = partsize;
|
||||
bsdlabel[part].pi_bsize = 8192;
|
||||
bsdlabel[part].pi_fsize = 1024;
|
||||
msg_prompt_add (MSG_mountpoint, NULL,
|
||||
fsmount[part], 20);
|
||||
msg_prompt_add(MSG_mountpoint, NULL, fsmount[part],
|
||||
20);
|
||||
partstart += partsize;
|
||||
remain = fsdsize - partstart;
|
||||
part++;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* OK, we have a partition table. Give the user the chance to
|
||||
* edit it and verify it's OK, or abort altogether.
|
||||
@ -337,16 +368,14 @@ md_make_bsd_partitions()
|
||||
/* save label to disk for MI code to update. */
|
||||
(void) savenewlabel(bsdlabel, 8); /* 8 partitions in label */
|
||||
|
||||
|
||||
/* Everything looks OK. */
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Upgrade support */
|
||||
int
|
||||
md_update()
|
||||
md_update(void)
|
||||
{
|
||||
|
||||
endwin();
|
||||
md_copy_filesystem();
|
||||
md_post_newfs();
|
||||
@ -357,7 +386,26 @@ md_update()
|
||||
}
|
||||
|
||||
void
|
||||
md_cleanup_install()
|
||||
md_cleanup_install(void)
|
||||
{
|
||||
char realfrom[STRSIZE];
|
||||
char realto[STRSIZE];
|
||||
char sedcmd[STRSIZE];
|
||||
|
||||
strncpy(realfrom, target_expand("/etc/rc.conf"), STRSIZE);
|
||||
strncpy(realto, target_expand("/etc/rc.conf.install"), STRSIZE);
|
||||
|
||||
sprintf(sedcmd, "sed 's/rc_configured=NO/rc_configured=YES/' < %s > %s",
|
||||
realfrom, realto);
|
||||
if (logging)
|
||||
(void)fprintf(log, "%s\n", sedcmd);
|
||||
if (scripting)
|
||||
(void)fprintf(script, "%s\n", sedcmd);
|
||||
do_system(sedcmd);
|
||||
|
||||
run_prog(1, 0, NULL, "mv -f %s %s", realto, realfrom);
|
||||
|
||||
run_prog(0, 0, NULL, "rm -f %s", target_expand("/sysinst"));
|
||||
run_prog(0, 0, NULL, "rm -f %s", target_expand("/.termcap"));
|
||||
run_prog(0, 0, NULL, "rm -f %s", target_expand("/.profile"));
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.2 1999/07/11 14:12:21 minoura Exp $ */
|
||||
/* $NetBSD: md.c,v 1.3 1999/08/10 15:54:56 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -37,6 +37,7 @@
|
||||
*/
|
||||
|
||||
/* md.c -- Machine specific code for x68k */
|
||||
/* This file is in close sync with pmax, sparc, and vax md.c */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
@ -54,9 +55,15 @@
|
||||
* Symbolic names for disk partitions.
|
||||
*/
|
||||
#define PART_ROOT A
|
||||
#define PART_SWAP B
|
||||
#define PART_RAW C
|
||||
#define PART_USR D
|
||||
#define PART_USR D /* Can be after PART_FIRST_FREE */
|
||||
#define PART_FIRST_FREE E
|
||||
#define PART_LAST H
|
||||
|
||||
#define DEFSWAPRAM 32 /* Assume at least this RAM for swap calc */
|
||||
#define DEFROOTSIZE 20 /* Default root size */
|
||||
#define STDNEEDMB 80 /* Min space for non X install */
|
||||
|
||||
#ifdef notyet
|
||||
#undef NDOSPART 8
|
||||
@ -80,7 +87,7 @@ static int md_newdisk __P((void));
|
||||
static int md_check_partition_order __P((void));
|
||||
|
||||
int
|
||||
md_get_info()
|
||||
md_get_info(void)
|
||||
{
|
||||
char buf[1024];
|
||||
int fd;
|
||||
@ -91,12 +98,16 @@ md_get_info()
|
||||
|
||||
fd = open(devname, O_RDONLY, 0);
|
||||
if (fd < 0) {
|
||||
if (logging)
|
||||
(void)fprintf(log, "Can't open %s\n", devname);
|
||||
endwin();
|
||||
fprintf(stderr, "Can't open %s\n", devname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
|
||||
if (logging)
|
||||
(void)fprintf(log, "Can't read disklabel on %s.\n",
|
||||
devname);
|
||||
endwin();
|
||||
fprintf(stderr, "Can't read disklabel on %s.\n", devname);
|
||||
close(fd);
|
||||
@ -141,7 +152,7 @@ md_get_info()
|
||||
close(fd);
|
||||
|
||||
/* Compute minimum NetBSD partition sizes (in sectors). */
|
||||
minfsdmb = (80 + 4*rammb) * (MEG / sectorsize);
|
||||
minfsdmb = STDNEEDMB * (MEG / sectorsize);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -308,7 +319,7 @@ md_check_partitions(void)
|
||||
* hook called before writing new disklabel.
|
||||
*/
|
||||
int
|
||||
md_pre_disklabel()
|
||||
md_pre_disklabel(void)
|
||||
{
|
||||
if (md_need_newdisk)
|
||||
md_newdisk ();
|
||||
@ -327,7 +338,7 @@ md_post_disklabel(void)
|
||||
/*
|
||||
* MD hook called after upgrade() or install() has finished setting
|
||||
* up the target disk but immediately before the user is given the
|
||||
* ``disks are now set up'' message that, if power fails, they can
|
||||
* ``disks are now set up'' message, so that if power fails, they can
|
||||
* continue installation by booting the target disk and doing an
|
||||
* `upgrade'.
|
||||
*
|
||||
@ -352,12 +363,16 @@ md_copy_filesystem(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* md back-end code for menu-driven BSD disklabel editor.
|
||||
*/
|
||||
int
|
||||
md_make_bsd_partitions(void)
|
||||
{
|
||||
int i, part;
|
||||
int remain;
|
||||
char isize[20];
|
||||
int maxpart = getmaxpartitions();
|
||||
|
||||
/*
|
||||
* Initialize global variables that track space used on this disk.
|
||||
@ -365,7 +380,7 @@ md_make_bsd_partitions(void)
|
||||
*/
|
||||
ptstart = 64; /* assume 512 byte/sector */
|
||||
ptsize = dlsize - ptstart;
|
||||
fsdsize = dlsize;
|
||||
fsdsize = dlsize; /* actually means `whole disk' */
|
||||
fsptsize = dlsize - ptstart; /* netbsd partition -- same as above */
|
||||
fsdmb = fsdsize / MEG;
|
||||
|
||||
@ -383,6 +398,7 @@ md_make_bsd_partitions(void)
|
||||
multname = msg_string(MSG_megname);
|
||||
}
|
||||
|
||||
|
||||
/* Build standard partitions */
|
||||
emptylabel(bsdlabel);
|
||||
|
||||
@ -393,14 +409,13 @@ md_make_bsd_partitions(void)
|
||||
|
||||
/* Standard fstypes */
|
||||
bsdlabel[A].pi_fstype = FS_BSDFFS;
|
||||
bsdlabel[B].pi_fstype = FS_SWAP;
|
||||
bsdlabel[B].pi_fstype = FS_UNUSED;
|
||||
/* Conventionally, C is whole disk. */
|
||||
bsdlabel[D].pi_fstype = FS_UNUSED; /* fill out below */
|
||||
bsdlabel[E].pi_fstype = FS_UNUSED;
|
||||
bsdlabel[F].pi_fstype = FS_UNUSED;
|
||||
bsdlabel[G].pi_fstype = FS_UNUSED;
|
||||
bsdlabel[H].pi_fstype = FS_UNUSED;
|
||||
part = D;
|
||||
|
||||
|
||||
switch (layoutkind) {
|
||||
@ -409,22 +424,23 @@ md_make_bsd_partitions(void)
|
||||
partstart = ptstart;
|
||||
|
||||
/* Root */
|
||||
/* 20Mbyte for root */
|
||||
partsize= NUMSEC(20, MEG/sectorsize, dlcylsize);
|
||||
bsdlabel[A].pi_offset = partstart;
|
||||
bsdlabel[A].pi_size = partsize;
|
||||
bsdlabel[A].pi_bsize = 8192;
|
||||
bsdlabel[A].pi_fsize = 1024;
|
||||
strcpy(fsmount[A], "/");
|
||||
partsize = NUMSEC(DEFROOTSIZE, MEG/sectorsize, dlcylsize);
|
||||
bsdlabel[PART_ROOT].pi_offset = partstart;
|
||||
bsdlabel[PART_ROOT].pi_size = partsize;
|
||||
bsdlabel[PART_ROOT].pi_bsize = 8192;
|
||||
bsdlabel[PART_ROOT].pi_fsize = 1024;
|
||||
strcpy(fsmount[PART_ROOT], "/");
|
||||
partstart += partsize;
|
||||
|
||||
/* swap */
|
||||
i = NUMSEC (layoutkind * 2 * (rammb < 32 ? 32 : rammb),
|
||||
i = NUMSEC(layoutkind * 2 *
|
||||
(rammb < DEFSWAPRAM ? DEFSWAPRAM : rammb),
|
||||
MEG/sectorsize, dlcylsize) + partstart;
|
||||
partsize = NUMSEC(i/(MEG/sectorsize)+1, MEG/sectorsize,
|
||||
dlcylsize) - partstart;
|
||||
bsdlabel[B].pi_offset = partstart;
|
||||
bsdlabel[B].pi_size = partsize;
|
||||
bsdlabel[PART_SWAP].pi_fstype = FS_SWAP;
|
||||
bsdlabel[PART_SWAP].pi_offset = partstart;
|
||||
bsdlabel[PART_SWAP].pi_size = partsize;
|
||||
partstart += partsize;
|
||||
|
||||
/* /usr */
|
||||
@ -443,40 +459,56 @@ md_make_bsd_partitions(void)
|
||||
/* root */
|
||||
partstart = ptstart;
|
||||
remain = fsdsize - partstart;
|
||||
/* 20Mbyte for root */
|
||||
partsize = NUMSEC (20, MEG/sectorsize, dlcylsize);
|
||||
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);
|
||||
bsdlabel[A].pi_offset = partstart;
|
||||
bsdlabel[A].pi_size = partsize;
|
||||
bsdlabel[A].pi_bsize = 8192;
|
||||
bsdlabel[A].pi_fsize = 1024;
|
||||
strcpy(fsmount[A], "/");
|
||||
/* If less than a 'unit' left, also use it */
|
||||
if (remain - partsize < sizemult)
|
||||
partsize = remain;
|
||||
bsdlabel[PART_ROOT].pi_offset = partstart;
|
||||
bsdlabel[PART_ROOT].pi_size = partsize;
|
||||
bsdlabel[PART_ROOT].pi_bsize = 8192;
|
||||
bsdlabel[PART_ROOT].pi_fsize = 1024;
|
||||
strcpy(fsmount[PART_ROOT], "/");
|
||||
partstart += partsize;
|
||||
|
||||
/* swap */
|
||||
remain = fsdsize - partstart;
|
||||
i = NUMSEC(2 * (rammb < 32 ? 32 : rammb),
|
||||
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);
|
||||
bsdlabel[B].pi_offset = partstart;
|
||||
bsdlabel[B].pi_size = partsize;
|
||||
if (partsize) {
|
||||
/* If less than a 'unit' left, also use it */
|
||||
if (remain - partsize < sizemult)
|
||||
partsize = remain;
|
||||
bsdlabel[PART_SWAP].pi_fstype = FS_SWAP;
|
||||
bsdlabel[PART_SWAP].pi_offset = partstart;
|
||||
bsdlabel[PART_SWAP].pi_size = partsize;
|
||||
partstart += partsize;
|
||||
}
|
||||
}
|
||||
|
||||
/* /usr */
|
||||
remain = fsdsize - partstart;
|
||||
partsize = fsdsize - 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;
|
||||
bsdlabel[PART_USR].pi_fstype = FS_BSDFFS;
|
||||
@ -486,19 +518,24 @@ md_make_bsd_partitions(void)
|
||||
bsdlabel[PART_USR].pi_fsize = 1024;
|
||||
strcpy(fsmount[PART_USR], "/usr");
|
||||
partstart += partsize;
|
||||
}
|
||||
}
|
||||
|
||||
/* Others ... */
|
||||
remain = fsdsize - partstart;
|
||||
part = F;
|
||||
if (remain > 0)
|
||||
msg_display(MSG_otherparts);
|
||||
while (remain > 0 && part <= H) {
|
||||
part = PART_FIRST_FREE;
|
||||
for (; remain > 0 && part <= PART_LAST; ++part ) {
|
||||
if (bsdlabel[part].pi_fstype != FS_UNUSED)
|
||||
continue;
|
||||
partsize = fsdsize - partstart;
|
||||
snprintf(isize, 20, "%d", partsize/sizemult);
|
||||
msg_prompt_add(MSG_askfspart, isize, isize, 20,
|
||||
diskdev, partname[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;
|
||||
bsdlabel[part].pi_fstype = FS_BSDFFS;
|
||||
@ -506,23 +543,21 @@ md_make_bsd_partitions(void)
|
||||
bsdlabel[part].pi_size = partsize;
|
||||
bsdlabel[part].pi_bsize = 8192;
|
||||
bsdlabel[part].pi_fsize = 1024;
|
||||
msg_prompt_add(MSG_mountpoint, NULL,
|
||||
fsmount[part], 20);
|
||||
msg_prompt_add(MSG_mountpoint, NULL, fsmount[part],
|
||||
20);
|
||||
partstart += partsize;
|
||||
remain = fsdsize - partstart;
|
||||
part++;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* OK, we have a partition table. Give the user the chance to
|
||||
* edit it and verify it's OK, or abort altogether.
|
||||
*/
|
||||
edit_check:
|
||||
if (edit_and_check_label(bsdlabel, 8, RAW_PART, RAW_PART) == 0) {
|
||||
if (edit_and_check_label(bsdlabel, maxpart, RAW_PART, RAW_PART) == 0) {
|
||||
msg_display(MSG_abort);
|
||||
return 0;
|
||||
}
|
||||
@ -602,6 +637,7 @@ md_cleanup_install(void)
|
||||
do_system(sedcmd);
|
||||
|
||||
run_prog(1, 0, NULL, "mv -f %s %s", realto, realfrom);
|
||||
|
||||
run_prog(0, 0, NULL, "rm -f %s", target_expand("/sysinst"));
|
||||
run_prog(0, 0, NULL, "rm -f %s", target_expand("/.termcap"));
|
||||
run_prog(0, 0, NULL, "rm -f %s", target_expand("/.profile"));
|
||||
|
Loading…
Reference in New Issue
Block a user