diff options
author | phk <phk@FreeBSD.org> | 1995-05-27 23:39:35 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1995-05-27 23:39:35 +0000 |
commit | 46125ba2eddf1b1eea2607293277346e29ee2af9 (patch) | |
tree | 291cad597f17930adf43e6eedc0bc0f9042e1b66 | |
parent | ca8242ab1848c07abea376675ce3ec0c8a437cc8 (diff) | |
download | FreeBSD-src-46125ba2eddf1b1eea2607293277346e29ee2af9.zip FreeBSD-src-46125ba2eddf1b1eea2607293277346e29ee2af9.tar.gz |
Major cleanup. Mediaroutines now get asked about a file. All the
multi part stuff centralized.
The final check is backwards or something so it always said it failed,
even it it didn't.
Fixed tcpip address check to not be stupid, 10.0.255.1 is legal.
-rw-r--r-- | release/sysinstall/cdrom.c | 35 | ||||
-rw-r--r-- | release/sysinstall/dist.c | 126 | ||||
-rw-r--r-- | release/sysinstall/dos.c | 20 | ||||
-rw-r--r-- | release/sysinstall/floppy.c | 23 | ||||
-rw-r--r-- | release/sysinstall/ftp_strat.c | 113 | ||||
-rw-r--r-- | release/sysinstall/install.c | 14 | ||||
-rw-r--r-- | release/sysinstall/media.c | 78 | ||||
-rw-r--r-- | release/sysinstall/sysinstall.h | 20 | ||||
-rw-r--r-- | release/sysinstall/tape.c | 4 | ||||
-rw-r--r-- | release/sysinstall/tcpip.c | 4 | ||||
-rw-r--r-- | release/sysinstall/ufs.c | 4 | ||||
-rw-r--r-- | usr.sbin/sade/install.c | 14 | ||||
-rw-r--r-- | usr.sbin/sade/sade.h | 20 | ||||
-rw-r--r-- | usr.sbin/sysinstall/cdrom.c | 35 | ||||
-rw-r--r-- | usr.sbin/sysinstall/dist.c | 126 | ||||
-rw-r--r-- | usr.sbin/sysinstall/dos.c | 20 | ||||
-rw-r--r-- | usr.sbin/sysinstall/floppy.c | 23 | ||||
-rw-r--r-- | usr.sbin/sysinstall/install.c | 14 | ||||
-rw-r--r-- | usr.sbin/sysinstall/media.c | 78 | ||||
-rw-r--r-- | usr.sbin/sysinstall/sysinstall.h | 20 | ||||
-rw-r--r-- | usr.sbin/sysinstall/tape.c | 4 | ||||
-rw-r--r-- | usr.sbin/sysinstall/tcpip.c | 4 | ||||
-rw-r--r-- | usr.sbin/sysinstall/ufs.c | 4 |
23 files changed, 464 insertions, 339 deletions
diff --git a/release/sysinstall/cdrom.c b/release/sysinstall/cdrom.c index 3152bf0..095cc19 100644 --- a/release/sysinstall/cdrom.c +++ b/release/sysinstall/cdrom.c @@ -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: media_strategy.c,v 1.28 1995/05/26 20:30:59 jkh Exp $ + * $Id: cdrom.c,v 1.1 1995/05/27 10:38:45 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -57,6 +57,7 @@ #include <sys/wait.h> #include <unistd.h> #include <grp.h> +#include <fcntl.h> #define CD9660 #include <sys/mount.h> @@ -102,45 +103,19 @@ mediaInitCDROM(Device *dev) } int -mediaGetCDROM(char *dist, char *path) +mediaGetCDROM(char *file) { char buf[PATH_MAX]; - Attribs *dist_attr; - int retval; - dist_attr = safe_malloc(sizeof(Attribs) * MAX_ATTRIBS); - - snprintf(buf, PATH_MAX, "/stand/info/%s.inf", dist); - - if (!access(buf, R_OK) && attr_parse(&dist_attr, buf) == 0) { - msgConfirm("Cannot load information file for %s distribution!\nPlease verify that your media is valid and try again.", dist); - free(dist_attr); - return FALSE; - } - - snprintf(buf, PATH_MAX, "/cdrom/%s%s", path ? path : "", dist); - retval = genericGetDist(buf, dist_attr, FALSE); - free(dist_attr); - return retval; + snprintf(buf, PATH_MAX, "/cdrom/%s", file); + return open(buf,O_RDONLY); } void mediaShutdownCDROM(Device *dev) { - extern int getDistpid; - if (!cdromMounted) return; - if (getDistpid) { - int i, j; - - i = waitpid(getDistpid, &j, 0); - if (i < 0 || WEXITSTATUS(j)) { - msgConfirm("Warning: Last extraction returned status code %d.", WEXITSTATUS(j)); - getDistpid = 0; - } - getDistpid = 0; - } msgDebug("Unmounting /cdrom\n"); if (unmount("/cdrom", 0) != 0) msgConfirm("Could not unmount the CDROM: %s\n", strerror(errno)); diff --git a/release/sysinstall/dist.c b/release/sysinstall/dist.c index 9b70bb6..799782b 100644 --- a/release/sysinstall/dist.c +++ b/release/sysinstall/dist.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: dist.c,v 1.25 1995/05/26 22:22:20 jkh Exp $ + * $Id: dist.c,v 1.26 1995/05/27 10:47:30 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -222,41 +222,123 @@ static int distExtract(char *parent, Distribution *me) { int i, status; - int fd; + int cpid, zpid, fd, fd2, chunk, numchunks; + char dparent[FILENAME_MAX], *path, *dist, buf[10240]; + const char *tmp; + Attribs *dist_attr; status = 0; if (mediaDevice->init) if (!(*mediaDevice->init)(mediaDevice)) return 0; for (i = 0; me[i].my_name; i++) { - if (me[i].my_bit & *(me[i].my_mask)) { - if (me[i].my_dist) - status = distExtract(me[i].my_name, me[i].my_dist); - else { - char dparent[FILENAME_MAX]; - - snprintf(dparent, FILENAME_MAX, "%s/", parent ? parent : me[i].my_name); - fd = (*mediaDevice->get)(me[i].my_name, dparent); - if (fd != -1) { + + /* If we're not doing it, we're not doing it */ + if (!(me[i].my_bit & *(me[i].my_mask))) + continue; + + /* Recurse if we think thats more fun */ + if (me[i].my_dist) { + status = distExtract(me[i].my_name, me[i].my_dist); + goto done; + } + + snprintf(dparent, FILENAME_MAX, "%s/", parent ? parent : me[i].my_name); + dist = me[i].my_name; + path = dparent ? dparent : ""; + + snprintf(buf, 512, "%s%s.tgz", path, dist); + fd = (*mediaDevice->get)(buf); + if (fd != -1) { + status = mediaExtractDist(me[i].my_name, me[i].my_dir, fd); + if (mediaDevice->close) + (*mediaDevice->close)(mediaDevice, fd); + else + close(fd); + goto done; + } + + snprintf(buf, sizeof buf, "/stand/info/%s%s.inf", path, dist); + if (!access(buf, R_OK)) { + msgDebug("Parsing attributes file for %s\n", dist); + dist_attr = safe_malloc(sizeof(Attribs) * MAX_ATTRIBS); + if (attr_parse(&dist_attr, buf) == 0) { + msgConfirm("Cannot load information file for %s distribution!\nPlease verify that your media is valid and try again.", dist); + return -1; + } + + msgDebug("Looking for attribute `pieces'\n"); + tmp = attr_match(dist_attr, "pieces"); + numchunks = atoi(tmp); + } else + numchunks = 0; + + msgDebug("Attempting to extract distribution from %u chunks.\n", + numchunks); + + if (numchunks < 2 ) { + snprintf(buf, 512, "%s%s", path, dist); + if (numchunks) + strcat(buf,".aa"); + fd = (*mediaDevice->get)(buf); + if (fd == -1) { + status = 1; + } else { status = mediaExtractDist(me[i].my_name, me[i].my_dir, fd); if (mediaDevice->close) (*mediaDevice->close)(mediaDevice, fd); else close(fd); - } - else { - if (getenv(NO_CONFIRMATION)) - status = 0; - else - status = !msgYesNo("Unable to transfer the %s distribution from %s.\nDo you want to retry this distribution later?", me[i].my_name, mediaDevice->name); - } } - if (!status) { - /* Extract was successful, remove ourselves from further consideration */ - *(me[i].my_mask) &= ~(me[i].my_bit); + goto done; + } + + mediaExtractDistBegin(dist, me[i].my_dir, &fd2, &zpid, &cpid); + for (chunk = 0; chunk < numchunks; chunk++) { + int n, retval; + + snprintf(buf, 512, "%s%s.%c%c", path, dist, + (chunk / 26) + 'a', (chunk % 26) + 'a'); + fd = (*mediaDevice->get)(buf); + + if (fd < 0) + { + msgConfirm("FtpGet failed to retreive piece `%s' in the %s distribution!\nAborting the transfer", chunk, dist); + goto punt; } + while ((n = read(fd, buf, sizeof buf)) > 0) { + retval = write(fd2, buf, n); + if (retval != n) + { + if (mediaDevice->close) + (*mediaDevice->close)(mediaDevice, fd); + msgConfirm("Write failure on transfer! (wrote %d bytes of %d bytes)", retval, n); + goto punt; + } + } + if (mediaDevice->close) + (*mediaDevice->close)(mediaDevice, fd); } - } + close(fd2); + status = mediaExtractDistEnd(zpid,cpid); + goto done; + + punt: + close(fd2); + mediaExtractDistEnd(zpid,cpid); + status = 1; + done: + if (status) { + if (getenv(NO_CONFIRMATION)) + status = 0; + else + status = !msgYesNo("Unable to transfer the %s distribution from %s.\nDo you want to retry this distribution later?", me[i].my_name, mediaDevice->name); + } + if (!status) { + /* Extract was successful, remove ourselves from further consideration */ + *(me[i].my_mask) &= ~(me[i].my_bit); + } +} if (mediaDevice->shutdown && parent == NULL) { (*mediaDevice->shutdown)(mediaDevice); mediaDevice = NULL; diff --git a/release/sysinstall/dos.c b/release/sysinstall/dos.c index a8d1a85..d3999c5 100644 --- a/release/sysinstall/dos.c +++ b/release/sysinstall/dos.c @@ -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: media_strategy.c,v 1.28 1995/05/26 20:30:59 jkh Exp $ + * $Id: dos.c,v 1.1 1995/05/27 10:38:47 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -49,6 +49,7 @@ #include <sys/param.h> #include <sys/wait.h> #include <unistd.h> +#include <fcntl.h> #include <grp.h> #define MSDOSFS @@ -80,23 +81,12 @@ mediaInitDOS(Device *dev) } int -mediaGetDOS(char *dist, char *path) +mediaGetDOS(char *file) { char buf[PATH_MAX]; - Attribs *dist_attr = NULL; - int retval; - dist_attr = safe_malloc(sizeof(Attribs) * MAX_ATTRIBS); - snprintf(buf, PATH_MAX, "/stand/info/%s.inf", dist); - if (!access(buf, R_OK) && attr_parse(&dist_attr, buf) == 0) { - msgConfirm("Cannot load information file for %s distribution!\nPlease verify that your media is valid and try again.", dist); - free(dist_attr); - return FALSE; - } - snprintf(buf, PATH_MAX, "/dos/%s%s", path ? path : "", dist); - retval = genericGetDist(buf, dist_attr, FALSE); - free(dist_attr); - return retval; + snprintf(buf, PATH_MAX, "/dos/%s", file); + return open(buf,O_RDONLY); } void diff --git a/release/sysinstall/floppy.c b/release/sysinstall/floppy.c index 2c4df0b..a2a1212 100644 --- a/release/sysinstall/floppy.c +++ b/release/sysinstall/floppy.c @@ -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: media_strategy.c,v 1.28 1995/05/26 20:30:59 jkh Exp $ + * $Id: floppy.c,v 1.1 1995/05/27 10:38:52 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -141,28 +141,13 @@ mediaInitFloppy(Device *dev) } int -mediaGetFloppy(char *dist, char *path) +mediaGetFloppy(char *file) { char buf[PATH_MAX]; - char *fname; - Attribs *dist_attr; - int retval; - dist_attr = safe_malloc(sizeof(Attribs) * MAX_ATTRIBS); + snprintf(buf, PATH_MAX, "/mnt/%s", file); - snprintf(buf, PATH_MAX, "/stand/info/%s.inf", dist); - if (!access(buf, R_OK) && attr_parse(&dist_attr, buf) == 0) - { - msgConfirm("Cannot load information file for %s distribution!\nPlease verify that your media is valid and try again.", dist); - free(dist_attr); - return FALSE; - } - fname = index(dist, '/') + 1; - snprintf(buf, PATH_MAX, "/mnt/%s", fname); - - retval = genericGetDist(buf, dist_attr, TRUE); - free(dist_attr); - return retval; + return open(buf,O_RDONLY); } void diff --git a/release/sysinstall/ftp_strat.c b/release/sysinstall/ftp_strat.c index 7fbfe25..19c4ac3 100644 --- a/release/sysinstall/ftp_strat.c +++ b/release/sysinstall/ftp_strat.c @@ -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: ftp_strat.c,v 1.2 1995/05/27 20:50:10 jkh Exp $ + * $Id: ftp_strat.c,v 1.3 1995/05/27 21:18:07 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -118,113 +118,17 @@ mediaInitFTP(Device *dev) return TRUE; } -static pid_t ftppid = 0; - int -mediaGetFTP(char *dist, char *path) +mediaGetFTP(char *file) { - int fd; - char buf[512]; - int pfd[2], numchunks; - const char *tmp; - Attribs *dist_attr; - - if (!path) - path = ""; - msgNotify("Attempting to retreive `%s' over FTP", dist); - snprintf(buf, PATH_MAX, "/stand/info/%s%s.inf", path, dist); - if (!access(buf, R_OK)) { - msgDebug("Parsing attributes file for %s\n", dist); - dist_attr = safe_malloc(sizeof(Attribs) * MAX_ATTRIBS); - if (attr_parse(&dist_attr, buf) == 0) { - msgConfirm("Cannot load information file for %s distribution!\nPlease verify that your media is valid and try again.", dist); - return -1; - } - - msgDebug("Looking for attribute `pieces'\n"); - tmp = attr_match(dist_attr, "pieces"); - numchunks = atoi(tmp); - } - else - numchunks = 0; - msgDebug("Attempting to extract distribution from %u files\n", numchunks ? numchunks : 1); - - /* Take the lack of an info file to mean we're a fully qualified name */ - if (!numchunks) { - sprintf(buf, "%s%s", path, dist); - return(FtpGet(ftp, buf)); - } - else if (numchunks == 1) { - snprintf(buf, 512, "%s%s.aa", path, dist); - return(FtpGet(ftp, buf)); - } - - /* reap the previous child corpse - yuck! */ - if (ftppid) { - int i, j; - - i = waitpid(ftppid, &j, 0); - if (i < 0 || WEXITSTATUS(j)) { - msgConfirm("Previous FTP transaction returned status code %d - aborting\ntransfer.", WEXITSTATUS(j)); - ftppid = 0; - return -1; - } - ftppid = 0; - } - pipe(pfd); - ftppid = fork(); - if (!ftppid) { - int chunk; - int retval; - Boolean needEOF = FALSE; - - dup2(pfd[1], 1); close(pfd[1]); - close(pfd[0]); - - for (chunk = 0; chunk < numchunks; chunk++) { - char buffer[10240]; - int n; - - if (needEOF) { - FtpEOF(ftp); - needEOF = FALSE; - } - snprintf(buf, 512, "%s%s.%c%c", path, dist, (chunk / 26) + 'a', (chunk % 26) + 'a'); - fd = FtpGet(ftp, buf); - - if (fd < 0) - { - msgConfirm("FtpGet failed to retreive piece `%s' in the %s distribution!\nAborting the transfer", chunk, dist); - exit(1); - } - else - needEOF = TRUE; - while ((n = read(fd, buffer, 10240)) > 0) - { - retval = write(1, buffer, n); - if (retval != n) - { - msgConfirm("Write failure on transfer! (wrote %d bytes of %d bytes)", retval, n); - exit(1); - } - - } - close(fd); - } - close(1); - msgDebug("Extract of %s finished with success!!!\n", dist); - exit(0); - } - close(pfd[1]); - return(pfd[0]); + return(FtpGet(ftp, file)); } Boolean mediaCloseFTP(Device *dev, int fd) { FtpEOF(ftp); - close(fd); - return TRUE; + return (TRUE); } void @@ -239,16 +143,7 @@ mediaShutdownFTP(Device *dev) FtpClose(ftp); ftp = NULL; } - if (ftppid) { - int i, j; - - i = waitpid(ftppid, &j, 0); - if (i < 0 || WEXITSTATUS(j)) - msgConfirm("Warning: Last FTP transaction returned status code %d.", WEXITSTATUS(j)); - ftppid = 0; - } if (netdev->shutdown) (*netdev->shutdown)(netdev); ftpInitted = FALSE; } - diff --git a/release/sysinstall/install.c b/release/sysinstall/install.c index 56ad315..32e1025 100644 --- a/release/sysinstall/install.c +++ b/release/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.60 1995/05/26 20:45:19 jkh Exp $ + * $Id: install.c,v 1.61 1995/05/27 10:47:32 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -374,7 +374,7 @@ copy_self(void) int i; msgWeHaveOutput("Copying the boot floppy to /stand on root filesystem"); - i = vsystem("find -x /stand | cpio -pdmv /mnt"); + i = vsystem("find -x /stand | cpio -pdmV /mnt"); if (i) msgConfirm("Copy returned error status of %d!", i); /* copy up the etc files */ @@ -404,7 +404,7 @@ root_extract(void) if (mediaDevice->init) if (!(*mediaDevice->init)(mediaDevice)) break; - fd = (*mediaDevice->get)("root.flp", "floppies/"); + fd = (*mediaDevice->get)("floppies/root.flp"); if (fd != -1) { msgNotify("Loading root floppy from %s", mediaDevice->name); (void)mediaExtractDist("root.flp", "/", fd); @@ -412,9 +412,13 @@ root_extract(void) (*mediaDevice->close)(mediaDevice, fd); else close(fd); + if (mediaDevice->shutdown) + (*mediaDevice->shutdown)(mediaDevice); + } else { + if (mediaDevice->shutdown) + (*mediaDevice->shutdown)(mediaDevice); + loop_on_root_floppy(); } - if (mediaDevice->shutdown) - (*mediaDevice->shutdown)(mediaDevice); break; case DEVICE_TYPE_FLOPPY: diff --git a/release/sysinstall/media.c b/release/sysinstall/media.c index cf4b4bd..8ab18cf 100644 --- a/release/sysinstall/media.c +++ b/release/sysinstall/media.c @@ -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: media.c,v 1.18 1995/05/26 20:30:58 jkh Exp $ + * $Id: media.c,v 1.19 1995/05/27 10:47:34 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -432,6 +432,80 @@ mediaSetFS(char *str) } Boolean +mediaExtractDistBegin(char *distname, char *dir, int *fd, int *zpid, int *cpid) +{ + int i, pfd[2],qfd[2]; + + if (!dir) + dir = "/"; + msgWeHaveOutput("Extracting %s into %s directory..", distname, dir); + + Mkdir(dir, NULL); + chdir(dir); + pipe(pfd); + pipe(qfd); + *zpid = fork(); + if (!*zpid) { + dup2(qfd[0], 0); close(qfd[0]); + dup2(pfd[1], 1); close(pfd[1]); + if (DebugFD != -1) + dup2(DebugFD, 2); + else { + close(2); + open("/dev/null", O_WRONLY); + } + close(qfd[1]); + close(pfd[0]); + i = execl("/stand/gunzip", "/stand/gunzip", 0); + msgDebug("/stand/gunzip command returns %d status\n", i); + exit(i); + } + *fd = qfd[1]; + close(qfd[0]); + *cpid = fork(); + if (!*cpid) { + dup2(pfd[0], 0); close(pfd[0]); + close(pfd[1]); + close(qfd[1]); + if (DebugFD != -1) { + dup2(DebugFD, 1); + dup2(DebugFD, 2); + } + else { + close(1); open("/dev/null", O_WRONLY); + dup2(1, 2); + } + i = execl("/stand/cpio", "/stand/cpio", "-iduVm", "-H", "tar", 0); + msgDebug("/stand/cpio command returns %d status\n", i); + exit(i); + } + close(pfd[0]); + close(pfd[1]); + return TRUE; +} + +Boolean +mediaExtractDistEnd(int zpid, int cpid) +{ + int i,j; + + i = waitpid(zpid, &j, 0); + if (i < 0) { /* Don't check status - gunzip seems to return a bogus one! */ + dialog_clear(); + msgDebug("wait for gunzip returned status of %d!\n", i); + return FALSE; + } + i = waitpid(cpid, &j, 0); + if (i < 0 || WEXITSTATUS(j)) { + dialog_clear(); + msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j)); + return FALSE; + } + return TRUE; +} + + +Boolean mediaExtractDist(char *distname, char *dir, int fd) { int i, j, zpid, cpid, pfd[2]; @@ -471,7 +545,7 @@ mediaExtractDist(char *distname, char *dir, int fd) close(1); open("/dev/null", O_WRONLY); dup2(1, 2); } - i = execl("/stand/cpio", "/stand/cpio", "-iduvm", "-H", "tar", 0); + i = execl("/stand/cpio", "/stand/cpio", "-iduVm", "-H", "tar", 0); msgDebug("/stand/cpio command returns %d status\n", i); exit(i); } diff --git a/release/sysinstall/sysinstall.h b/release/sysinstall/sysinstall.h index 4d0dfa0..98adb0b 100644 --- a/release/sysinstall/sysinstall.h +++ b/release/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.35 1995/05/26 19:28:04 jkh Exp $ + * $Id: sysinstall.h,v 1.36 1995/05/27 10:47:42 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -171,7 +171,7 @@ typedef struct _device { DeviceType type; Boolean enabled; Boolean (*init)(struct _device *); - int (*get)(char *fname, char *dir); + int (*get)(char *file); Boolean (*close)(struct _device *, int fd); void (*shutdown)(struct _device *); void *private; @@ -250,7 +250,7 @@ extern int attr_parse(Attribs **attr, char *file); /* cdrom.c */ extern Boolean mediaInitCDROM(Device *dev); -extern int mediaGetCDROM(char *dist, char *path); +extern int mediaGetCDROM(char *file); extern void mediaShutdownCDROM(Device *dev); /* command.c */ @@ -280,7 +280,7 @@ extern Device **deviceFind(char *name, DeviceType type); extern int deviceCount(Device **devs); extern Device *new_device(char *name); extern Device *deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled, - Boolean (*init)(Device *mediadev), int (*get)(char *distname, char *path), + Boolean (*init)(Device *mediadev), int (*get)(char *file), Boolean (*close)(Device *mediadev, int fd), void (*shutDown)(Device *mediadev), void *private); @@ -305,19 +305,19 @@ extern void dmenuOpenSimple(DMenu *menu); /* dos.c */ extern Boolean mediaInitDOS(Device *dev); -extern int mediaGetDOS(char *dist, char *path); +extern int mediaGetDOS(char *file); extern void mediaShutdownDOS(Device *dev); /* floppy.c */ extern int getRootFloppy(void); extern Boolean mediaInitFloppy(Device *dev); -extern int mediaGetFloppy(char *dist, char *path); +extern int mediaGetFloppy(char *file); extern void mediaShutdownFloppy(Device *dev); /* ftp_strat.c */ extern Boolean mediaCloseFTP(Device *dev, int fd); extern Boolean mediaInitFTP(Device *dev); -extern int mediaGetFTP(char *dist, char *path); +extern int mediaGetFTP(char *file); extern void mediaShutdownFTP(Device *dev); /* globals.c */ @@ -366,6 +366,8 @@ extern int mediaSetFTP(char *str); extern int mediaSetFS(char *str); extern Boolean mediaGetType(void); extern Boolean mediaExtractDist(char *distname, char *dir, int fd); +extern Boolean mediaExtractDistBegin(char *distname, char *dir, int *fd, int *zpid, int *cpic); +extern Boolean mediaExtractDistEnd(int zpid, int cpid); extern Boolean mediaVerify(void); /* misc.c */ @@ -419,7 +421,7 @@ extern int vsystem(char *fmt, ...); /* tape.c */ extern Boolean mediaInitTape(Device *dev); -extern int mediaGetTape(char *dist, char *path); +extern int mediaGetTape(char *file); extern void mediaShutdownTape(Device *dev); /* tcpip.c */ @@ -432,7 +434,7 @@ extern int set_termcap(void); /* ufs.c */ extern Boolean mediaInitUFS(Device *dev); -extern int mediaGetUFS(char *dist, char *path); +extern int mediaGetUFS(char *file); /* variables.c */ extern void variable_set(char *var); diff --git a/release/sysinstall/tape.c b/release/sysinstall/tape.c index 2e158ff..6fb6c69 100644 --- a/release/sysinstall/tape.c +++ b/release/sysinstall/tape.c @@ -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: media_strategy.c,v 1.28 1995/05/26 20:30:59 jkh Exp $ + * $Id: tape.c,v 1.1 1995/05/27 10:39:02 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -59,7 +59,7 @@ mediaInitTape(Device *dev) } int -mediaGetTape(char *dist, char *path) +mediaGetTape(char *file) { return -1; } diff --git a/release/sysinstall/tcpip.c b/release/sysinstall/tcpip.c index 2c9d714..7ece498 100644 --- a/release/sysinstall/tcpip.c +++ b/release/sysinstall/tcpip.c @@ -1,5 +1,5 @@ /* - * $Id: tcpip.c,v 1.20 1995/05/26 21:37:53 jkh Exp $ + * $Id: tcpip.c,v 1.21 1995/05/26 22:08:59 jkh Exp $ * * Copyright (c) 1995 * Gary J Palmer. All rights reserved. @@ -137,7 +137,7 @@ static Layout layout[] = { { NULL }, }; -#define _validByte(b) ((b) > 0 && (b) < 255) +#define _validByte(b) ((b) >= 0 && (b) < 255) /* whine */ static void diff --git a/release/sysinstall/ufs.c b/release/sysinstall/ufs.c index 5639cbc..1fd9d4e 100644 --- a/release/sysinstall/ufs.c +++ b/release/sysinstall/ufs.c @@ -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: media_strategy.c,v 1.28 1995/05/26 20:30:59 jkh Exp $ + * $Id: ufs.c,v 1.1 1995/05/27 10:39:04 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -52,7 +52,7 @@ mediaInitUFS(Device *dev) } int -mediaGetUFS(char *dist, char *path) +mediaGetUFS(char *file) { return -1; } diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c index 56ad315..32e1025 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.60 1995/05/26 20:45:19 jkh Exp $ + * $Id: install.c,v 1.61 1995/05/27 10:47:32 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -374,7 +374,7 @@ copy_self(void) int i; msgWeHaveOutput("Copying the boot floppy to /stand on root filesystem"); - i = vsystem("find -x /stand | cpio -pdmv /mnt"); + i = vsystem("find -x /stand | cpio -pdmV /mnt"); if (i) msgConfirm("Copy returned error status of %d!", i); /* copy up the etc files */ @@ -404,7 +404,7 @@ root_extract(void) if (mediaDevice->init) if (!(*mediaDevice->init)(mediaDevice)) break; - fd = (*mediaDevice->get)("root.flp", "floppies/"); + fd = (*mediaDevice->get)("floppies/root.flp"); if (fd != -1) { msgNotify("Loading root floppy from %s", mediaDevice->name); (void)mediaExtractDist("root.flp", "/", fd); @@ -412,9 +412,13 @@ root_extract(void) (*mediaDevice->close)(mediaDevice, fd); else close(fd); + if (mediaDevice->shutdown) + (*mediaDevice->shutdown)(mediaDevice); + } else { + if (mediaDevice->shutdown) + (*mediaDevice->shutdown)(mediaDevice); + loop_on_root_floppy(); } - if (mediaDevice->shutdown) - (*mediaDevice->shutdown)(mediaDevice); break; case DEVICE_TYPE_FLOPPY: diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h index 4d0dfa0..98adb0b 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.35 1995/05/26 19:28:04 jkh Exp $ + * $Id: sysinstall.h,v 1.36 1995/05/27 10:47:42 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -171,7 +171,7 @@ typedef struct _device { DeviceType type; Boolean enabled; Boolean (*init)(struct _device *); - int (*get)(char *fname, char *dir); + int (*get)(char *file); Boolean (*close)(struct _device *, int fd); void (*shutdown)(struct _device *); void *private; @@ -250,7 +250,7 @@ extern int attr_parse(Attribs **attr, char *file); /* cdrom.c */ extern Boolean mediaInitCDROM(Device *dev); -extern int mediaGetCDROM(char *dist, char *path); +extern int mediaGetCDROM(char *file); extern void mediaShutdownCDROM(Device *dev); /* command.c */ @@ -280,7 +280,7 @@ extern Device **deviceFind(char *name, DeviceType type); extern int deviceCount(Device **devs); extern Device *new_device(char *name); extern Device *deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled, - Boolean (*init)(Device *mediadev), int (*get)(char *distname, char *path), + Boolean (*init)(Device *mediadev), int (*get)(char *file), Boolean (*close)(Device *mediadev, int fd), void (*shutDown)(Device *mediadev), void *private); @@ -305,19 +305,19 @@ extern void dmenuOpenSimple(DMenu *menu); /* dos.c */ extern Boolean mediaInitDOS(Device *dev); -extern int mediaGetDOS(char *dist, char *path); +extern int mediaGetDOS(char *file); extern void mediaShutdownDOS(Device *dev); /* floppy.c */ extern int getRootFloppy(void); extern Boolean mediaInitFloppy(Device *dev); -extern int mediaGetFloppy(char *dist, char *path); +extern int mediaGetFloppy(char *file); extern void mediaShutdownFloppy(Device *dev); /* ftp_strat.c */ extern Boolean mediaCloseFTP(Device *dev, int fd); extern Boolean mediaInitFTP(Device *dev); -extern int mediaGetFTP(char *dist, char *path); +extern int mediaGetFTP(char *file); extern void mediaShutdownFTP(Device *dev); /* globals.c */ @@ -366,6 +366,8 @@ extern int mediaSetFTP(char *str); extern int mediaSetFS(char *str); extern Boolean mediaGetType(void); extern Boolean mediaExtractDist(char *distname, char *dir, int fd); +extern Boolean mediaExtractDistBegin(char *distname, char *dir, int *fd, int *zpid, int *cpic); +extern Boolean mediaExtractDistEnd(int zpid, int cpid); extern Boolean mediaVerify(void); /* misc.c */ @@ -419,7 +421,7 @@ extern int vsystem(char *fmt, ...); /* tape.c */ extern Boolean mediaInitTape(Device *dev); -extern int mediaGetTape(char *dist, char *path); +extern int mediaGetTape(char *file); extern void mediaShutdownTape(Device *dev); /* tcpip.c */ @@ -432,7 +434,7 @@ extern int set_termcap(void); /* ufs.c */ extern Boolean mediaInitUFS(Device *dev); -extern int mediaGetUFS(char *dist, char *path); +extern int mediaGetUFS(char *file); /* variables.c */ extern void variable_set(char *var); diff --git a/usr.sbin/sysinstall/cdrom.c b/usr.sbin/sysinstall/cdrom.c index 3152bf0..095cc19 100644 --- a/usr.sbin/sysinstall/cdrom.c +++ b/usr.sbin/sysinstall/cdrom.c @@ -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: media_strategy.c,v 1.28 1995/05/26 20:30:59 jkh Exp $ + * $Id: cdrom.c,v 1.1 1995/05/27 10:38:45 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -57,6 +57,7 @@ #include <sys/wait.h> #include <unistd.h> #include <grp.h> +#include <fcntl.h> #define CD9660 #include <sys/mount.h> @@ -102,45 +103,19 @@ mediaInitCDROM(Device *dev) } int -mediaGetCDROM(char *dist, char *path) +mediaGetCDROM(char *file) { char buf[PATH_MAX]; - Attribs *dist_attr; - int retval; - dist_attr = safe_malloc(sizeof(Attribs) * MAX_ATTRIBS); - - snprintf(buf, PATH_MAX, "/stand/info/%s.inf", dist); - - if (!access(buf, R_OK) && attr_parse(&dist_attr, buf) == 0) { - msgConfirm("Cannot load information file for %s distribution!\nPlease verify that your media is valid and try again.", dist); - free(dist_attr); - return FALSE; - } - - snprintf(buf, PATH_MAX, "/cdrom/%s%s", path ? path : "", dist); - retval = genericGetDist(buf, dist_attr, FALSE); - free(dist_attr); - return retval; + snprintf(buf, PATH_MAX, "/cdrom/%s", file); + return open(buf,O_RDONLY); } void mediaShutdownCDROM(Device *dev) { - extern int getDistpid; - if (!cdromMounted) return; - if (getDistpid) { - int i, j; - - i = waitpid(getDistpid, &j, 0); - if (i < 0 || WEXITSTATUS(j)) { - msgConfirm("Warning: Last extraction returned status code %d.", WEXITSTATUS(j)); - getDistpid = 0; - } - getDistpid = 0; - } msgDebug("Unmounting /cdrom\n"); if (unmount("/cdrom", 0) != 0) msgConfirm("Could not unmount the CDROM: %s\n", strerror(errno)); diff --git a/usr.sbin/sysinstall/dist.c b/usr.sbin/sysinstall/dist.c index 9b70bb6..799782b 100644 --- a/usr.sbin/sysinstall/dist.c +++ b/usr.sbin/sysinstall/dist.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: dist.c,v 1.25 1995/05/26 22:22:20 jkh Exp $ + * $Id: dist.c,v 1.26 1995/05/27 10:47:30 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -222,41 +222,123 @@ static int distExtract(char *parent, Distribution *me) { int i, status; - int fd; + int cpid, zpid, fd, fd2, chunk, numchunks; + char dparent[FILENAME_MAX], *path, *dist, buf[10240]; + const char *tmp; + Attribs *dist_attr; status = 0; if (mediaDevice->init) if (!(*mediaDevice->init)(mediaDevice)) return 0; for (i = 0; me[i].my_name; i++) { - if (me[i].my_bit & *(me[i].my_mask)) { - if (me[i].my_dist) - status = distExtract(me[i].my_name, me[i].my_dist); - else { - char dparent[FILENAME_MAX]; - - snprintf(dparent, FILENAME_MAX, "%s/", parent ? parent : me[i].my_name); - fd = (*mediaDevice->get)(me[i].my_name, dparent); - if (fd != -1) { + + /* If we're not doing it, we're not doing it */ + if (!(me[i].my_bit & *(me[i].my_mask))) + continue; + + /* Recurse if we think thats more fun */ + if (me[i].my_dist) { + status = distExtract(me[i].my_name, me[i].my_dist); + goto done; + } + + snprintf(dparent, FILENAME_MAX, "%s/", parent ? parent : me[i].my_name); + dist = me[i].my_name; + path = dparent ? dparent : ""; + + snprintf(buf, 512, "%s%s.tgz", path, dist); + fd = (*mediaDevice->get)(buf); + if (fd != -1) { + status = mediaExtractDist(me[i].my_name, me[i].my_dir, fd); + if (mediaDevice->close) + (*mediaDevice->close)(mediaDevice, fd); + else + close(fd); + goto done; + } + + snprintf(buf, sizeof buf, "/stand/info/%s%s.inf", path, dist); + if (!access(buf, R_OK)) { + msgDebug("Parsing attributes file for %s\n", dist); + dist_attr = safe_malloc(sizeof(Attribs) * MAX_ATTRIBS); + if (attr_parse(&dist_attr, buf) == 0) { + msgConfirm("Cannot load information file for %s distribution!\nPlease verify that your media is valid and try again.", dist); + return -1; + } + + msgDebug("Looking for attribute `pieces'\n"); + tmp = attr_match(dist_attr, "pieces"); + numchunks = atoi(tmp); + } else + numchunks = 0; + + msgDebug("Attempting to extract distribution from %u chunks.\n", + numchunks); + + if (numchunks < 2 ) { + snprintf(buf, 512, "%s%s", path, dist); + if (numchunks) + strcat(buf,".aa"); + fd = (*mediaDevice->get)(buf); + if (fd == -1) { + status = 1; + } else { status = mediaExtractDist(me[i].my_name, me[i].my_dir, fd); if (mediaDevice->close) (*mediaDevice->close)(mediaDevice, fd); else close(fd); - } - else { - if (getenv(NO_CONFIRMATION)) - status = 0; - else - status = !msgYesNo("Unable to transfer the %s distribution from %s.\nDo you want to retry this distribution later?", me[i].my_name, mediaDevice->name); - } } - if (!status) { - /* Extract was successful, remove ourselves from further consideration */ - *(me[i].my_mask) &= ~(me[i].my_bit); + goto done; + } + + mediaExtractDistBegin(dist, me[i].my_dir, &fd2, &zpid, &cpid); + for (chunk = 0; chunk < numchunks; chunk++) { + int n, retval; + + snprintf(buf, 512, "%s%s.%c%c", path, dist, + (chunk / 26) + 'a', (chunk % 26) + 'a'); + fd = (*mediaDevice->get)(buf); + + if (fd < 0) + { + msgConfirm("FtpGet failed to retreive piece `%s' in the %s distribution!\nAborting the transfer", chunk, dist); + goto punt; } + while ((n = read(fd, buf, sizeof buf)) > 0) { + retval = write(fd2, buf, n); + if (retval != n) + { + if (mediaDevice->close) + (*mediaDevice->close)(mediaDevice, fd); + msgConfirm("Write failure on transfer! (wrote %d bytes of %d bytes)", retval, n); + goto punt; + } + } + if (mediaDevice->close) + (*mediaDevice->close)(mediaDevice, fd); } - } + close(fd2); + status = mediaExtractDistEnd(zpid,cpid); + goto done; + + punt: + close(fd2); + mediaExtractDistEnd(zpid,cpid); + status = 1; + done: + if (status) { + if (getenv(NO_CONFIRMATION)) + status = 0; + else + status = !msgYesNo("Unable to transfer the %s distribution from %s.\nDo you want to retry this distribution later?", me[i].my_name, mediaDevice->name); + } + if (!status) { + /* Extract was successful, remove ourselves from further consideration */ + *(me[i].my_mask) &= ~(me[i].my_bit); + } +} if (mediaDevice->shutdown && parent == NULL) { (*mediaDevice->shutdown)(mediaDevice); mediaDevice = NULL; diff --git a/usr.sbin/sysinstall/dos.c b/usr.sbin/sysinstall/dos.c index a8d1a85..d3999c5 100644 --- a/usr.sbin/sysinstall/dos.c +++ b/usr.sbin/sysinstall/dos.c @@ -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: media_strategy.c,v 1.28 1995/05/26 20:30:59 jkh Exp $ + * $Id: dos.c,v 1.1 1995/05/27 10:38:47 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -49,6 +49,7 @@ #include <sys/param.h> #include <sys/wait.h> #include <unistd.h> +#include <fcntl.h> #include <grp.h> #define MSDOSFS @@ -80,23 +81,12 @@ mediaInitDOS(Device *dev) } int -mediaGetDOS(char *dist, char *path) +mediaGetDOS(char *file) { char buf[PATH_MAX]; - Attribs *dist_attr = NULL; - int retval; - dist_attr = safe_malloc(sizeof(Attribs) * MAX_ATTRIBS); - snprintf(buf, PATH_MAX, "/stand/info/%s.inf", dist); - if (!access(buf, R_OK) && attr_parse(&dist_attr, buf) == 0) { - msgConfirm("Cannot load information file for %s distribution!\nPlease verify that your media is valid and try again.", dist); - free(dist_attr); - return FALSE; - } - snprintf(buf, PATH_MAX, "/dos/%s%s", path ? path : "", dist); - retval = genericGetDist(buf, dist_attr, FALSE); - free(dist_attr); - return retval; + snprintf(buf, PATH_MAX, "/dos/%s", file); + return open(buf,O_RDONLY); } void diff --git a/usr.sbin/sysinstall/floppy.c b/usr.sbin/sysinstall/floppy.c index 2c4df0b..a2a1212 100644 --- a/usr.sbin/sysinstall/floppy.c +++ b/usr.sbin/sysinstall/floppy.c @@ -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: media_strategy.c,v 1.28 1995/05/26 20:30:59 jkh Exp $ + * $Id: floppy.c,v 1.1 1995/05/27 10:38:52 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -141,28 +141,13 @@ mediaInitFloppy(Device *dev) } int -mediaGetFloppy(char *dist, char *path) +mediaGetFloppy(char *file) { char buf[PATH_MAX]; - char *fname; - Attribs *dist_attr; - int retval; - dist_attr = safe_malloc(sizeof(Attribs) * MAX_ATTRIBS); + snprintf(buf, PATH_MAX, "/mnt/%s", file); - snprintf(buf, PATH_MAX, "/stand/info/%s.inf", dist); - if (!access(buf, R_OK) && attr_parse(&dist_attr, buf) == 0) - { - msgConfirm("Cannot load information file for %s distribution!\nPlease verify that your media is valid and try again.", dist); - free(dist_attr); - return FALSE; - } - fname = index(dist, '/') + 1; - snprintf(buf, PATH_MAX, "/mnt/%s", fname); - - retval = genericGetDist(buf, dist_attr, TRUE); - free(dist_attr); - return retval; + return open(buf,O_RDONLY); } void diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c index 56ad315..32e1025 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.60 1995/05/26 20:45:19 jkh Exp $ + * $Id: install.c,v 1.61 1995/05/27 10:47:32 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -374,7 +374,7 @@ copy_self(void) int i; msgWeHaveOutput("Copying the boot floppy to /stand on root filesystem"); - i = vsystem("find -x /stand | cpio -pdmv /mnt"); + i = vsystem("find -x /stand | cpio -pdmV /mnt"); if (i) msgConfirm("Copy returned error status of %d!", i); /* copy up the etc files */ @@ -404,7 +404,7 @@ root_extract(void) if (mediaDevice->init) if (!(*mediaDevice->init)(mediaDevice)) break; - fd = (*mediaDevice->get)("root.flp", "floppies/"); + fd = (*mediaDevice->get)("floppies/root.flp"); if (fd != -1) { msgNotify("Loading root floppy from %s", mediaDevice->name); (void)mediaExtractDist("root.flp", "/", fd); @@ -412,9 +412,13 @@ root_extract(void) (*mediaDevice->close)(mediaDevice, fd); else close(fd); + if (mediaDevice->shutdown) + (*mediaDevice->shutdown)(mediaDevice); + } else { + if (mediaDevice->shutdown) + (*mediaDevice->shutdown)(mediaDevice); + loop_on_root_floppy(); } - if (mediaDevice->shutdown) - (*mediaDevice->shutdown)(mediaDevice); break; case DEVICE_TYPE_FLOPPY: diff --git a/usr.sbin/sysinstall/media.c b/usr.sbin/sysinstall/media.c index cf4b4bd..8ab18cf 100644 --- a/usr.sbin/sysinstall/media.c +++ b/usr.sbin/sysinstall/media.c @@ -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: media.c,v 1.18 1995/05/26 20:30:58 jkh Exp $ + * $Id: media.c,v 1.19 1995/05/27 10:47:34 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -432,6 +432,80 @@ mediaSetFS(char *str) } Boolean +mediaExtractDistBegin(char *distname, char *dir, int *fd, int *zpid, int *cpid) +{ + int i, pfd[2],qfd[2]; + + if (!dir) + dir = "/"; + msgWeHaveOutput("Extracting %s into %s directory..", distname, dir); + + Mkdir(dir, NULL); + chdir(dir); + pipe(pfd); + pipe(qfd); + *zpid = fork(); + if (!*zpid) { + dup2(qfd[0], 0); close(qfd[0]); + dup2(pfd[1], 1); close(pfd[1]); + if (DebugFD != -1) + dup2(DebugFD, 2); + else { + close(2); + open("/dev/null", O_WRONLY); + } + close(qfd[1]); + close(pfd[0]); + i = execl("/stand/gunzip", "/stand/gunzip", 0); + msgDebug("/stand/gunzip command returns %d status\n", i); + exit(i); + } + *fd = qfd[1]; + close(qfd[0]); + *cpid = fork(); + if (!*cpid) { + dup2(pfd[0], 0); close(pfd[0]); + close(pfd[1]); + close(qfd[1]); + if (DebugFD != -1) { + dup2(DebugFD, 1); + dup2(DebugFD, 2); + } + else { + close(1); open("/dev/null", O_WRONLY); + dup2(1, 2); + } + i = execl("/stand/cpio", "/stand/cpio", "-iduVm", "-H", "tar", 0); + msgDebug("/stand/cpio command returns %d status\n", i); + exit(i); + } + close(pfd[0]); + close(pfd[1]); + return TRUE; +} + +Boolean +mediaExtractDistEnd(int zpid, int cpid) +{ + int i,j; + + i = waitpid(zpid, &j, 0); + if (i < 0) { /* Don't check status - gunzip seems to return a bogus one! */ + dialog_clear(); + msgDebug("wait for gunzip returned status of %d!\n", i); + return FALSE; + } + i = waitpid(cpid, &j, 0); + if (i < 0 || WEXITSTATUS(j)) { + dialog_clear(); + msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j)); + return FALSE; + } + return TRUE; +} + + +Boolean mediaExtractDist(char *distname, char *dir, int fd) { int i, j, zpid, cpid, pfd[2]; @@ -471,7 +545,7 @@ mediaExtractDist(char *distname, char *dir, int fd) close(1); open("/dev/null", O_WRONLY); dup2(1, 2); } - i = execl("/stand/cpio", "/stand/cpio", "-iduvm", "-H", "tar", 0); + i = execl("/stand/cpio", "/stand/cpio", "-iduVm", "-H", "tar", 0); msgDebug("/stand/cpio command returns %d status\n", i); exit(i); } diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h index 4d0dfa0..98adb0b 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.35 1995/05/26 19:28:04 jkh Exp $ + * $Id: sysinstall.h,v 1.36 1995/05/27 10:47:42 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -171,7 +171,7 @@ typedef struct _device { DeviceType type; Boolean enabled; Boolean (*init)(struct _device *); - int (*get)(char *fname, char *dir); + int (*get)(char *file); Boolean (*close)(struct _device *, int fd); void (*shutdown)(struct _device *); void *private; @@ -250,7 +250,7 @@ extern int attr_parse(Attribs **attr, char *file); /* cdrom.c */ extern Boolean mediaInitCDROM(Device *dev); -extern int mediaGetCDROM(char *dist, char *path); +extern int mediaGetCDROM(char *file); extern void mediaShutdownCDROM(Device *dev); /* command.c */ @@ -280,7 +280,7 @@ extern Device **deviceFind(char *name, DeviceType type); extern int deviceCount(Device **devs); extern Device *new_device(char *name); extern Device *deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled, - Boolean (*init)(Device *mediadev), int (*get)(char *distname, char *path), + Boolean (*init)(Device *mediadev), int (*get)(char *file), Boolean (*close)(Device *mediadev, int fd), void (*shutDown)(Device *mediadev), void *private); @@ -305,19 +305,19 @@ extern void dmenuOpenSimple(DMenu *menu); /* dos.c */ extern Boolean mediaInitDOS(Device *dev); -extern int mediaGetDOS(char *dist, char *path); +extern int mediaGetDOS(char *file); extern void mediaShutdownDOS(Device *dev); /* floppy.c */ extern int getRootFloppy(void); extern Boolean mediaInitFloppy(Device *dev); -extern int mediaGetFloppy(char *dist, char *path); +extern int mediaGetFloppy(char *file); extern void mediaShutdownFloppy(Device *dev); /* ftp_strat.c */ extern Boolean mediaCloseFTP(Device *dev, int fd); extern Boolean mediaInitFTP(Device *dev); -extern int mediaGetFTP(char *dist, char *path); +extern int mediaGetFTP(char *file); extern void mediaShutdownFTP(Device *dev); /* globals.c */ @@ -366,6 +366,8 @@ extern int mediaSetFTP(char *str); extern int mediaSetFS(char *str); extern Boolean mediaGetType(void); extern Boolean mediaExtractDist(char *distname, char *dir, int fd); +extern Boolean mediaExtractDistBegin(char *distname, char *dir, int *fd, int *zpid, int *cpic); +extern Boolean mediaExtractDistEnd(int zpid, int cpid); extern Boolean mediaVerify(void); /* misc.c */ @@ -419,7 +421,7 @@ extern int vsystem(char *fmt, ...); /* tape.c */ extern Boolean mediaInitTape(Device *dev); -extern int mediaGetTape(char *dist, char *path); +extern int mediaGetTape(char *file); extern void mediaShutdownTape(Device *dev); /* tcpip.c */ @@ -432,7 +434,7 @@ extern int set_termcap(void); /* ufs.c */ extern Boolean mediaInitUFS(Device *dev); -extern int mediaGetUFS(char *dist, char *path); +extern int mediaGetUFS(char *file); /* variables.c */ extern void variable_set(char *var); diff --git a/usr.sbin/sysinstall/tape.c b/usr.sbin/sysinstall/tape.c index 2e158ff..6fb6c69 100644 --- a/usr.sbin/sysinstall/tape.c +++ b/usr.sbin/sysinstall/tape.c @@ -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: media_strategy.c,v 1.28 1995/05/26 20:30:59 jkh Exp $ + * $Id: tape.c,v 1.1 1995/05/27 10:39:02 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -59,7 +59,7 @@ mediaInitTape(Device *dev) } int -mediaGetTape(char *dist, char *path) +mediaGetTape(char *file) { return -1; } diff --git a/usr.sbin/sysinstall/tcpip.c b/usr.sbin/sysinstall/tcpip.c index 2c9d714..7ece498 100644 --- a/usr.sbin/sysinstall/tcpip.c +++ b/usr.sbin/sysinstall/tcpip.c @@ -1,5 +1,5 @@ /* - * $Id: tcpip.c,v 1.20 1995/05/26 21:37:53 jkh Exp $ + * $Id: tcpip.c,v 1.21 1995/05/26 22:08:59 jkh Exp $ * * Copyright (c) 1995 * Gary J Palmer. All rights reserved. @@ -137,7 +137,7 @@ static Layout layout[] = { { NULL }, }; -#define _validByte(b) ((b) > 0 && (b) < 255) +#define _validByte(b) ((b) >= 0 && (b) < 255) /* whine */ static void diff --git a/usr.sbin/sysinstall/ufs.c b/usr.sbin/sysinstall/ufs.c index 5639cbc..1fd9d4e 100644 --- a/usr.sbin/sysinstall/ufs.c +++ b/usr.sbin/sysinstall/ufs.c @@ -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: media_strategy.c,v 1.28 1995/05/26 20:30:59 jkh Exp $ + * $Id: ufs.c,v 1.1 1995/05/27 10:39:04 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -52,7 +52,7 @@ mediaInitUFS(Device *dev) } int -mediaGetUFS(char *dist, char *path) +mediaGetUFS(char *file) { return -1; } |