Fixed to make sysinstall work again. Notable changes:

Removed a dialog_clear() which somebody aimlessly had slammed into TellEm()
in absence of any understanding of the structure of this program. :-(

Skip through stage0 for now.

Make write_bootblocks write the disklabel using the kernel-call, and forget
about the boot-blocks for now.  This is wrong, but I havn't found the real
problem yet.  I will continue work on this problem.

Added a Debug-feature.  There is a printf' like Debug() now which sends its
output to ttyv1 (Alt-F2), and all "discarded output" from sub-processes end
up there too.  Made TellEm() put it's messages there also, so that we can
see where what happens.

Set the PATH for the shell we shouldn't start at the end :-)

set "npartitions" after the disklabel-editor returns, so that we actually
can edit all the 8 parts of the label.
This commit is contained in:
Poul-Henning Kamp 1994-10-29 10:01:40 +00:00
parent e2247bbffd
commit aa7d974a35
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=3987
11 changed files with 71 additions and 30 deletions

View File

@ -54,11 +54,11 @@ disable_label(int fd)
int
write_bootblocks(int fd, off_t offset, int bbsize)
{
if (ioctl(fd, DIOCSDINFO, &avail_disklabels[inst_disk]) < 0 &&
errno != ENODEV && errno != ENOTTY) {
sprintf(errmsg, "Failed to change in-core disklabel\n");
if (ioctl(fd, DIOCWDINFO, &avail_disklabels[inst_disk]) < 0) {
Fatal("Failed to write disklabel: %s\n", strerror(errno));
return(-1);
}
return(0);
if (lseek(fd, (offset * avail_disklabels[inst_disk].d_secsize), SEEK_SET) < 0) {
sprintf(errmsg, "Couldn't seek to start of partition\n");
@ -69,7 +69,10 @@ write_bootblocks(int fd, off_t offset, int bbsize)
return(-1);
if (write(fd, bootblocks, bbsize) != bbsize) {
sprintf(errmsg, "Failed to write bootblocks\n");
sprintf(errmsg, "Failed to write bootblocks (%p) %d %s\n",
bootblocks,
errno, strerror(errno)
);
return(-1);
}

View File

@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: exec.c,v 1.2 1994/10/21 05:36:42 phk Exp $
* $Id: exec.c,v 1.4 1994/10/26 05:40:59 phk Exp $
*
*/
@ -52,14 +52,17 @@ exec(int magic, char *cmd, char *args, ...)
if ((pid = fork()) == 0) {
switch (magic) {
case 0:
close(0); open("/dev/null",O_RDONLY);
close(1); open("/dev/null",O_WRONLY);
close(2); open("/dev/null",O_WRONLY);
close(0); dup(debug_fd);
close(1); dup(debug_fd);
close(2); dup(debug_fd);
close(debug_fd);
break;
case 1:
close(2); open("/dev/null",O_WRONLY);
close(2); dup(debug_fd);
close(debug_fd);
break;
case 2:
close(debug_fd);
default:
break;
}

View File

@ -418,13 +418,22 @@ build_disklabel(struct disklabel *lbl)
nsects = Mbtosects(atoi(label_fields[i][UPARTSIZES].field),
lbl->d_secsize);
nsects = rndtocylbdry(nsects, lbl->d_secpercyl);
offset = rndtocylbdry(offset, lbl->d_secpercyl);
lbl->d_partitions[i].p_size = nsects;
lbl->d_partitions[i].p_offset = offset;
offset += nsects;
total_sects += nsects;
lbl->d_partitions[i].p_fstype =
getfstype(label_fields[i][FSTYPE].field);
if(nsects) {
offset = rndtocylbdry(offset, lbl->d_secpercyl);
lbl->d_partitions[i].p_size = nsects;
lbl->d_partitions[i].p_offset = offset;
Debug("Part%d: %d sects, %d offset, %d end",
i,nsects,offset,nsects+offset);
offset += nsects;
total_sects += nsects;
lbl->d_partitions[i].p_fstype =
getfstype(label_fields[i][FSTYPE].field);
lbl->d_npartitions = i+1;
} else {
lbl->d_partitions[i].p_size = 0;
lbl->d_partitions[i].p_offset = 0;
lbl->d_partitions[i].p_fstype = 0;
}
}
}
}

View File

@ -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.7 1994/10/24 03:30:55 paul Exp $
* $Id: main.c,v 1.8 1994/10/26 02:53:09 phk Exp $
*
*/
@ -73,11 +73,12 @@ main(int argc, char **argv)
close(0); open("/dev/console",O_RDWR);
close(1); dup(0);
close(2); dup(0);
printf("sysinstall running as init\n\r");
i = 1;
ioctl(0,TIOCSPGRP,&i);
setlogin("root");
}
debug_fd = open("/dev/ttyv1",O_WRONLY);
if (set_termcap() == -1) {
Fatal("Can't find terminal entry\n");
}

View File

@ -32,10 +32,17 @@ static char *welcome[] = {
"Exit to shell.",
};
void stage0()
void
stage0()
{
int valid = 0;
if (!access(README_FILE, R_OK)) {
dialog_clear();
dialog_textbox("READ ME FIRST", README_FILE, 24, 80);
}
return;
do {
if (!dialog_menu("Welcome to FreeBSD!",
"Please select one of the following options.\n",

View File

@ -305,6 +305,7 @@ stage1()
dialog_msgbox(TITLE, "This is an experimental disklabel configuration\nmenu. It doesn't perform any validation of the entries\nas yet so BE SURE YOU TYPE THINGS CORRECTLY.\n\n Hit escape to quit the editor.\n\nThere may be some delay exiting because of a dialog bug", 20,70,1);
dialog_clear();
edit_disklabel(&avail_disklabels[inst_disk]);
build_disklabel(&avail_disklabels[inst_disk]);
if (build_bootblocks(&avail_disklabels[inst_disk]) == -1)
Fatal(errmsg);

View File

@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: stage3.c,v 1.4 1994/10/21 02:14:52 phk Exp $
* $Id: stage4.c,v 1.2 1994/10/26 05:41:01 phk Exp $
*
*/
@ -60,7 +60,7 @@ stage4()
close(pfd[1]);
close(1); open("/dev/null",O_WRONLY);
chdir("/stand");
i = exec (1,"/stand/cpio","/stand/cpio","-idum", 0);
i = exec (1,"/stand/cpio","/stand/cpio","-iduvm", 0);
exit(i);
}
close(pfd[0]);

View File

@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: stage3.c,v 1.4 1994/10/21 02:14:52 phk Exp $
* $Id: stage5.c,v 1.2 1994/10/26 05:41:02 phk Exp $
*
*/
@ -29,6 +29,7 @@ stage5()
{
end_dialog();
dialog_active=0;
setenv("PATH","/stand",1);
for(;;)
exec (2,"/stand/sh","/stand/-sh", 0);
}

View File

@ -17,9 +17,6 @@
#define BOOT1 "/stand/sdboot"
#define BOOT2 "/stand/bootsd"
#define BOOT1 "/stand/sdboot"
#define BOOT2 "/stand/bootsd"
#define MAXFS 25
#define MAX_NO_DISKS 10
@ -45,6 +42,7 @@ EXTERN char *devicename[MAXFS+1];
EXTERN char *mountpoint[MAXFS+1];
EXTERN int dialog_active;
EXTERN char selection[];
EXTERN int debug_fd;
extern unsigned char **avail_disknames;
extern int no_disks;
@ -57,9 +55,10 @@ extern struct disklabel *avail_disklabels;
extern u_short dkcksum(struct disklabel *);
/* utils.c */
void Abort __P((void));
void ExitSysinstall __P((void));
void Abort __P((void));
void ExitSysinstall __P((void));
void TellEm __P((char *fmt, ...));
void Debug __P((char *fmt, ...));
void stage0 __P((void));
void *Malloc __P((size_t size));
char *StrAlloc __P((char *str));

View File

@ -70,7 +70,7 @@ set_termcap()
if (access("/etc/termcap.small",R_OK)) {
no_termcap = 1;
} else if (setenv("TERMCAP", "/etc/termcap.small", 1) < 0)
return -1;
no_termcap = 1;
if (ioctl(STDERR_FILENO, GIO_COLOR, &color_display) < 0) {
char buf[64];

View File

@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: utils.c,v 1.11 1994/10/24 03:55:25 ache Exp $
* $Id: utils.c,v 1.12 1994/10/26 02:53:15 phk Exp $
*
*/
@ -28,6 +28,21 @@
#include "sysinstall.h"
void
Debug(char *fmt, ...)
{
char *p;
va_list ap;
p = Malloc(2048);
va_start(ap,fmt);
vsnprintf(p, 2048, fmt, ap);
va_end(ap);
write(debug_fd,"Debug <",7);
write(debug_fd,p,strlen(p));
write(debug_fd,">\n\r",3);
free(p);
}
void
TellEm(char *fmt, ...)
{
@ -37,8 +52,10 @@ TellEm(char *fmt, ...)
va_start(ap,fmt);
vsnprintf(p, 2048, fmt, ap);
va_end(ap);
write(debug_fd,"Progress <",10);
write(debug_fd,p,strlen(p));
write(debug_fd,">\n\r",3);
dialog_msgbox("Progress", p, 3, 75, 0);
dialog_clear();
free(p);
}