diff options
author | jkh <jkh@FreeBSD.org> | 1995-05-08 06:06:30 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1995-05-08 06:06:30 +0000 |
commit | 7440d1ae5c074c0c8ed8018cd10e429b279d8745 (patch) | |
tree | 0f8452edfa4c92d9e7ad62938d4ad2e891ccdbef /usr.sbin | |
parent | 021b1e61da72a756bc8f87b139948c264ab03d85 (diff) | |
download | FreeBSD-src-7440d1ae5c074c0c8ed8018cd10e429b279d8745.zip FreeBSD-src-7440d1ae5c074c0c8ed8018cd10e429b279d8745.tar.gz |
Ok, we should now create all filesystems, mount them and extract the
cpio floppy at this point.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/sade/Makefile | 2 | ||||
-rw-r--r-- | usr.sbin/sade/install.c | 68 | ||||
-rw-r--r-- | usr.sbin/sade/msg.c | 23 | ||||
-rw-r--r-- | usr.sbin/sade/sade.h | 11 | ||||
-rw-r--r-- | usr.sbin/sade/system.c | 5 | ||||
-rw-r--r-- | usr.sbin/sade/termcap.c | 6 | ||||
-rw-r--r-- | usr.sbin/sysinstall/Makefile | 2 | ||||
-rw-r--r-- | usr.sbin/sysinstall/install.c | 68 | ||||
-rw-r--r-- | usr.sbin/sysinstall/msg.c | 23 | ||||
-rw-r--r-- | usr.sbin/sysinstall/sysinstall.h | 11 | ||||
-rw-r--r-- | usr.sbin/sysinstall/system.c | 5 | ||||
-rw-r--r-- | usr.sbin/sysinstall/termcap.c | 6 |
12 files changed, 188 insertions, 42 deletions
diff --git a/usr.sbin/sade/Makefile b/usr.sbin/sade/Makefile index 2a206eb..4aa36cc 100644 --- a/usr.sbin/sade/Makefile +++ b/usr.sbin/sade/Makefile @@ -8,7 +8,7 @@ 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 wizard.c \ - disks.c + disks.c command.c CFLAGS += -Wall -g -I${.CURDIR}/../libdisk diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c index a96a3ee..8f1ad5e 100644 --- a/usr.sbin/sade/install.c +++ b/usr.sbin/sade/install.c @@ -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.9 1995/05/06 09:34:18 jkh Exp $ + * $Id: install.c,v 1.10 1995/05/07 23:37:33 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -42,7 +42,10 @@ */ #include "sysinstall.h" -#include<sys/disklabel.h> +#include <sys/disklabel.h> +#include <sys/errno.h> +#include <sys/fcntl.h> +#include <unistd.h> Boolean SystemWasInstalled; @@ -86,7 +89,7 @@ installHook(char *str) if (!write_disks(disks)) { make_filesystems(disks); - cpio_extract(disks); + cpio_extract(); extract_dists(disks); install_configuration_files(disks); do_final_setup(disks); @@ -156,6 +159,7 @@ make_filesystems(struct disk **disks) { int i; + command_clear(); for (i = 0; disks[i]; i++) { struct chunk *c1; @@ -168,21 +172,69 @@ make_filesystems(struct disk **disks) while (c2) { if (c2->type == part && c2->subtype != FS_SWAP && - c2->private && ((PartInfo *)c2->private)->newfs) - vsystem("%s %s", ((PartInfo *)c2->private)->newfs_cmd, - c2->name); + c2->private) { + PartInfo *tmp = (PartInfo *)c2->private; + + if (tmp->newfs) + command_add(tmp->mountpoint, + "%s %s", tmp->newfs_cmd, c2->name); + command_add(tmp->mountpoint, + "mkdir -p /mnt/%s", tmp->mountpoint); + command_add(tmp->mountpoint, + "mount /mnt/dev/%s /mnt/%s", c2->name, + tmp->mountpoint); + } c2 = c2->next; } } c1 = c1->next; } } + command_sort(); + command_execute(); } void -cpio_extract(struct disk **disks) +cpio_extract(void) { - + int i, j, zpid, cpid, pfd[2]; + + while (CpioFD == -1) { + msgConfirm("Please Insert CPIO floppy in floppy drive 0"); + CpioFD = open("/dev/rfd0", O_RDONLY); + } + msgNotify("Extracting contents of CPIO floppy."); + pipe(pfd); + zpid = fork(); + if (!zpid) { + close(0); dup(CpioFD); close(CpioFD); + close(1); dup(pfd[1]); close(pfd[1]); + close(pfd[0]); + i = execl("/stand/gunzip", "/stand/gunzip", 0); + msgDebug("/stand/gunzip command returns %d status\n", i); + exit(i); + } + cpid = fork(); + if (!cpid) { + close(0); dup(pfd[0]); close(pfd[0]); + close(CpioFD); + close(pfd[1]); + close(1); open("/dev/null", O_WRONLY); + i = execl("/stand/cpio", "/stand/cpio", "-iduvm", 0); + msgDebug("/stand/cpio command returns %d status\n", i); + exit(i); + } + close(pfd[0]); + close(pfd[1]); + close(CpioFD); + i = wait(&j); + if (i < 0 || j) + msgFatal("Pid %d, status %d, cpio=%d, gunzip=%d.\nerror:%s", + i, j, cpid, zpid, strerror(errno)); + i = wait(&j); + if (i < 0 || j) + msgFatal("Pid %d, status %d, cpio=%d, gunzip=%d.\nerror:%s", + i, j, cpid, zpid, strerror(errno)); } void diff --git a/usr.sbin/sade/msg.c b/usr.sbin/sade/msg.c index 70cf576..d8dc84b 100644 --- a/usr.sbin/sade/msg.c +++ b/usr.sbin/sade/msg.c @@ -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.7 1995/05/07 03:38:01 jkh Exp $ + * $Id: msg.c,v 1.8 1995/05/07 05:58:57 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -53,9 +53,8 @@ msgYap(char *fmt, ...) int attrs; errstr = (char *)safe_malloc(FILENAME_MAX); - errstr[0] = '\0'; va_start(args, fmt); - vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); + vsnprintf(errstr, FILENAME_MAX, fmt, args); va_end(args); attrs = getattrs(stdscr); attrset(A_REVERSE); @@ -74,9 +73,8 @@ msgInfo(char *fmt, ...) int attrs; errstr = (char *)safe_malloc(FILENAME_MAX); - errstr[0] = '\0'; va_start(args, fmt); - vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); + vsnprintf(errstr, FILENAME_MAX, fmt, args); va_end(args); attrs = getattrs(stdscr); attrset(A_NORMAL); @@ -240,3 +238,18 @@ msgGetInput(char *buf, char *fmt, ...) return NULL; } +/* Write something to the debugging port */ +void +msgDebug(char *fmt, ...) +{ + va_list args; + char *dbg; + + dbg = (char *)safe_malloc(FILENAME_MAX); + strcpy(dbg, "DEBUG: "); + va_start(args, fmt); + vsnprintf((char *)(dbg + strlen(dbg)), FILENAME_MAX, fmt, args); + va_end(args); + write(DebugFD, dbg, strlen(dbg)); + free(dbg); +} diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h index 68698a1..fad3398 100644 --- a/usr.sbin/sade/sade.h +++ b/usr.sbin/sade/sade.h @@ -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.10 1995/05/07 02:04:29 jkh Exp $ + * $Id: sysinstall.h,v 1.11 1995/05/07 23:37:34 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -203,6 +203,12 @@ extern unsigned int SrcDists; /* Which src distributions we want */ /*** Prototypes ***/ +/* command.c */ +extern void command_clear(void); +extern void command_sort(void); +extern void command_execute(void); +extern void command_add(char *key, char *fmt, ...); + /* globals.c */ extern void globalsInit(void); @@ -238,7 +244,7 @@ extern int vsystem(char *fmt, ...); extern void partition_disks(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 cpio_extract(void); extern void extract_dists(struct disk **disks); extern void install_configuration_files(struct disk **disks); extern void do_final_setup(struct disk **disks); @@ -267,6 +273,7 @@ extern int set_termcap(void); extern void msgInfo(char *fmt, ...); extern void msgYap(char *fmt, ...); extern void msgWarn(char *fmt, ...); +extern void msgDebug(char *fmt, ...); extern void msgError(char *fmt, ...); extern void msgFatal(char *fmt, ...); extern void msgConfirm(char *fmt, ...); diff --git a/usr.sbin/sade/system.c b/usr.sbin/sade/system.c index d7783c2..4f1c643 100644 --- a/usr.sbin/sade/system.c +++ b/usr.sbin/sade/system.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: system.c,v 1.6 1995/05/06 09:34:22 jkh Exp $ + * $Id: system.c,v 1.7 1995/05/07 03:38:03 jkh Exp $ * * Jordan Hubbard * @@ -269,10 +269,11 @@ vsystem(char *fmt, ...) cmd = (char *)malloc(FILENAME_MAX); cmd[0] = '\0'; va_start(args, fmt); - vsnprintf((char *)(cmd + strlen(cmd)), FILENAME_MAX, fmt, args); + vsnprintf(cmd, FILENAME_MAX, fmt, args); va_end(args); msgNotify("Executing command: %s", cmd); i = system(cmd); + msgDebug("Command `%s' returns status of %d\n", cmd, i); free(cmd); return i; } diff --git a/usr.sbin/sade/termcap.c b/usr.sbin/sade/termcap.c index 8b2a5f9..86e758a 100644 --- a/usr.sbin/sade/termcap.c +++ b/usr.sbin/sade/termcap.c @@ -42,19 +42,19 @@ set_termcap(void) return -1; if (setenv("TERMCAP", termcap_cons25, 1) < 0) return -1; - DebugFD = open("/dev/ttyv1",O_WRONLY); + DebugFD = open("/dev/ttyv1", O_WRONLY); OnVTY = TRUE; } else { if (setenv("TERM", "cons25-m", 1) < 0) return -1; if (setenv("TERMCAP", termcap_cons25_m, 1) < 0) return -1; - DebugFD = open("/dev/ttyv1",O_WRONLY); + DebugFD = open("/dev/ttyv1", O_WRONLY); OnVTY = TRUE; } } else { - DebugFD = open("sysinstall.debug", O_WRONLY|O_CREAT|O_TRUNC,0644); + DebugFD = open("sysinstall.debug", O_WRONLY|O_CREAT|O_TRUNC, 0644); } return 0; } diff --git a/usr.sbin/sysinstall/Makefile b/usr.sbin/sysinstall/Makefile index 2a206eb..4aa36cc 100644 --- a/usr.sbin/sysinstall/Makefile +++ b/usr.sbin/sysinstall/Makefile @@ -8,7 +8,7 @@ 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 wizard.c \ - disks.c + disks.c command.c CFLAGS += -Wall -g -I${.CURDIR}/../libdisk diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c index a96a3ee..8f1ad5e 100644 --- a/usr.sbin/sysinstall/install.c +++ b/usr.sbin/sysinstall/install.c @@ -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.9 1995/05/06 09:34:18 jkh Exp $ + * $Id: install.c,v 1.10 1995/05/07 23:37:33 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -42,7 +42,10 @@ */ #include "sysinstall.h" -#include<sys/disklabel.h> +#include <sys/disklabel.h> +#include <sys/errno.h> +#include <sys/fcntl.h> +#include <unistd.h> Boolean SystemWasInstalled; @@ -86,7 +89,7 @@ installHook(char *str) if (!write_disks(disks)) { make_filesystems(disks); - cpio_extract(disks); + cpio_extract(); extract_dists(disks); install_configuration_files(disks); do_final_setup(disks); @@ -156,6 +159,7 @@ make_filesystems(struct disk **disks) { int i; + command_clear(); for (i = 0; disks[i]; i++) { struct chunk *c1; @@ -168,21 +172,69 @@ make_filesystems(struct disk **disks) while (c2) { if (c2->type == part && c2->subtype != FS_SWAP && - c2->private && ((PartInfo *)c2->private)->newfs) - vsystem("%s %s", ((PartInfo *)c2->private)->newfs_cmd, - c2->name); + c2->private) { + PartInfo *tmp = (PartInfo *)c2->private; + + if (tmp->newfs) + command_add(tmp->mountpoint, + "%s %s", tmp->newfs_cmd, c2->name); + command_add(tmp->mountpoint, + "mkdir -p /mnt/%s", tmp->mountpoint); + command_add(tmp->mountpoint, + "mount /mnt/dev/%s /mnt/%s", c2->name, + tmp->mountpoint); + } c2 = c2->next; } } c1 = c1->next; } } + command_sort(); + command_execute(); } void -cpio_extract(struct disk **disks) +cpio_extract(void) { - + int i, j, zpid, cpid, pfd[2]; + + while (CpioFD == -1) { + msgConfirm("Please Insert CPIO floppy in floppy drive 0"); + CpioFD = open("/dev/rfd0", O_RDONLY); + } + msgNotify("Extracting contents of CPIO floppy."); + pipe(pfd); + zpid = fork(); + if (!zpid) { + close(0); dup(CpioFD); close(CpioFD); + close(1); dup(pfd[1]); close(pfd[1]); + close(pfd[0]); + i = execl("/stand/gunzip", "/stand/gunzip", 0); + msgDebug("/stand/gunzip command returns %d status\n", i); + exit(i); + } + cpid = fork(); + if (!cpid) { + close(0); dup(pfd[0]); close(pfd[0]); + close(CpioFD); + close(pfd[1]); + close(1); open("/dev/null", O_WRONLY); + i = execl("/stand/cpio", "/stand/cpio", "-iduvm", 0); + msgDebug("/stand/cpio command returns %d status\n", i); + exit(i); + } + close(pfd[0]); + close(pfd[1]); + close(CpioFD); + i = wait(&j); + if (i < 0 || j) + msgFatal("Pid %d, status %d, cpio=%d, gunzip=%d.\nerror:%s", + i, j, cpid, zpid, strerror(errno)); + i = wait(&j); + if (i < 0 || j) + msgFatal("Pid %d, status %d, cpio=%d, gunzip=%d.\nerror:%s", + i, j, cpid, zpid, strerror(errno)); } void diff --git a/usr.sbin/sysinstall/msg.c b/usr.sbin/sysinstall/msg.c index 70cf576..d8dc84b 100644 --- a/usr.sbin/sysinstall/msg.c +++ b/usr.sbin/sysinstall/msg.c @@ -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.7 1995/05/07 03:38:01 jkh Exp $ + * $Id: msg.c,v 1.8 1995/05/07 05:58:57 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -53,9 +53,8 @@ msgYap(char *fmt, ...) int attrs; errstr = (char *)safe_malloc(FILENAME_MAX); - errstr[0] = '\0'; va_start(args, fmt); - vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); + vsnprintf(errstr, FILENAME_MAX, fmt, args); va_end(args); attrs = getattrs(stdscr); attrset(A_REVERSE); @@ -74,9 +73,8 @@ msgInfo(char *fmt, ...) int attrs; errstr = (char *)safe_malloc(FILENAME_MAX); - errstr[0] = '\0'; va_start(args, fmt); - vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); + vsnprintf(errstr, FILENAME_MAX, fmt, args); va_end(args); attrs = getattrs(stdscr); attrset(A_NORMAL); @@ -240,3 +238,18 @@ msgGetInput(char *buf, char *fmt, ...) return NULL; } +/* Write something to the debugging port */ +void +msgDebug(char *fmt, ...) +{ + va_list args; + char *dbg; + + dbg = (char *)safe_malloc(FILENAME_MAX); + strcpy(dbg, "DEBUG: "); + va_start(args, fmt); + vsnprintf((char *)(dbg + strlen(dbg)), FILENAME_MAX, fmt, args); + va_end(args); + write(DebugFD, dbg, strlen(dbg)); + free(dbg); +} diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h index 68698a1..fad3398 100644 --- a/usr.sbin/sysinstall/sysinstall.h +++ b/usr.sbin/sysinstall/sysinstall.h @@ -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.10 1995/05/07 02:04:29 jkh Exp $ + * $Id: sysinstall.h,v 1.11 1995/05/07 23:37:34 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -203,6 +203,12 @@ extern unsigned int SrcDists; /* Which src distributions we want */ /*** Prototypes ***/ +/* command.c */ +extern void command_clear(void); +extern void command_sort(void); +extern void command_execute(void); +extern void command_add(char *key, char *fmt, ...); + /* globals.c */ extern void globalsInit(void); @@ -238,7 +244,7 @@ extern int vsystem(char *fmt, ...); extern void partition_disks(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 cpio_extract(void); extern void extract_dists(struct disk **disks); extern void install_configuration_files(struct disk **disks); extern void do_final_setup(struct disk **disks); @@ -267,6 +273,7 @@ extern int set_termcap(void); extern void msgInfo(char *fmt, ...); extern void msgYap(char *fmt, ...); extern void msgWarn(char *fmt, ...); +extern void msgDebug(char *fmt, ...); extern void msgError(char *fmt, ...); extern void msgFatal(char *fmt, ...); extern void msgConfirm(char *fmt, ...); diff --git a/usr.sbin/sysinstall/system.c b/usr.sbin/sysinstall/system.c index d7783c2..4f1c643 100644 --- a/usr.sbin/sysinstall/system.c +++ b/usr.sbin/sysinstall/system.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: system.c,v 1.6 1995/05/06 09:34:22 jkh Exp $ + * $Id: system.c,v 1.7 1995/05/07 03:38:03 jkh Exp $ * * Jordan Hubbard * @@ -269,10 +269,11 @@ vsystem(char *fmt, ...) cmd = (char *)malloc(FILENAME_MAX); cmd[0] = '\0'; va_start(args, fmt); - vsnprintf((char *)(cmd + strlen(cmd)), FILENAME_MAX, fmt, args); + vsnprintf(cmd, FILENAME_MAX, fmt, args); va_end(args); msgNotify("Executing command: %s", cmd); i = system(cmd); + msgDebug("Command `%s' returns status of %d\n", cmd, i); free(cmd); return i; } diff --git a/usr.sbin/sysinstall/termcap.c b/usr.sbin/sysinstall/termcap.c index 8b2a5f9..86e758a 100644 --- a/usr.sbin/sysinstall/termcap.c +++ b/usr.sbin/sysinstall/termcap.c @@ -42,19 +42,19 @@ set_termcap(void) return -1; if (setenv("TERMCAP", termcap_cons25, 1) < 0) return -1; - DebugFD = open("/dev/ttyv1",O_WRONLY); + DebugFD = open("/dev/ttyv1", O_WRONLY); OnVTY = TRUE; } else { if (setenv("TERM", "cons25-m", 1) < 0) return -1; if (setenv("TERMCAP", termcap_cons25_m, 1) < 0) return -1; - DebugFD = open("/dev/ttyv1",O_WRONLY); + DebugFD = open("/dev/ttyv1", O_WRONLY); OnVTY = TRUE; } } else { - DebugFD = open("sysinstall.debug", O_WRONLY|O_CREAT|O_TRUNC,0644); + DebugFD = open("sysinstall.debug", O_WRONLY|O_CREAT|O_TRUNC, 0644); } return 0; } |