Round partitions to the next whole cylinder.
Fill in devicename and mountpoint structures from default_disklabel() so stage2 code knows what to do. New file label.c for disklabel editing code.
This commit is contained in:
parent
859b82e043
commit
e661ae2fa9
@ -4,11 +4,11 @@ NOMAN= yet
|
||||
|
||||
.PATH: /usr/src/sbin/disklabel
|
||||
|
||||
SRCS = stage1.c dkcksum.c bootarea.c mbr.c \
|
||||
utils.c termcap.c exec.c \
|
||||
stage0.c stage2.c stage3.c main.c
|
||||
SRCS = bootarea.c exec.c dkcksum.c label.c \
|
||||
main.c mbr.c stage0.c stage1.c \
|
||||
stage2.c stage3.c termcap.c utils.c
|
||||
|
||||
CFLAGS += -Wall -g
|
||||
CFLAGS += -Wall
|
||||
LDADD = -ldialog -lncurses -lmytinfo
|
||||
DPADD = ${LIBDIALOG} ${LIBNCURSES} ${LIBMYTINFO}
|
||||
|
||||
|
@ -33,6 +33,7 @@ extern char *bootblocks;
|
||||
extern struct mbr *mbr;
|
||||
extern char boot1[];
|
||||
extern char boot2[];
|
||||
extern char **avail_disknames;
|
||||
|
||||
int
|
||||
enable_label(int fd)
|
||||
@ -129,11 +130,10 @@ build_bootblocks(struct disklabel *label)
|
||||
|
||||
dialog_clear();
|
||||
|
||||
/* Copy DOS partition area into bootblocks */
|
||||
/* Copy MBR partition area into bootblocks */
|
||||
|
||||
bcopy(mbr->dospart, &bootblocks[DOSPARTOFF],
|
||||
sizeof(struct dos_partition) * 4);
|
||||
|
||||
sizeof(struct dos_partition) * NDOSPART);
|
||||
|
||||
/* Write the disklabel into the bootblocks */
|
||||
|
||||
@ -162,6 +162,7 @@ default_disklabel(struct disklabel *label, int avail_sects, int offset)
|
||||
{
|
||||
|
||||
int nsects;
|
||||
int cylfill;
|
||||
|
||||
/* Fill in default label entries */
|
||||
label->d_magic = DISKMAGIC;
|
||||
@ -189,8 +190,15 @@ default_disklabel(struct disklabel *label, int avail_sects, int offset)
|
||||
label->d_partitions[3].p_fstype = FS_UNUSED;
|
||||
label->d_partitions[3].p_frag = DEFFRAG;
|
||||
|
||||
/* Round offset to a cylinder */
|
||||
cylfill = offset / label->d_secpercyl;
|
||||
cylfill++;
|
||||
cylfill *= label->d_secpercyl;
|
||||
cylfill = cylfill - offset;
|
||||
|
||||
/* Default root */
|
||||
nsects = Mb_to_cylbdry(DEFROOTSIZE, label);
|
||||
nsects += cylfill;
|
||||
|
||||
label->d_partitions[0].p_size = nsects;
|
||||
label->d_partitions[0].p_offset = offset;
|
||||
@ -226,6 +234,15 @@ default_disklabel(struct disklabel *label, int avail_sects, int offset)
|
||||
customise_label()
|
||||
#endif
|
||||
|
||||
sprintf(scratch, "%sa", avail_disknames[inst_disk]);
|
||||
devicename[0] = StrAlloc(scratch);
|
||||
mountpoint[0] = StrAlloc("/");
|
||||
sprintf(scratch, "%sb", avail_disknames[inst_disk]);
|
||||
devicename[1] = StrAlloc(scratch);
|
||||
mountpoint[1] = StrAlloc("swap");
|
||||
sprintf(scratch, "%se", avail_disknames[inst_disk]);
|
||||
devicename[2] = StrAlloc(scratch);
|
||||
mountpoint[2] = StrAlloc("/usr");
|
||||
}
|
||||
|
||||
int
|
||||
|
73
sbin/sysinstall/label.c
Normal file
73
sbin/sysinstall/label.c
Normal file
@ -0,0 +1,73 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/disklabel.h>
|
||||
|
||||
#include <dialog.h>
|
||||
#include "sysinstall.h"
|
||||
|
||||
void
|
||||
display_disklabel(int disk)
|
||||
{
|
||||
int i, key=0;
|
||||
WINDOW *window;
|
||||
|
||||
window = newwin(LINES, COLS, 0, 0);
|
||||
keypad(window, TRUE);
|
||||
|
||||
draw_box(window, 1, 1, LINES-2, COLS-2,
|
||||
COLOR_PAIR(COLOR_YELLOW), COLOR_PAIR(COLOR_BLUE));
|
||||
|
||||
wattron(window, COLOR_PAIR(COLOR_RED));
|
||||
mvwprintw(window, 2, 2, "Dumping label for disk %d, %s\n", disk, avail_disklabels[disk].d_typename);
|
||||
mvwprintw(window, 3, 2, "magic = %lu",avail_disklabels[disk].d_magic);
|
||||
mvwprintw(window, 3, 22, "type = %x",avail_disklabels[disk].d_type);
|
||||
mvwprintw(window, 3, 32, "subtype = %x\n",avail_disklabels[disk].d_subtype);
|
||||
mvwprintw(window, 4, 2, "Typename = %s",avail_disklabels[disk].d_typename);
|
||||
mvwprintw(window, 4, 38, "Packname = %s",avail_disklabels[disk].d_packname);
|
||||
mvwprintw(window, 5, 74, "boot0 = %s",avail_disklabels[disk].d_boot0);
|
||||
mvwprintw(window, 5, 50, "boot1 = %s\n",avail_disklabels[disk].d_boot1);
|
||||
mvwprintw(window, 5, 2, "secsize = %ld",avail_disklabels[disk].d_secsize);
|
||||
mvwprintw(window, 5, 20, "nsectors = %ld",avail_disklabels[disk].d_nsectors);
|
||||
mvwprintw(window, 5, 30, "ntracks = %ld",avail_disklabels[disk].d_ntracks);
|
||||
mvwprintw(window, 5, 50, "ncylinders = %ld\n",avail_disklabels[disk].d_ncylinders);
|
||||
mvwprintw(window, 6, 2, "secpercyl = %ld",avail_disklabels[disk].d_secpercyl);
|
||||
mvwprintw(window, 6, 40, "secperunit = %ld\n",avail_disklabels[disk].d_secperunit);
|
||||
mvwprintw(window, 7, 2, "sparespertrack = %d",avail_disklabels[disk].d_sparespertrack);
|
||||
mvwprintw(window, 7, 20, "sparespercyl = %d",avail_disklabels[disk].d_sparespercyl);
|
||||
mvwprintw(window, 7, 40, "acylinders = %ld\n",avail_disklabels[disk].d_acylinders);
|
||||
mvwprintw(window, 8, 2, "rpm = %d",avail_disklabels[disk].d_rpm);
|
||||
mvwprintw(window, 8, 20, "interleave = %d",avail_disklabels[disk].d_interleave);
|
||||
mvwprintw(window, 8, 40, "trackskew = %d",avail_disklabels[disk].d_trackskew);
|
||||
mvwprintw(window, 8, 60, "cylskew = %d\n",avail_disklabels[disk].d_cylskew);
|
||||
mvwprintw(window, 9, 2, "headswitch = %ld",avail_disklabels[disk].d_headswitch);
|
||||
mvwprintw(window, 9, 30, "trkseek = %ld",avail_disklabels[disk].d_trkseek);
|
||||
mvwprintw(window, 9, 55, "flags = %ld\n",avail_disklabels[disk].d_flags);
|
||||
mvwprintw(window, 10, 2, "Drivedata");
|
||||
for(i=0; i< NDDATA; i++) {
|
||||
mvwprintw(window, 10, 11 + (i*10), " : %d = %ld",i,avail_disklabels[disk].d_drivedata[i]);
|
||||
}
|
||||
mvwprintw(window, 11, 2, "Spare");
|
||||
for (i=0; i< NSPARE; i++) {
|
||||
mvwprintw(window, 11, 7 + (i*10), " : %d = %ld",i,avail_disklabels[disk].d_spare[i]);
|
||||
}
|
||||
mvwprintw(window, 12, 2, "magic2 = %lu",avail_disklabels[disk].d_magic2);
|
||||
mvwprintw(window, 12, 40, "checksum = %d\n",avail_disklabels[disk].d_checksum);
|
||||
mvwprintw(window, 13, 2, "npartitions = %d",avail_disklabels[disk].d_npartitions);
|
||||
mvwprintw(window, 13, 25, "bbsize = %lu",avail_disklabels[disk].d_bbsize);
|
||||
mvwprintw(window, 13, 50, "sbsize = %lu\n",avail_disklabels[disk].d_sbsize);
|
||||
for (i=0; i< MAXPARTITIONS; i++) {
|
||||
mvwprintw(window, 14+i, 2, "%d: size: %ld",i,avail_disklabels[disk].d_partitions[i].p_size);
|
||||
mvwprintw(window, 14+i, 20, "offset: %ld",avail_disklabels[disk].d_partitions[i].p_offset);
|
||||
mvwprintw(window, 14+i, 36, "fsize: %ld",avail_disklabels[disk].d_partitions[i].p_fsize);
|
||||
mvwprintw(window, 14+i, 49, "fstype: %d",avail_disklabels[disk].d_partitions[i].p_fstype);
|
||||
mvwprintw(window, 14+i, 60, "frag: %d",avail_disklabels[disk].d_partitions[i].p_frag);
|
||||
mvwprintw(window, 14+i, 70, "cpg: %d",avail_disklabels[disk].d_partitions[i].p_cpg);
|
||||
}
|
||||
|
||||
refresh();
|
||||
|
||||
while (key != '\n')
|
||||
key = wgetch(window);
|
||||
clear();
|
||||
dialog_clear();
|
||||
refresh();
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id: main.c,v 1.5 1994/10/20 19:30:50 ache Exp $
|
||||
* $Id: main.c,v 1.6 1994/10/21 02:14:50 phk Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -96,23 +96,6 @@ main(int argc, char **argv)
|
||||
if (getenv("STAGE0") || !access("/this_is_boot_flp",R_OK)) {
|
||||
stage0();
|
||||
stage1();
|
||||
|
||||
/*
|
||||
* XXX This is how stage one should output:
|
||||
*/
|
||||
devicename[0] = StrAlloc("wd0a");
|
||||
mountpoint[0] = StrAlloc("/");
|
||||
|
||||
devicename[1] = StrAlloc("wd0e");
|
||||
mountpoint[1] = StrAlloc("/usr");
|
||||
|
||||
devicename[2] = StrAlloc("wd0b");
|
||||
mountpoint[2] = StrAlloc("swap");
|
||||
/*
|
||||
* XXX sort it by mountpoint, so that safe seq of mounting
|
||||
* is guaranteed
|
||||
*/
|
||||
|
||||
stage2();
|
||||
reboot(RB_AUTOBOOT);
|
||||
} else if (getenv("STAGE3") || !access("/this_is_hd",R_OK)) {
|
||||
|
@ -97,7 +97,7 @@ show_mbr(struct mbr *mbr)
|
||||
window = newwin(LINES, COLS, 0, 0);
|
||||
keypad(window, TRUE);
|
||||
|
||||
draw_box(window, 0, 0, LINES - 1, COLS - 1,
|
||||
draw_box(window, 1, 1, LINES - 2, COLS - 2,
|
||||
COLOR_PAIR(COLOR_YELLOW), COLOR_PAIR(COLOR_BLUE));
|
||||
|
||||
for (i=0; i<NDOSPART/2; i++) {
|
||||
@ -128,6 +128,7 @@ show_mbr(struct mbr *mbr)
|
||||
key = wgetch(window);
|
||||
|
||||
delwin(window);
|
||||
refresh();
|
||||
dialog_clear();
|
||||
}
|
||||
|
||||
|
@ -249,6 +249,7 @@ stage1()
|
||||
ready = 1;
|
||||
|
||||
inst_disk = select_disk();
|
||||
display_disklabel(inst_disk);
|
||||
|
||||
if (read_mbr(avail_fds[inst_disk], mbr) == -1) {
|
||||
sprintf(scratch, "The following error occured will trying\nto read the master boot record:\n\n%s\nIn order to install FreeBSD a new master boot record\nwill have to be written which will mean all current\ndata on the hard disk will be lost.", errmsg);
|
||||
@ -317,6 +318,7 @@ stage1()
|
||||
}
|
||||
}
|
||||
|
||||
display_disklabel(inst_disk);
|
||||
/* Write master boot record and bootblocks */
|
||||
if (write_mbr(avail_fds[inst_disk], mbr) == -1)
|
||||
Fatal(errmsg);
|
||||
|
Loading…
Reference in New Issue
Block a user