Everything but the partition editor is done. This commit is for MBR testing.

This commit is contained in:
Jordan K. Hubbard 1995-05-04 23:36:23 +00:00
parent fb31b6d679
commit a2e3498a3c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=8281
24 changed files with 1410 additions and 177 deletions

View File

@ -7,7 +7,8 @@ CLEANFILES= makedevs.c rtermcap
SRCS = globals.c main.c dmenu.c menus.c \
misc.c msg.c system.c install.c \
termcap.c makedevs.c media.c variable.c \
devices.c dist.c lang.c
devices.c dist.c lang.c wizard.c \
disks.c
CFLAGS += -Wall -g -I${.CURDIR}/../libdisk

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: devices.c,v 1.2 1995/05/04 03:51:14 jkh Exp $
* $Id: devices.c,v 1.3 1995/05/04 19:48:09 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -42,7 +42,6 @@
*/
#include "sysinstall.h"
#include "libdisk.h"
#include <ctype.h>
/* Where we start displaying chunk information on the screen */
@ -79,13 +78,13 @@ static struct chunk *chunk_info[10];
static int current_chunk;
static void
record_chunks(char *disk, struct disk *d)
record_chunks(struct disk *d)
{
struct chunk *c1;
int i = 0;
int last_free = 0;
if (!d->chunks)
msgFatal("No chunk list found for %s!", disk);
msgFatal("No chunk list found for %s!", d->name);
c1 = d->chunks->part;
while (c1) {
if (c1->type == unused && c1->size > last_free) {
@ -99,14 +98,15 @@ record_chunks(char *disk, struct disk *d)
}
static void
print_chunks(char *disk, struct disk *d)
print_chunks(struct disk *d)
{
int row;
int i;
attrset(A_NORMAL);
mvaddstr(0, 0, "Disk name:\t");
attrset(A_BOLD); addstr(disk); attrset(A_NORMAL);
attrset(A_BOLD); addstr(d->name); attrset(A_NORMAL);
attrset(A_REVERSE); mvaddstr(0, 55, "Master Partition Editor"); attrset(A_NORMAL);
mvprintw(1, 0,
"BIOS Geometry:\t%lu cyls/%lu heads/%lu sectors",
d->bios_cyl, d->bios_hd, d->bios_sect);
@ -129,42 +129,34 @@ print_chunks(char *disk, struct disk *d)
static void
print_command_summary()
{
mvprintw(15, 0, "The following commands are supported (in upper or lower case):");
mvprintw(14, 0, "The following commands are supported (in upper or lower case):");
mvprintw(16, 0, "A = Use Entire Disk B = Scan For Bad Blocks");
mvprintw(17, 0, "C = Create New Partition D = Delete Partition");
mvprintw(18, 0, "B = Scan For Bad Blocks U = Undo All Changes");
mvprintw(19, 0, "W = Write Changes ESC = Proceed to next screen");
mvprintw(18, 0, "G = Set BIOS Geometry U = Undo All Changes");
mvprintw(19, 0, "W = `Wizard' Mode ESC = Proceed to next screen");
mvprintw(21, 0, "The currently selected partition is displayed in ");
attrset(A_BOLD); addstr("bold"); attrset(A_NORMAL);
mvprintw(22, 0, "Use F1 or `?' for help on this screen");
move(0, 0);
}
struct disk *
device_slice_disk(char *disk)
device_slice_disk(struct disk *d)
{
struct disk *d;
char *p;
int key = 0;
Boolean chunking;
char *msg = NULL;
d = Open_Disk(disk);
if (!d)
msgFatal("Couldn't open disk `%s'!", disk);
p = CheckRules(d);
if (p) {
msgConfirm(p);
free(p);
}
char name[40];
dialog_clear();
chunking = TRUE;
strncpy(name, d->name, 40);
keypad(stdscr, TRUE);
record_chunks(disk, d);
record_chunks(d);
while (chunking) {
clear();
print_chunks(disk, d);
print_chunks(d);
print_command_summary();
if (msg) {
standout(); mvprintw(23, 0, msg); standend();
@ -203,10 +195,16 @@ device_slice_disk(char *disk)
systemDisplayFile("slice.hlp");
break;
case 'A':
All_FreeBSD(d);
record_chunks(d);
break;
case 'B':
if (chunk_info[current_chunk]->type != freebsd)
msg = "Can only scan for bad blocks in FreeBSD partition.";
else
else if (strncmp(name, "sd", 2) ||
!msgYesNo("This typically makes sense only for ESDI, IDE or MFM drives.\nAre you sure you want to do this on a SCSI disk?"))
chunk_info[current_chunk]->flags |= CHUNK_BAD144;
break;
@ -220,13 +218,13 @@ device_slice_disk(char *disk)
snprintf(tmp, 20, "%d", chunk_info[current_chunk]->size);
val = msgGetInput(tmp, "Please specify size for new FreeBSD partition");
if (val && (size = atoi(val)) > 0) {
if (val && (size = strtol(val, 0, 0)) > 0) {
Create_Chunk(d, chunk_info[current_chunk]->offset,
size,
freebsd,
3,
chunk_info[current_chunk]->flags);
record_chunks(disk, d);
record_chunks(d);
}
}
break;
@ -236,21 +234,36 @@ device_slice_disk(char *disk)
msg = "Partition is already unused!";
else {
Delete_Chunk(d, chunk_info[current_chunk]);
record_chunks(disk, d);
record_chunks(d);
}
break;
case 'G':
/* Set geometry */
break;
case 'U':
Free_Disk(d);
d = Open_Disk(disk);
record_chunks(disk, d);
d = Open_Disk(name);
if (!d)
msgFatal("Can't reopen disk %s!", name);
record_chunks(d);
break;
case 'W':
if (!msgYesNo("Are you sure you want to write this to disk?"))
Write_Disk(d);
if (!msgYesNo("Are you sure you want to go into Wizard mode?\nNo seat belts whatsoever are provided!")) {
clear();
dialog_clear();
end_dialog();
DialogActive = FALSE;
slice_wizard(d);
clear();
dialog_clear();
DialogActive = TRUE;
record_chunks(d);
}
else
msg = "Write not confirmed";
msg = "Wise choice!";
break;
case 27: /* ESC */
@ -258,10 +271,16 @@ device_slice_disk(char *disk)
break;
default:
msg = "Invalid character typed.";
beep();
msg = "Type F1 or ? for help";
break;
}
}
p = CheckRules(d);
if (p) {
msgConfirm(p);
free(p);
}
clear();
refresh();
return d;

100
release/sysinstall/disks.c Normal file
View File

@ -0,0 +1,100 @@
/*
* The new sysinstall program.
*
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.5 1995/05/04 03:51:16 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer,
* verbatim and that no modifications are made prior to this
* point in the file.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Jordan Hubbard
* for the FreeBSD Project.
* 4. The name of Jordan Hubbard or the FreeBSD project may not be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include "sysinstall.h"
/* If the given disk has a root partition on it, return TRUE */
static Boolean
contains_root_partition(struct disk *d)
{
return FALSE;
}
void
partition_disk(struct disk *d)
{
}
int
write_disks(struct disk **disks)
{
int i;
extern u_char boot1[], boot2[];
extern u_char mbr[], bteasy17[];
dialog_clear();
if (!msgYesNo("Last Chance! Are you sure you want to write your changes to disk?")) {
for (i = 0; disks[i]; i++) {
if (contains_root_partition(disks[i]))
Set_Boot_Blocks(disks[i], boot1, boot2);
if (i == 0 && !msgYesNo("Would you like to install a boot manager?\n\nThis will allow you to easily select between other operating systems\non the first disk, as well as boot from a driver other than the first."))
Set_Boot_Mgr(disks[i], bteasy17);
else if (i == 0 && !msgYesNo("Would you like to remove an existing boot manager?"))
Set_Boot_Mgr(disks[i], mbr);
Write_Disk(disks[i]);
}
return 0;
}
return 1;
}
void
make_filesystems(struct disk **disks)
{
}
void
cpio_extract(struct disk **disks)
{
}
void
extract_dists(struct disk **disks)
{
}
void
do_final_setup(struct disk **disks)
{
}

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.5 1995/05/04 03:51:16 jkh Exp $
* $Id: install.c,v 1.6 1995/05/04 19:48:11 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -43,6 +43,8 @@
#include "sysinstall.h"
Boolean SystemWasInstalled;
static int
installHook(char *str)
{
@ -53,6 +55,7 @@ installHook(char *str)
/* Clip garbage off the ends */
string_prune(str);
str = string_skipwhite(str);
/* Try and open all the disks */
while (str) {
char *cp;
@ -63,30 +66,42 @@ installHook(char *str)
beep();
return 0;
}
disks[i++] = device_slice_disk(str);
disks[i] = Open_Disk(str);
if (!disks[i])
msgFatal("Unable to open disk %s!", str);
++i;
str = cp;
}
disks[i] = NULL;
if (!i)
return 0;
else {
#ifdef notdoneyet
partition_disks(disks);
if (!confirm_write(disks)) {
for (i = 0; disks[i]; i++)
Free_Disk(disks[i]);
return 0;
}
else {
while (1) {
/* Now go set up all the MBR partition information */
for (i = 0; disks[i]; i++)
disks[i] = device_slice_disk(disks[i]);
for (i = 0; disks[i]; i++)
partition_disk(disks[i]);
if (!write_disks(disks)) {
make_filesystems(disks);
cpio_extract(disks);
extract_dists(disks);
do_final_setup(disks);
systemShutdown();
SystemWasInstalled = TRUE;
break;
}
else {
dialog_clear();
if (msgYesNo("Would you like to go back to the master partition menu?")) {
for (i = 0; disks[i]; i++)
Free_Disk(disks[i]);
break;
}
}
#endif
}
return 1;
return SystemWasInstalled;
}
int
@ -105,7 +120,7 @@ installCustom(char *str)
dmenuOpen(menu, &choice, &scroll, &curr, &max);
free(menu);
free(devs);
return 1;
return SystemWasInstalled;
}
int
@ -124,7 +139,7 @@ installExpress(char *str)
dmenuOpen(menu, &choice, &scroll, &curr, &max);
free(menu);
free(devs);
return 1;
return SystemWasInstalled;
}
int

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: menus.c,v 1.5 1995/05/04 03:51:19 jkh Exp $
* $Id: menus.c,v 1.6 1995/05/04 19:48:14 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -65,7 +65,7 @@ DMenu MenuInitial = {
"This is the main menu of the FreeBSD installation system. Please\n\
select one of the options below by using the arrow keys or typing the\n\
first character of the option name you're interested in. Invoke an\n\
option by pressing enter.", /* prompt */
option by pressing enter. If you'd like a shell, press ESC", /* prompt */
"Press F1 for usage instructions", /* help line */
"usage.hlp", /* help file */
{ { "Usage", "Quick start - How to use this menu system.", /* U */
@ -76,8 +76,6 @@ option by pressing enter.", /* prompt */
DMENU_SUBMENU, (void *)&MenuLanguage, 0 },
{ "Install", "Begin installation", /* I */
DMENU_CALL, (void *)installCustom, 0 },
{ "Bootmsg", "Read the boot messages again.", /* B */
DMENU_SYSTEM_COMMAND_BOX, (void *)"dmesg", 0 },
{ NULL } },
};

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: msg.c,v 1.3 1995/05/04 03:51:21 jkh Exp $
* $Id: msg.c,v 1.4 1995/05/04 19:48:16 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -173,7 +173,7 @@ msgConfirm(char *fmt, ...)
va_end(args);
use_helpline(NULL);
use_helpfile(NULL);
dialog_mesgbox("User Confirmation Request", errstr, -1, -1);
dialog_mesgbox("User Attention Requested", errstr, -1, -1);
free(errstr);
}
@ -191,7 +191,7 @@ msgYesNo(char *fmt, ...)
va_end(args);
use_helpline(NULL);
use_helpfile(NULL);
ret = dialog_yesno("Decision Required", errstr, -1, -1);
ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1);
free(errstr);
return ret;
}

View File

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $Id: sysinstall.h,v 1.5 1995/05/04 03:51:22 jkh Exp $
* $Id: sysinstall.h,v 1.6 1995/05/04 19:48:17 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -49,6 +49,7 @@
#include <string.h>
#include <unistd.h>
#include <dialog.h>
#include "libdisk.h"
/*** Defines ***/
@ -171,6 +172,7 @@ extern int CpioFD; /* The file descriptor for our CPIO floppy */
extern int DebugFD; /* Where diagnostic output goes */
extern Boolean OnCDROM; /* Are we running off of a CDROM? */
extern Boolean OnSerial; /* Are we on a serial console? */
extern Boolean SystemWasInstalled; /* Did we install it? */
extern Boolean DialogActive; /* Is the dialog() stuff up? */
extern Variable *VarHead; /* The head of the variable chain */
extern unsigned int Dists; /* Which distributions we want */
@ -208,6 +210,14 @@ extern void systemChangeLang(char *lang);
extern void systemChangeTerminal(char *color, char *mono);
extern void systemChangeScreenmap(char *newmap);
/* disks.c */
extern void partition_disk(struct disk *disks);
extern int write_disks(struct disk **disks);
extern void make_filesystems(struct disk **disks);
extern void cpio_extract(struct disk **disks);
extern void extract_dists(struct disk **disks);
extern void do_final_setup(struct disk **disks);
/* dmenu.c */
extern void dmenuOpen(DMenu *menu, int *choice, int *scroll,
int *curr, int *max);
@ -248,7 +258,7 @@ extern int mediaSetFS(char *str);
/* devices.c */
extern Device *device_get_all(DeviceType type, int *ndevs);
extern struct disk *device_slice_disk(char *disk);
extern struct disk *device_slice_disk(struct disk *d);
extern DMenu *device_create_disk_menu(DMenu *menu, Device **rdevs,
int (*func)());
@ -268,5 +278,8 @@ extern void lang_set_Russian(char *str);
extern void lang_set_Spanish(char *str);
extern void lang_set_Swedish(char *str);
/* wizard.c */
extern void slice_wizard(struct disk *d);
#endif
/* _SYSINSTALL_H_INCLUDE */

265
release/sysinstall/wizard.c Normal file
View File

@ -0,0 +1,265 @@
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: tst01.c,v 1.8 1995/05/01 04:05:26 phk Exp $
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <err.h>
#include <sys/types.h>
#include "libdisk.h"
u_char mbr[] = {
250,51,192,142,208,188,0,124,139,244,80,7,80,31,251,252,191,0,6,185,0,1,
242,165,234,29,6,0,0,190,190,7,179,4,128,60,128,116,14,128,60,0,117,28,
131,198,16,254,203,117,239,205,24,139,20,139,76,2,139,238,131,198,16,254,
203,116,26,128,60,0,116,244,190,139,6,172,60,0,116,11,86,187,7,0,180,14,
205,16,94,235,240,235,254,191,5,0,187,0,124,184,1,2,87,205,19,95,115,12,
51,192,205,19,79,117,237,190,163,6,235,211,190,194,6,191,254,125,129,61,
85,170,117,199,139,245,234,0,124,0,0,73,110,118,97,108,105,100,32,112,97,
114,116,105,116,105,111,110,32,116,97,98,108,101,0,69,114,114,111,114,32,
108,111,97,100,105,110,103,32,111,112,101,114,97,116,105,110,103,32,115,
121,115,116,101,109,0,77,105,115,115,105,110,103,32,111,112,101,114,97,
116,105,110,103,32,115,121,115,116,101,109,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,
1,1,0,4,15,63,60,63,0,0,0,241,239,0,0,0,0,1,61,5,15,63,243,48,240,0,0,144,
208,2,0,0,0,1,244,165,15,63,170,192,192,3,0,144,208,2,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,85,170
};
u_char bteasy17[] = {
51,192,142,192,142,216,142,208,188,0,124,252,139,244,191,0,6,185,0,1,242,
165,234,96,6,0,0,139,213,88,162,72,7,60,53,116,28,180,16,246,228,5,174,
4,150,246,68,4,255,116,62,198,4,128,232,218,0,138,116,1,139,76,2,235,8,
232,207,0,185,1,0,50,209,187,0,124,184,1,2,205,19,114,30,129,191,254,1,
85,170,117,22,234,0,124,0,0,128,250,129,116,2,178,128,139,234,66,128,242,
179,136,22,58,7,191,190,7,185,4,0,198,6,45,7,49,50,246,136,45,138,69,4,
60,0,116,35,60,5,116,31,254,198,190,42,7,232,113,0,190,72,7,70,70,139,28,
10,255,116,5,50,125,4,117,243,141,183,114,7,232,90,0,131,199,16,254,6,45,
7,226,203,128,62,117,4,2,116,11,190,59,7,10,246,117,10,205,24,235,172,190,
42,7,232,57,0,232,54,0,50,228,205,26,139,218,131,195,96,180,1,205,22,180,
0,117,11,205,26,59,211,114,242,160,72,7,235,10,205,22,138,196,60,28,116,
243,4,246,60,49,114,214,60,53,119,210,80,190,40,7,187,27,6,83,252,172,80,
36,127,180,14,205,16,88,168,128,116,242,195,86,184,1,3,187,0,6,185,1,0,
50,246,205,19,94,198,6,72,7,63,195,13,138,13,10,70,48,32,46,32,46,32,46,
160,100,105,115,107,32,49,13,10,10,68,101,102,97,117,108,116,58,32,70,63,
160,0,1,0,4,0,6,3,7,7,10,10,99,14,100,14,101,20,128,20,129,25,130,30,147,
36,165,39,159,43,117,47,82,47,219,50,64,55,242,61,0,100,111,243,72,80,70,
211,79,115,178,85,110,105,248,78,111,118,101,108,236,77,105,110,105,248,
76,105,110,117,248,65,109,111,101,98,225,66,83,196,66,83,68,233,80,67,73,
216,67,80,205,86,101,110,105,248,68,111,115,115,101,227,63,191,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,85,170
};
int
scan_block(int fd, daddr_t block)
{
u_char foo[512];
if (-1 == lseek(fd,block * 512,SEEK_SET))
err(1,"lseek");
if (512 != read(fd,foo, 512))
return 1;
return 0;
}
void
Scan_Disk(struct disk *d)
{
char device[64];
u_long l;
int i,j,fd;
strcpy(device,"/dev/r");
strcat(device,d->name);
fd = open(device,O_RDWR);
if (fd < 0) {
warn("open(%s) failed",device);
return;
}
for(i=-1,l=0;;l++) {
j = scan_block(fd,l);
if (j != i) {
if (i == -1) {
printf("%c: %lu.",j ? 'B' : 'G', l);
fflush(stdout);
} else if (i == 0) {
printf(".%lu\nB: %lu.",l-1,l);
fflush(stdout);
} else {
printf(".%lu\nG: %lu.",l-1,l);
fflush(stdout);
}
i = j;
}
}
close(fd);
}
void
slice_wizard(struct disk *d)
{
struct disk *db;
char myprompt[BUFSIZ];
char input[BUFSIZ];
char *p,*q=0;
char **cp,*cmds[200];
int ncmd,i;
sprintf(myprompt,"%s> ", d->name);
while(1) {
printf("--==##==--\n");
Debug_Disk(d);
p = CheckRules(d);
if (p) {
printf("%s",p);
free(p);
}
printf(myprompt);
fflush(stdout);
q = p = fgets(input,sizeof(input),stdin);
if(!p)
break;
for(cp = cmds; (*cp = strsep(&p, " \t\n")) != NULL;)
if (**cp != '\0')
cp++;
ncmd = cp - cmds;
if(!ncmd)
continue;
if (!strcasecmp(*cmds,"quit")) { break; }
if (!strcasecmp(*cmds,"exit")) { break; }
if (!strcasecmp(*cmds,"q")) { break; }
if (!strcasecmp(*cmds,"x")) { break; }
if (!strcasecmp(*cmds,"delete") && ncmd == 2) {
printf("delete = %d\n",
Delete_Chunk(d,
(struct chunk *)strtol(cmds[1],0,0)));
continue;
}
if (!strcasecmp(*cmds,"allfreebsd")) {
All_FreeBSD(d);
continue;
}
if (!strcasecmp(*cmds,"bios") && ncmd == 4) {
Set_Bios_Geom(d,
strtol(cmds[1],0,0),
strtol(cmds[2],0,0),
strtol(cmds[3],0,0));
continue;
}
if (!strcasecmp(*cmds,"phys") && ncmd == 4) {
d = Set_Phys_Geom(d,
strtol(cmds[1],0,0),
strtol(cmds[2],0,0),
strtol(cmds[3],0,0));
continue;
}
if (!strcasecmp(*cmds,"collapse")) {
if (cmds[1])
while (Collapse_Chunk(d,
(struct chunk *)strtol(cmds[1],0,0)))
;
else
Collapse_Disk(d);
continue;
}
if (!strcasecmp(*cmds,"list")) {
cp = Disk_Names();
printf("Disks:");
for(i=0;cp[i];i++) {
printf(" %s",cp[i]);
free(cp[i]);
}
free(cp);
continue;
}
if (!strcasecmp(*cmds,"create") && ncmd == 6) {
printf("Create=%d\n",
Create_Chunk(d,
strtol(cmds[1],0,0),
strtol(cmds[2],0,0),
strtol(cmds[3],0,0),
strtol(cmds[4],0,0),
strtol(cmds[5],0,0)));
continue;
}
if (!strcasecmp(*cmds,"read")) {
db = d;
if (ncmd > 1)
d = Open_Disk(cmds[1]);
else
d = Open_Disk(d->name);
if (d)
Free_Disk(db);
else
d = db;
continue;
}
if (!strcasecmp(*cmds,"scan")) {
Scan_Disk(d);
continue;
}
if (!strcasecmp(*cmds,"bteasy")) {
Set_Boot_Mgr(d,bteasy17);
continue;
}
if (!strcasecmp(*cmds,"mbr")) {
Set_Boot_Mgr(d,mbr);
continue;
}
if (!strcasecmp(*cmds,"boot")) {
extern u_char boot1[],boot2[];
Set_Boot_Blocks(d,boot1,boot2);
continue;
}
if (!strcasecmp(*cmds,"write")) {
printf("Write=%d\n",
Write_Disk(d));
Free_Disk(d);
d = Open_Disk(d->name);
continue;
}
if (strcasecmp(*cmds,"help"))
printf("\007ERROR\n");
printf("CMDS:\n");
printf("allfreebsd\t\t");
printf("bios cyl hd sect\n");
printf("boot\t\t");
printf("bteasy17\n");
printf("collapse [pointer]\t\t");
printf("create offset size enum subtype flags\n");
printf("subtype(part): swap=1, ffs=7\t\t");
printf("delete pointer\n");
printf("list\t\t");
printf("mbr\n");
printf("phys cyl hd sect\t\t");
printf("quit\n");
printf("read [disk]\t\t");
printf("scan\n");
printf("write\t\t");
printf("ENUM:\n\t");
for(i=0;chunk_n[i];i++)
printf("%d = %s%s",i,chunk_n[i],i == 4 ? "\n\t" : " ");
printf("\n");
}
}

View File

@ -7,7 +7,8 @@ CLEANFILES= makedevs.c rtermcap
SRCS = globals.c main.c dmenu.c menus.c \
misc.c msg.c system.c install.c \
termcap.c makedevs.c media.c variable.c \
devices.c dist.c lang.c
devices.c dist.c lang.c wizard.c \
disks.c
CFLAGS += -Wall -g -I${.CURDIR}/../libdisk

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: devices.c,v 1.2 1995/05/04 03:51:14 jkh Exp $
* $Id: devices.c,v 1.3 1995/05/04 19:48:09 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -42,7 +42,6 @@
*/
#include "sysinstall.h"
#include "libdisk.h"
#include <ctype.h>
/* Where we start displaying chunk information on the screen */
@ -79,13 +78,13 @@ static struct chunk *chunk_info[10];
static int current_chunk;
static void
record_chunks(char *disk, struct disk *d)
record_chunks(struct disk *d)
{
struct chunk *c1;
int i = 0;
int last_free = 0;
if (!d->chunks)
msgFatal("No chunk list found for %s!", disk);
msgFatal("No chunk list found for %s!", d->name);
c1 = d->chunks->part;
while (c1) {
if (c1->type == unused && c1->size > last_free) {
@ -99,14 +98,15 @@ record_chunks(char *disk, struct disk *d)
}
static void
print_chunks(char *disk, struct disk *d)
print_chunks(struct disk *d)
{
int row;
int i;
attrset(A_NORMAL);
mvaddstr(0, 0, "Disk name:\t");
attrset(A_BOLD); addstr(disk); attrset(A_NORMAL);
attrset(A_BOLD); addstr(d->name); attrset(A_NORMAL);
attrset(A_REVERSE); mvaddstr(0, 55, "Master Partition Editor"); attrset(A_NORMAL);
mvprintw(1, 0,
"BIOS Geometry:\t%lu cyls/%lu heads/%lu sectors",
d->bios_cyl, d->bios_hd, d->bios_sect);
@ -129,42 +129,34 @@ print_chunks(char *disk, struct disk *d)
static void
print_command_summary()
{
mvprintw(15, 0, "The following commands are supported (in upper or lower case):");
mvprintw(14, 0, "The following commands are supported (in upper or lower case):");
mvprintw(16, 0, "A = Use Entire Disk B = Scan For Bad Blocks");
mvprintw(17, 0, "C = Create New Partition D = Delete Partition");
mvprintw(18, 0, "B = Scan For Bad Blocks U = Undo All Changes");
mvprintw(19, 0, "W = Write Changes ESC = Proceed to next screen");
mvprintw(18, 0, "G = Set BIOS Geometry U = Undo All Changes");
mvprintw(19, 0, "W = `Wizard' Mode ESC = Proceed to next screen");
mvprintw(21, 0, "The currently selected partition is displayed in ");
attrset(A_BOLD); addstr("bold"); attrset(A_NORMAL);
mvprintw(22, 0, "Use F1 or `?' for help on this screen");
move(0, 0);
}
struct disk *
device_slice_disk(char *disk)
device_slice_disk(struct disk *d)
{
struct disk *d;
char *p;
int key = 0;
Boolean chunking;
char *msg = NULL;
d = Open_Disk(disk);
if (!d)
msgFatal("Couldn't open disk `%s'!", disk);
p = CheckRules(d);
if (p) {
msgConfirm(p);
free(p);
}
char name[40];
dialog_clear();
chunking = TRUE;
strncpy(name, d->name, 40);
keypad(stdscr, TRUE);
record_chunks(disk, d);
record_chunks(d);
while (chunking) {
clear();
print_chunks(disk, d);
print_chunks(d);
print_command_summary();
if (msg) {
standout(); mvprintw(23, 0, msg); standend();
@ -203,10 +195,16 @@ device_slice_disk(char *disk)
systemDisplayFile("slice.hlp");
break;
case 'A':
All_FreeBSD(d);
record_chunks(d);
break;
case 'B':
if (chunk_info[current_chunk]->type != freebsd)
msg = "Can only scan for bad blocks in FreeBSD partition.";
else
else if (strncmp(name, "sd", 2) ||
!msgYesNo("This typically makes sense only for ESDI, IDE or MFM drives.\nAre you sure you want to do this on a SCSI disk?"))
chunk_info[current_chunk]->flags |= CHUNK_BAD144;
break;
@ -220,13 +218,13 @@ device_slice_disk(char *disk)
snprintf(tmp, 20, "%d", chunk_info[current_chunk]->size);
val = msgGetInput(tmp, "Please specify size for new FreeBSD partition");
if (val && (size = atoi(val)) > 0) {
if (val && (size = strtol(val, 0, 0)) > 0) {
Create_Chunk(d, chunk_info[current_chunk]->offset,
size,
freebsd,
3,
chunk_info[current_chunk]->flags);
record_chunks(disk, d);
record_chunks(d);
}
}
break;
@ -236,21 +234,36 @@ device_slice_disk(char *disk)
msg = "Partition is already unused!";
else {
Delete_Chunk(d, chunk_info[current_chunk]);
record_chunks(disk, d);
record_chunks(d);
}
break;
case 'G':
/* Set geometry */
break;
case 'U':
Free_Disk(d);
d = Open_Disk(disk);
record_chunks(disk, d);
d = Open_Disk(name);
if (!d)
msgFatal("Can't reopen disk %s!", name);
record_chunks(d);
break;
case 'W':
if (!msgYesNo("Are you sure you want to write this to disk?"))
Write_Disk(d);
if (!msgYesNo("Are you sure you want to go into Wizard mode?\nNo seat belts whatsoever are provided!")) {
clear();
dialog_clear();
end_dialog();
DialogActive = FALSE;
slice_wizard(d);
clear();
dialog_clear();
DialogActive = TRUE;
record_chunks(d);
}
else
msg = "Write not confirmed";
msg = "Wise choice!";
break;
case 27: /* ESC */
@ -258,10 +271,16 @@ device_slice_disk(char *disk)
break;
default:
msg = "Invalid character typed.";
beep();
msg = "Type F1 or ? for help";
break;
}
}
p = CheckRules(d);
if (p) {
msgConfirm(p);
free(p);
}
clear();
refresh();
return d;

100
usr.sbin/sade/disks.c Normal file
View File

@ -0,0 +1,100 @@
/*
* The new sysinstall program.
*
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.5 1995/05/04 03:51:16 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer,
* verbatim and that no modifications are made prior to this
* point in the file.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Jordan Hubbard
* for the FreeBSD Project.
* 4. The name of Jordan Hubbard or the FreeBSD project may not be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include "sysinstall.h"
/* If the given disk has a root partition on it, return TRUE */
static Boolean
contains_root_partition(struct disk *d)
{
return FALSE;
}
void
partition_disk(struct disk *d)
{
}
int
write_disks(struct disk **disks)
{
int i;
extern u_char boot1[], boot2[];
extern u_char mbr[], bteasy17[];
dialog_clear();
if (!msgYesNo("Last Chance! Are you sure you want to write your changes to disk?")) {
for (i = 0; disks[i]; i++) {
if (contains_root_partition(disks[i]))
Set_Boot_Blocks(disks[i], boot1, boot2);
if (i == 0 && !msgYesNo("Would you like to install a boot manager?\n\nThis will allow you to easily select between other operating systems\non the first disk, as well as boot from a driver other than the first."))
Set_Boot_Mgr(disks[i], bteasy17);
else if (i == 0 && !msgYesNo("Would you like to remove an existing boot manager?"))
Set_Boot_Mgr(disks[i], mbr);
Write_Disk(disks[i]);
}
return 0;
}
return 1;
}
void
make_filesystems(struct disk **disks)
{
}
void
cpio_extract(struct disk **disks)
{
}
void
extract_dists(struct disk **disks)
{
}
void
do_final_setup(struct disk **disks)
{
}

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.5 1995/05/04 03:51:16 jkh Exp $
* $Id: install.c,v 1.6 1995/05/04 19:48:11 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -43,6 +43,8 @@
#include "sysinstall.h"
Boolean SystemWasInstalled;
static int
installHook(char *str)
{
@ -53,6 +55,7 @@ installHook(char *str)
/* Clip garbage off the ends */
string_prune(str);
str = string_skipwhite(str);
/* Try and open all the disks */
while (str) {
char *cp;
@ -63,30 +66,42 @@ installHook(char *str)
beep();
return 0;
}
disks[i++] = device_slice_disk(str);
disks[i] = Open_Disk(str);
if (!disks[i])
msgFatal("Unable to open disk %s!", str);
++i;
str = cp;
}
disks[i] = NULL;
if (!i)
return 0;
else {
#ifdef notdoneyet
partition_disks(disks);
if (!confirm_write(disks)) {
for (i = 0; disks[i]; i++)
Free_Disk(disks[i]);
return 0;
}
else {
while (1) {
/* Now go set up all the MBR partition information */
for (i = 0; disks[i]; i++)
disks[i] = device_slice_disk(disks[i]);
for (i = 0; disks[i]; i++)
partition_disk(disks[i]);
if (!write_disks(disks)) {
make_filesystems(disks);
cpio_extract(disks);
extract_dists(disks);
do_final_setup(disks);
systemShutdown();
SystemWasInstalled = TRUE;
break;
}
else {
dialog_clear();
if (msgYesNo("Would you like to go back to the master partition menu?")) {
for (i = 0; disks[i]; i++)
Free_Disk(disks[i]);
break;
}
}
#endif
}
return 1;
return SystemWasInstalled;
}
int
@ -105,7 +120,7 @@ installCustom(char *str)
dmenuOpen(menu, &choice, &scroll, &curr, &max);
free(menu);
free(devs);
return 1;
return SystemWasInstalled;
}
int
@ -124,7 +139,7 @@ installExpress(char *str)
dmenuOpen(menu, &choice, &scroll, &curr, &max);
free(menu);
free(devs);
return 1;
return SystemWasInstalled;
}
int

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: menus.c,v 1.5 1995/05/04 03:51:19 jkh Exp $
* $Id: menus.c,v 1.6 1995/05/04 19:48:14 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -65,7 +65,7 @@ DMenu MenuInitial = {
"This is the main menu of the FreeBSD installation system. Please\n\
select one of the options below by using the arrow keys or typing the\n\
first character of the option name you're interested in. Invoke an\n\
option by pressing enter.", /* prompt */
option by pressing enter. If you'd like a shell, press ESC", /* prompt */
"Press F1 for usage instructions", /* help line */
"usage.hlp", /* help file */
{ { "Usage", "Quick start - How to use this menu system.", /* U */
@ -76,8 +76,6 @@ option by pressing enter.", /* prompt */
DMENU_SUBMENU, (void *)&MenuLanguage, 0 },
{ "Install", "Begin installation", /* I */
DMENU_CALL, (void *)installCustom, 0 },
{ "Bootmsg", "Read the boot messages again.", /* B */
DMENU_SYSTEM_COMMAND_BOX, (void *)"dmesg", 0 },
{ NULL } },
};

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: msg.c,v 1.3 1995/05/04 03:51:21 jkh Exp $
* $Id: msg.c,v 1.4 1995/05/04 19:48:16 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -173,7 +173,7 @@ msgConfirm(char *fmt, ...)
va_end(args);
use_helpline(NULL);
use_helpfile(NULL);
dialog_mesgbox("User Confirmation Request", errstr, -1, -1);
dialog_mesgbox("User Attention Requested", errstr, -1, -1);
free(errstr);
}
@ -191,7 +191,7 @@ msgYesNo(char *fmt, ...)
va_end(args);
use_helpline(NULL);
use_helpfile(NULL);
ret = dialog_yesno("Decision Required", errstr, -1, -1);
ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1);
free(errstr);
return ret;
}

View File

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $Id: sysinstall.h,v 1.5 1995/05/04 03:51:22 jkh Exp $
* $Id: sysinstall.h,v 1.6 1995/05/04 19:48:17 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -49,6 +49,7 @@
#include <string.h>
#include <unistd.h>
#include <dialog.h>
#include "libdisk.h"
/*** Defines ***/
@ -171,6 +172,7 @@ extern int CpioFD; /* The file descriptor for our CPIO floppy */
extern int DebugFD; /* Where diagnostic output goes */
extern Boolean OnCDROM; /* Are we running off of a CDROM? */
extern Boolean OnSerial; /* Are we on a serial console? */
extern Boolean SystemWasInstalled; /* Did we install it? */
extern Boolean DialogActive; /* Is the dialog() stuff up? */
extern Variable *VarHead; /* The head of the variable chain */
extern unsigned int Dists; /* Which distributions we want */
@ -208,6 +210,14 @@ extern void systemChangeLang(char *lang);
extern void systemChangeTerminal(char *color, char *mono);
extern void systemChangeScreenmap(char *newmap);
/* disks.c */
extern void partition_disk(struct disk *disks);
extern int write_disks(struct disk **disks);
extern void make_filesystems(struct disk **disks);
extern void cpio_extract(struct disk **disks);
extern void extract_dists(struct disk **disks);
extern void do_final_setup(struct disk **disks);
/* dmenu.c */
extern void dmenuOpen(DMenu *menu, int *choice, int *scroll,
int *curr, int *max);
@ -248,7 +258,7 @@ extern int mediaSetFS(char *str);
/* devices.c */
extern Device *device_get_all(DeviceType type, int *ndevs);
extern struct disk *device_slice_disk(char *disk);
extern struct disk *device_slice_disk(struct disk *d);
extern DMenu *device_create_disk_menu(DMenu *menu, Device **rdevs,
int (*func)());
@ -268,5 +278,8 @@ extern void lang_set_Russian(char *str);
extern void lang_set_Spanish(char *str);
extern void lang_set_Swedish(char *str);
/* wizard.c */
extern void slice_wizard(struct disk *d);
#endif
/* _SYSINSTALL_H_INCLUDE */

265
usr.sbin/sade/wizard.c Normal file
View File

@ -0,0 +1,265 @@
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: tst01.c,v 1.8 1995/05/01 04:05:26 phk Exp $
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <err.h>
#include <sys/types.h>
#include "libdisk.h"
u_char mbr[] = {
250,51,192,142,208,188,0,124,139,244,80,7,80,31,251,252,191,0,6,185,0,1,
242,165,234,29,6,0,0,190,190,7,179,4,128,60,128,116,14,128,60,0,117,28,
131,198,16,254,203,117,239,205,24,139,20,139,76,2,139,238,131,198,16,254,
203,116,26,128,60,0,116,244,190,139,6,172,60,0,116,11,86,187,7,0,180,14,
205,16,94,235,240,235,254,191,5,0,187,0,124,184,1,2,87,205,19,95,115,12,
51,192,205,19,79,117,237,190,163,6,235,211,190,194,6,191,254,125,129,61,
85,170,117,199,139,245,234,0,124,0,0,73,110,118,97,108,105,100,32,112,97,
114,116,105,116,105,111,110,32,116,97,98,108,101,0,69,114,114,111,114,32,
108,111,97,100,105,110,103,32,111,112,101,114,97,116,105,110,103,32,115,
121,115,116,101,109,0,77,105,115,115,105,110,103,32,111,112,101,114,97,
116,105,110,103,32,115,121,115,116,101,109,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,
1,1,0,4,15,63,60,63,0,0,0,241,239,0,0,0,0,1,61,5,15,63,243,48,240,0,0,144,
208,2,0,0,0,1,244,165,15,63,170,192,192,3,0,144,208,2,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,85,170
};
u_char bteasy17[] = {
51,192,142,192,142,216,142,208,188,0,124,252,139,244,191,0,6,185,0,1,242,
165,234,96,6,0,0,139,213,88,162,72,7,60,53,116,28,180,16,246,228,5,174,
4,150,246,68,4,255,116,62,198,4,128,232,218,0,138,116,1,139,76,2,235,8,
232,207,0,185,1,0,50,209,187,0,124,184,1,2,205,19,114,30,129,191,254,1,
85,170,117,22,234,0,124,0,0,128,250,129,116,2,178,128,139,234,66,128,242,
179,136,22,58,7,191,190,7,185,4,0,198,6,45,7,49,50,246,136,45,138,69,4,
60,0,116,35,60,5,116,31,254,198,190,42,7,232,113,0,190,72,7,70,70,139,28,
10,255,116,5,50,125,4,117,243,141,183,114,7,232,90,0,131,199,16,254,6,45,
7,226,203,128,62,117,4,2,116,11,190,59,7,10,246,117,10,205,24,235,172,190,
42,7,232,57,0,232,54,0,50,228,205,26,139,218,131,195,96,180,1,205,22,180,
0,117,11,205,26,59,211,114,242,160,72,7,235,10,205,22,138,196,60,28,116,
243,4,246,60,49,114,214,60,53,119,210,80,190,40,7,187,27,6,83,252,172,80,
36,127,180,14,205,16,88,168,128,116,242,195,86,184,1,3,187,0,6,185,1,0,
50,246,205,19,94,198,6,72,7,63,195,13,138,13,10,70,48,32,46,32,46,32,46,
160,100,105,115,107,32,49,13,10,10,68,101,102,97,117,108,116,58,32,70,63,
160,0,1,0,4,0,6,3,7,7,10,10,99,14,100,14,101,20,128,20,129,25,130,30,147,
36,165,39,159,43,117,47,82,47,219,50,64,55,242,61,0,100,111,243,72,80,70,
211,79,115,178,85,110,105,248,78,111,118,101,108,236,77,105,110,105,248,
76,105,110,117,248,65,109,111,101,98,225,66,83,196,66,83,68,233,80,67,73,
216,67,80,205,86,101,110,105,248,68,111,115,115,101,227,63,191,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,85,170
};
int
scan_block(int fd, daddr_t block)
{
u_char foo[512];
if (-1 == lseek(fd,block * 512,SEEK_SET))
err(1,"lseek");
if (512 != read(fd,foo, 512))
return 1;
return 0;
}
void
Scan_Disk(struct disk *d)
{
char device[64];
u_long l;
int i,j,fd;
strcpy(device,"/dev/r");
strcat(device,d->name);
fd = open(device,O_RDWR);
if (fd < 0) {
warn("open(%s) failed",device);
return;
}
for(i=-1,l=0;;l++) {
j = scan_block(fd,l);
if (j != i) {
if (i == -1) {
printf("%c: %lu.",j ? 'B' : 'G', l);
fflush(stdout);
} else if (i == 0) {
printf(".%lu\nB: %lu.",l-1,l);
fflush(stdout);
} else {
printf(".%lu\nG: %lu.",l-1,l);
fflush(stdout);
}
i = j;
}
}
close(fd);
}
void
slice_wizard(struct disk *d)
{
struct disk *db;
char myprompt[BUFSIZ];
char input[BUFSIZ];
char *p,*q=0;
char **cp,*cmds[200];
int ncmd,i;
sprintf(myprompt,"%s> ", d->name);
while(1) {
printf("--==##==--\n");
Debug_Disk(d);
p = CheckRules(d);
if (p) {
printf("%s",p);
free(p);
}
printf(myprompt);
fflush(stdout);
q = p = fgets(input,sizeof(input),stdin);
if(!p)
break;
for(cp = cmds; (*cp = strsep(&p, " \t\n")) != NULL;)
if (**cp != '\0')
cp++;
ncmd = cp - cmds;
if(!ncmd)
continue;
if (!strcasecmp(*cmds,"quit")) { break; }
if (!strcasecmp(*cmds,"exit")) { break; }
if (!strcasecmp(*cmds,"q")) { break; }
if (!strcasecmp(*cmds,"x")) { break; }
if (!strcasecmp(*cmds,"delete") && ncmd == 2) {
printf("delete = %d\n",
Delete_Chunk(d,
(struct chunk *)strtol(cmds[1],0,0)));
continue;
}
if (!strcasecmp(*cmds,"allfreebsd")) {
All_FreeBSD(d);
continue;
}
if (!strcasecmp(*cmds,"bios") && ncmd == 4) {
Set_Bios_Geom(d,
strtol(cmds[1],0,0),
strtol(cmds[2],0,0),
strtol(cmds[3],0,0));
continue;
}
if (!strcasecmp(*cmds,"phys") && ncmd == 4) {
d = Set_Phys_Geom(d,
strtol(cmds[1],0,0),
strtol(cmds[2],0,0),
strtol(cmds[3],0,0));
continue;
}
if (!strcasecmp(*cmds,"collapse")) {
if (cmds[1])
while (Collapse_Chunk(d,
(struct chunk *)strtol(cmds[1],0,0)))
;
else
Collapse_Disk(d);
continue;
}
if (!strcasecmp(*cmds,"list")) {
cp = Disk_Names();
printf("Disks:");
for(i=0;cp[i];i++) {
printf(" %s",cp[i]);
free(cp[i]);
}
free(cp);
continue;
}
if (!strcasecmp(*cmds,"create") && ncmd == 6) {
printf("Create=%d\n",
Create_Chunk(d,
strtol(cmds[1],0,0),
strtol(cmds[2],0,0),
strtol(cmds[3],0,0),
strtol(cmds[4],0,0),
strtol(cmds[5],0,0)));
continue;
}
if (!strcasecmp(*cmds,"read")) {
db = d;
if (ncmd > 1)
d = Open_Disk(cmds[1]);
else
d = Open_Disk(d->name);
if (d)
Free_Disk(db);
else
d = db;
continue;
}
if (!strcasecmp(*cmds,"scan")) {
Scan_Disk(d);
continue;
}
if (!strcasecmp(*cmds,"bteasy")) {
Set_Boot_Mgr(d,bteasy17);
continue;
}
if (!strcasecmp(*cmds,"mbr")) {
Set_Boot_Mgr(d,mbr);
continue;
}
if (!strcasecmp(*cmds,"boot")) {
extern u_char boot1[],boot2[];
Set_Boot_Blocks(d,boot1,boot2);
continue;
}
if (!strcasecmp(*cmds,"write")) {
printf("Write=%d\n",
Write_Disk(d));
Free_Disk(d);
d = Open_Disk(d->name);
continue;
}
if (strcasecmp(*cmds,"help"))
printf("\007ERROR\n");
printf("CMDS:\n");
printf("allfreebsd\t\t");
printf("bios cyl hd sect\n");
printf("boot\t\t");
printf("bteasy17\n");
printf("collapse [pointer]\t\t");
printf("create offset size enum subtype flags\n");
printf("subtype(part): swap=1, ffs=7\t\t");
printf("delete pointer\n");
printf("list\t\t");
printf("mbr\n");
printf("phys cyl hd sect\t\t");
printf("quit\n");
printf("read [disk]\t\t");
printf("scan\n");
printf("write\t\t");
printf("ENUM:\n\t");
for(i=0;chunk_n[i];i++)
printf("%d = %s%s",i,chunk_n[i],i == 4 ? "\n\t" : " ");
printf("\n");
}
}

View File

@ -7,7 +7,8 @@ CLEANFILES= makedevs.c rtermcap
SRCS = globals.c main.c dmenu.c menus.c \
misc.c msg.c system.c install.c \
termcap.c makedevs.c media.c variable.c \
devices.c dist.c lang.c
devices.c dist.c lang.c wizard.c \
disks.c
CFLAGS += -Wall -g -I${.CURDIR}/../libdisk

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: devices.c,v 1.2 1995/05/04 03:51:14 jkh Exp $
* $Id: devices.c,v 1.3 1995/05/04 19:48:09 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -42,7 +42,6 @@
*/
#include "sysinstall.h"
#include "libdisk.h"
#include <ctype.h>
/* Where we start displaying chunk information on the screen */
@ -79,13 +78,13 @@ static struct chunk *chunk_info[10];
static int current_chunk;
static void
record_chunks(char *disk, struct disk *d)
record_chunks(struct disk *d)
{
struct chunk *c1;
int i = 0;
int last_free = 0;
if (!d->chunks)
msgFatal("No chunk list found for %s!", disk);
msgFatal("No chunk list found for %s!", d->name);
c1 = d->chunks->part;
while (c1) {
if (c1->type == unused && c1->size > last_free) {
@ -99,14 +98,15 @@ record_chunks(char *disk, struct disk *d)
}
static void
print_chunks(char *disk, struct disk *d)
print_chunks(struct disk *d)
{
int row;
int i;
attrset(A_NORMAL);
mvaddstr(0, 0, "Disk name:\t");
attrset(A_BOLD); addstr(disk); attrset(A_NORMAL);
attrset(A_BOLD); addstr(d->name); attrset(A_NORMAL);
attrset(A_REVERSE); mvaddstr(0, 55, "Master Partition Editor"); attrset(A_NORMAL);
mvprintw(1, 0,
"BIOS Geometry:\t%lu cyls/%lu heads/%lu sectors",
d->bios_cyl, d->bios_hd, d->bios_sect);
@ -129,42 +129,34 @@ print_chunks(char *disk, struct disk *d)
static void
print_command_summary()
{
mvprintw(15, 0, "The following commands are supported (in upper or lower case):");
mvprintw(14, 0, "The following commands are supported (in upper or lower case):");
mvprintw(16, 0, "A = Use Entire Disk B = Scan For Bad Blocks");
mvprintw(17, 0, "C = Create New Partition D = Delete Partition");
mvprintw(18, 0, "B = Scan For Bad Blocks U = Undo All Changes");
mvprintw(19, 0, "W = Write Changes ESC = Proceed to next screen");
mvprintw(18, 0, "G = Set BIOS Geometry U = Undo All Changes");
mvprintw(19, 0, "W = `Wizard' Mode ESC = Proceed to next screen");
mvprintw(21, 0, "The currently selected partition is displayed in ");
attrset(A_BOLD); addstr("bold"); attrset(A_NORMAL);
mvprintw(22, 0, "Use F1 or `?' for help on this screen");
move(0, 0);
}
struct disk *
device_slice_disk(char *disk)
device_slice_disk(struct disk *d)
{
struct disk *d;
char *p;
int key = 0;
Boolean chunking;
char *msg = NULL;
d = Open_Disk(disk);
if (!d)
msgFatal("Couldn't open disk `%s'!", disk);
p = CheckRules(d);
if (p) {
msgConfirm(p);
free(p);
}
char name[40];
dialog_clear();
chunking = TRUE;
strncpy(name, d->name, 40);
keypad(stdscr, TRUE);
record_chunks(disk, d);
record_chunks(d);
while (chunking) {
clear();
print_chunks(disk, d);
print_chunks(d);
print_command_summary();
if (msg) {
standout(); mvprintw(23, 0, msg); standend();
@ -203,10 +195,16 @@ device_slice_disk(char *disk)
systemDisplayFile("slice.hlp");
break;
case 'A':
All_FreeBSD(d);
record_chunks(d);
break;
case 'B':
if (chunk_info[current_chunk]->type != freebsd)
msg = "Can only scan for bad blocks in FreeBSD partition.";
else
else if (strncmp(name, "sd", 2) ||
!msgYesNo("This typically makes sense only for ESDI, IDE or MFM drives.\nAre you sure you want to do this on a SCSI disk?"))
chunk_info[current_chunk]->flags |= CHUNK_BAD144;
break;
@ -220,13 +218,13 @@ device_slice_disk(char *disk)
snprintf(tmp, 20, "%d", chunk_info[current_chunk]->size);
val = msgGetInput(tmp, "Please specify size for new FreeBSD partition");
if (val && (size = atoi(val)) > 0) {
if (val && (size = strtol(val, 0, 0)) > 0) {
Create_Chunk(d, chunk_info[current_chunk]->offset,
size,
freebsd,
3,
chunk_info[current_chunk]->flags);
record_chunks(disk, d);
record_chunks(d);
}
}
break;
@ -236,21 +234,36 @@ device_slice_disk(char *disk)
msg = "Partition is already unused!";
else {
Delete_Chunk(d, chunk_info[current_chunk]);
record_chunks(disk, d);
record_chunks(d);
}
break;
case 'G':
/* Set geometry */
break;
case 'U':
Free_Disk(d);
d = Open_Disk(disk);
record_chunks(disk, d);
d = Open_Disk(name);
if (!d)
msgFatal("Can't reopen disk %s!", name);
record_chunks(d);
break;
case 'W':
if (!msgYesNo("Are you sure you want to write this to disk?"))
Write_Disk(d);
if (!msgYesNo("Are you sure you want to go into Wizard mode?\nNo seat belts whatsoever are provided!")) {
clear();
dialog_clear();
end_dialog();
DialogActive = FALSE;
slice_wizard(d);
clear();
dialog_clear();
DialogActive = TRUE;
record_chunks(d);
}
else
msg = "Write not confirmed";
msg = "Wise choice!";
break;
case 27: /* ESC */
@ -258,10 +271,16 @@ device_slice_disk(char *disk)
break;
default:
msg = "Invalid character typed.";
beep();
msg = "Type F1 or ? for help";
break;
}
}
p = CheckRules(d);
if (p) {
msgConfirm(p);
free(p);
}
clear();
refresh();
return d;

100
usr.sbin/sysinstall/disks.c Normal file
View File

@ -0,0 +1,100 @@
/*
* The new sysinstall program.
*
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.5 1995/05/04 03:51:16 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer,
* verbatim and that no modifications are made prior to this
* point in the file.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Jordan Hubbard
* for the FreeBSD Project.
* 4. The name of Jordan Hubbard or the FreeBSD project may not be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include "sysinstall.h"
/* If the given disk has a root partition on it, return TRUE */
static Boolean
contains_root_partition(struct disk *d)
{
return FALSE;
}
void
partition_disk(struct disk *d)
{
}
int
write_disks(struct disk **disks)
{
int i;
extern u_char boot1[], boot2[];
extern u_char mbr[], bteasy17[];
dialog_clear();
if (!msgYesNo("Last Chance! Are you sure you want to write your changes to disk?")) {
for (i = 0; disks[i]; i++) {
if (contains_root_partition(disks[i]))
Set_Boot_Blocks(disks[i], boot1, boot2);
if (i == 0 && !msgYesNo("Would you like to install a boot manager?\n\nThis will allow you to easily select between other operating systems\non the first disk, as well as boot from a driver other than the first."))
Set_Boot_Mgr(disks[i], bteasy17);
else if (i == 0 && !msgYesNo("Would you like to remove an existing boot manager?"))
Set_Boot_Mgr(disks[i], mbr);
Write_Disk(disks[i]);
}
return 0;
}
return 1;
}
void
make_filesystems(struct disk **disks)
{
}
void
cpio_extract(struct disk **disks)
{
}
void
extract_dists(struct disk **disks)
{
}
void
do_final_setup(struct disk **disks)
{
}

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.5 1995/05/04 03:51:16 jkh Exp $
* $Id: install.c,v 1.6 1995/05/04 19:48:11 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -43,6 +43,8 @@
#include "sysinstall.h"
Boolean SystemWasInstalled;
static int
installHook(char *str)
{
@ -53,6 +55,7 @@ installHook(char *str)
/* Clip garbage off the ends */
string_prune(str);
str = string_skipwhite(str);
/* Try and open all the disks */
while (str) {
char *cp;
@ -63,30 +66,42 @@ installHook(char *str)
beep();
return 0;
}
disks[i++] = device_slice_disk(str);
disks[i] = Open_Disk(str);
if (!disks[i])
msgFatal("Unable to open disk %s!", str);
++i;
str = cp;
}
disks[i] = NULL;
if (!i)
return 0;
else {
#ifdef notdoneyet
partition_disks(disks);
if (!confirm_write(disks)) {
for (i = 0; disks[i]; i++)
Free_Disk(disks[i]);
return 0;
}
else {
while (1) {
/* Now go set up all the MBR partition information */
for (i = 0; disks[i]; i++)
disks[i] = device_slice_disk(disks[i]);
for (i = 0; disks[i]; i++)
partition_disk(disks[i]);
if (!write_disks(disks)) {
make_filesystems(disks);
cpio_extract(disks);
extract_dists(disks);
do_final_setup(disks);
systemShutdown();
SystemWasInstalled = TRUE;
break;
}
else {
dialog_clear();
if (msgYesNo("Would you like to go back to the master partition menu?")) {
for (i = 0; disks[i]; i++)
Free_Disk(disks[i]);
break;
}
}
#endif
}
return 1;
return SystemWasInstalled;
}
int
@ -105,7 +120,7 @@ installCustom(char *str)
dmenuOpen(menu, &choice, &scroll, &curr, &max);
free(menu);
free(devs);
return 1;
return SystemWasInstalled;
}
int
@ -124,7 +139,7 @@ installExpress(char *str)
dmenuOpen(menu, &choice, &scroll, &curr, &max);
free(menu);
free(devs);
return 1;
return SystemWasInstalled;
}
int

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: menus.c,v 1.5 1995/05/04 03:51:19 jkh Exp $
* $Id: menus.c,v 1.6 1995/05/04 19:48:14 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -65,7 +65,7 @@ DMenu MenuInitial = {
"This is the main menu of the FreeBSD installation system. Please\n\
select one of the options below by using the arrow keys or typing the\n\
first character of the option name you're interested in. Invoke an\n\
option by pressing enter.", /* prompt */
option by pressing enter. If you'd like a shell, press ESC", /* prompt */
"Press F1 for usage instructions", /* help line */
"usage.hlp", /* help file */
{ { "Usage", "Quick start - How to use this menu system.", /* U */
@ -76,8 +76,6 @@ option by pressing enter.", /* prompt */
DMENU_SUBMENU, (void *)&MenuLanguage, 0 },
{ "Install", "Begin installation", /* I */
DMENU_CALL, (void *)installCustom, 0 },
{ "Bootmsg", "Read the boot messages again.", /* B */
DMENU_SYSTEM_COMMAND_BOX, (void *)"dmesg", 0 },
{ NULL } },
};

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: msg.c,v 1.3 1995/05/04 03:51:21 jkh Exp $
* $Id: msg.c,v 1.4 1995/05/04 19:48:16 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -173,7 +173,7 @@ msgConfirm(char *fmt, ...)
va_end(args);
use_helpline(NULL);
use_helpfile(NULL);
dialog_mesgbox("User Confirmation Request", errstr, -1, -1);
dialog_mesgbox("User Attention Requested", errstr, -1, -1);
free(errstr);
}
@ -191,7 +191,7 @@ msgYesNo(char *fmt, ...)
va_end(args);
use_helpline(NULL);
use_helpfile(NULL);
ret = dialog_yesno("Decision Required", errstr, -1, -1);
ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1);
free(errstr);
return ret;
}

View File

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $Id: sysinstall.h,v 1.5 1995/05/04 03:51:22 jkh Exp $
* $Id: sysinstall.h,v 1.6 1995/05/04 19:48:17 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -49,6 +49,7 @@
#include <string.h>
#include <unistd.h>
#include <dialog.h>
#include "libdisk.h"
/*** Defines ***/
@ -171,6 +172,7 @@ extern int CpioFD; /* The file descriptor for our CPIO floppy */
extern int DebugFD; /* Where diagnostic output goes */
extern Boolean OnCDROM; /* Are we running off of a CDROM? */
extern Boolean OnSerial; /* Are we on a serial console? */
extern Boolean SystemWasInstalled; /* Did we install it? */
extern Boolean DialogActive; /* Is the dialog() stuff up? */
extern Variable *VarHead; /* The head of the variable chain */
extern unsigned int Dists; /* Which distributions we want */
@ -208,6 +210,14 @@ extern void systemChangeLang(char *lang);
extern void systemChangeTerminal(char *color, char *mono);
extern void systemChangeScreenmap(char *newmap);
/* disks.c */
extern void partition_disk(struct disk *disks);
extern int write_disks(struct disk **disks);
extern void make_filesystems(struct disk **disks);
extern void cpio_extract(struct disk **disks);
extern void extract_dists(struct disk **disks);
extern void do_final_setup(struct disk **disks);
/* dmenu.c */
extern void dmenuOpen(DMenu *menu, int *choice, int *scroll,
int *curr, int *max);
@ -248,7 +258,7 @@ extern int mediaSetFS(char *str);
/* devices.c */
extern Device *device_get_all(DeviceType type, int *ndevs);
extern struct disk *device_slice_disk(char *disk);
extern struct disk *device_slice_disk(struct disk *d);
extern DMenu *device_create_disk_menu(DMenu *menu, Device **rdevs,
int (*func)());
@ -268,5 +278,8 @@ extern void lang_set_Russian(char *str);
extern void lang_set_Spanish(char *str);
extern void lang_set_Swedish(char *str);
/* wizard.c */
extern void slice_wizard(struct disk *d);
#endif
/* _SYSINSTALL_H_INCLUDE */

View File

@ -0,0 +1,265 @@
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: tst01.c,v 1.8 1995/05/01 04:05:26 phk Exp $
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <err.h>
#include <sys/types.h>
#include "libdisk.h"
u_char mbr[] = {
250,51,192,142,208,188,0,124,139,244,80,7,80,31,251,252,191,0,6,185,0,1,
242,165,234,29,6,0,0,190,190,7,179,4,128,60,128,116,14,128,60,0,117,28,
131,198,16,254,203,117,239,205,24,139,20,139,76,2,139,238,131,198,16,254,
203,116,26,128,60,0,116,244,190,139,6,172,60,0,116,11,86,187,7,0,180,14,
205,16,94,235,240,235,254,191,5,0,187,0,124,184,1,2,87,205,19,95,115,12,
51,192,205,19,79,117,237,190,163,6,235,211,190,194,6,191,254,125,129,61,
85,170,117,199,139,245,234,0,124,0,0,73,110,118,97,108,105,100,32,112,97,
114,116,105,116,105,111,110,32,116,97,98,108,101,0,69,114,114,111,114,32,
108,111,97,100,105,110,103,32,111,112,101,114,97,116,105,110,103,32,115,
121,115,116,101,109,0,77,105,115,115,105,110,103,32,111,112,101,114,97,
116,105,110,103,32,115,121,115,116,101,109,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,
1,1,0,4,15,63,60,63,0,0,0,241,239,0,0,0,0,1,61,5,15,63,243,48,240,0,0,144,
208,2,0,0,0,1,244,165,15,63,170,192,192,3,0,144,208,2,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,85,170
};
u_char bteasy17[] = {
51,192,142,192,142,216,142,208,188,0,124,252,139,244,191,0,6,185,0,1,242,
165,234,96,6,0,0,139,213,88,162,72,7,60,53,116,28,180,16,246,228,5,174,
4,150,246,68,4,255,116,62,198,4,128,232,218,0,138,116,1,139,76,2,235,8,
232,207,0,185,1,0,50,209,187,0,124,184,1,2,205,19,114,30,129,191,254,1,
85,170,117,22,234,0,124,0,0,128,250,129,116,2,178,128,139,234,66,128,242,
179,136,22,58,7,191,190,7,185,4,0,198,6,45,7,49,50,246,136,45,138,69,4,
60,0,116,35,60,5,116,31,254,198,190,42,7,232,113,0,190,72,7,70,70,139,28,
10,255,116,5,50,125,4,117,243,141,183,114,7,232,90,0,131,199,16,254,6,45,
7,226,203,128,62,117,4,2,116,11,190,59,7,10,246,117,10,205,24,235,172,190,
42,7,232,57,0,232,54,0,50,228,205,26,139,218,131,195,96,180,1,205,22,180,
0,117,11,205,26,59,211,114,242,160,72,7,235,10,205,22,138,196,60,28,116,
243,4,246,60,49,114,214,60,53,119,210,80,190,40,7,187,27,6,83,252,172,80,
36,127,180,14,205,16,88,168,128,116,242,195,86,184,1,3,187,0,6,185,1,0,
50,246,205,19,94,198,6,72,7,63,195,13,138,13,10,70,48,32,46,32,46,32,46,
160,100,105,115,107,32,49,13,10,10,68,101,102,97,117,108,116,58,32,70,63,
160,0,1,0,4,0,6,3,7,7,10,10,99,14,100,14,101,20,128,20,129,25,130,30,147,
36,165,39,159,43,117,47,82,47,219,50,64,55,242,61,0,100,111,243,72,80,70,
211,79,115,178,85,110,105,248,78,111,118,101,108,236,77,105,110,105,248,
76,105,110,117,248,65,109,111,101,98,225,66,83,196,66,83,68,233,80,67,73,
216,67,80,205,86,101,110,105,248,68,111,115,115,101,227,63,191,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,85,170
};
int
scan_block(int fd, daddr_t block)
{
u_char foo[512];
if (-1 == lseek(fd,block * 512,SEEK_SET))
err(1,"lseek");
if (512 != read(fd,foo, 512))
return 1;
return 0;
}
void
Scan_Disk(struct disk *d)
{
char device[64];
u_long l;
int i,j,fd;
strcpy(device,"/dev/r");
strcat(device,d->name);
fd = open(device,O_RDWR);
if (fd < 0) {
warn("open(%s) failed",device);
return;
}
for(i=-1,l=0;;l++) {
j = scan_block(fd,l);
if (j != i) {
if (i == -1) {
printf("%c: %lu.",j ? 'B' : 'G', l);
fflush(stdout);
} else if (i == 0) {
printf(".%lu\nB: %lu.",l-1,l);
fflush(stdout);
} else {
printf(".%lu\nG: %lu.",l-1,l);
fflush(stdout);
}
i = j;
}
}
close(fd);
}
void
slice_wizard(struct disk *d)
{
struct disk *db;
char myprompt[BUFSIZ];
char input[BUFSIZ];
char *p,*q=0;
char **cp,*cmds[200];
int ncmd,i;
sprintf(myprompt,"%s> ", d->name);
while(1) {
printf("--==##==--\n");
Debug_Disk(d);
p = CheckRules(d);
if (p) {
printf("%s",p);
free(p);
}
printf(myprompt);
fflush(stdout);
q = p = fgets(input,sizeof(input),stdin);
if(!p)
break;
for(cp = cmds; (*cp = strsep(&p, " \t\n")) != NULL;)
if (**cp != '\0')
cp++;
ncmd = cp - cmds;
if(!ncmd)
continue;
if (!strcasecmp(*cmds,"quit")) { break; }
if (!strcasecmp(*cmds,"exit")) { break; }
if (!strcasecmp(*cmds,"q")) { break; }
if (!strcasecmp(*cmds,"x")) { break; }
if (!strcasecmp(*cmds,"delete") && ncmd == 2) {
printf("delete = %d\n",
Delete_Chunk(d,
(struct chunk *)strtol(cmds[1],0,0)));
continue;
}
if (!strcasecmp(*cmds,"allfreebsd")) {
All_FreeBSD(d);
continue;
}
if (!strcasecmp(*cmds,"bios") && ncmd == 4) {
Set_Bios_Geom(d,
strtol(cmds[1],0,0),
strtol(cmds[2],0,0),
strtol(cmds[3],0,0));
continue;
}
if (!strcasecmp(*cmds,"phys") && ncmd == 4) {
d = Set_Phys_Geom(d,
strtol(cmds[1],0,0),
strtol(cmds[2],0,0),
strtol(cmds[3],0,0));
continue;
}
if (!strcasecmp(*cmds,"collapse")) {
if (cmds[1])
while (Collapse_Chunk(d,
(struct chunk *)strtol(cmds[1],0,0)))
;
else
Collapse_Disk(d);
continue;
}
if (!strcasecmp(*cmds,"list")) {
cp = Disk_Names();
printf("Disks:");
for(i=0;cp[i];i++) {
printf(" %s",cp[i]);
free(cp[i]);
}
free(cp);
continue;
}
if (!strcasecmp(*cmds,"create") && ncmd == 6) {
printf("Create=%d\n",
Create_Chunk(d,
strtol(cmds[1],0,0),
strtol(cmds[2],0,0),
strtol(cmds[3],0,0),
strtol(cmds[4],0,0),
strtol(cmds[5],0,0)));
continue;
}
if (!strcasecmp(*cmds,"read")) {
db = d;
if (ncmd > 1)
d = Open_Disk(cmds[1]);
else
d = Open_Disk(d->name);
if (d)
Free_Disk(db);
else
d = db;
continue;
}
if (!strcasecmp(*cmds,"scan")) {
Scan_Disk(d);
continue;
}
if (!strcasecmp(*cmds,"bteasy")) {
Set_Boot_Mgr(d,bteasy17);
continue;
}
if (!strcasecmp(*cmds,"mbr")) {
Set_Boot_Mgr(d,mbr);
continue;
}
if (!strcasecmp(*cmds,"boot")) {
extern u_char boot1[],boot2[];
Set_Boot_Blocks(d,boot1,boot2);
continue;
}
if (!strcasecmp(*cmds,"write")) {
printf("Write=%d\n",
Write_Disk(d));
Free_Disk(d);
d = Open_Disk(d->name);
continue;
}
if (strcasecmp(*cmds,"help"))
printf("\007ERROR\n");
printf("CMDS:\n");
printf("allfreebsd\t\t");
printf("bios cyl hd sect\n");
printf("boot\t\t");
printf("bteasy17\n");
printf("collapse [pointer]\t\t");
printf("create offset size enum subtype flags\n");
printf("subtype(part): swap=1, ffs=7\t\t");
printf("delete pointer\n");
printf("list\t\t");
printf("mbr\n");
printf("phys cyl hd sect\t\t");
printf("quit\n");
printf("read [disk]\t\t");
printf("scan\n");
printf("write\t\t");
printf("ENUM:\n\t");
for(i=0;chunk_n[i];i++)
printf("%d = %s%s",i,chunk_n[i],i == 4 ? "\n\t" : " ");
printf("\n");
}
}