diff options
author | jkh <jkh@FreeBSD.org> | 1995-05-28 03:05:06 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1995-05-28 03:05:06 +0000 |
commit | f6adc3d0cb0c4fabebcca758ff1974167658353e (patch) | |
tree | 11cb8db7e042dea4f3131229406e5cf69f646241 /usr.sbin | |
parent | f95342e1c873302bd88bff8b1183ce16998990e5 (diff) | |
download | FreeBSD-src-f6adc3d0cb0c4fabebcca758ff1974167658353e.zip FreeBSD-src-f6adc3d0cb0c4fabebcca758ff1974167658353e.tar.gz |
Humanize Poul-Henning's code. Status values should be properly
respected now.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/sade/sade.h | 3 | ||||
-rw-r--r-- | usr.sbin/sysinstall/cdrom.c | 19 | ||||
-rw-r--r-- | usr.sbin/sysinstall/dist.c | 65 | ||||
-rw-r--r-- | usr.sbin/sysinstall/dos.c | 16 | ||||
-rw-r--r-- | usr.sbin/sysinstall/floppy.c | 16 | ||||
-rw-r--r-- | usr.sbin/sysinstall/media.c | 143 | ||||
-rw-r--r-- | usr.sbin/sysinstall/network.c | 9 | ||||
-rw-r--r-- | usr.sbin/sysinstall/sysinstall.h | 3 | ||||
-rw-r--r-- | usr.sbin/sysinstall/tape.c | 9 | ||||
-rw-r--r-- | usr.sbin/sysinstall/tcpip.c | 7 |
10 files changed, 63 insertions, 227 deletions
diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h index 98adb0b..7ca3c9d 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.36 1995/05/27 10:47:42 jkh Exp $ + * $Id: sysinstall.h,v 1.37 1995/05/27 23:39:32 phk Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -357,7 +357,6 @@ extern const u_char koi8_r2cp866[]; extern u_char default_scrnmap[]; /* media.c */ -extern int genericGetDist(char *path, Attribs *dist_attrib, Boolean prompt); extern int mediaSetCDROM(char *str); extern int mediaSetFloppy(char *str); extern int mediaSetDOS(char *str); diff --git a/usr.sbin/sysinstall/cdrom.c b/usr.sbin/sysinstall/cdrom.c index 095cc19..86f8afc 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: cdrom.c,v 1.1 1995/05/27 10:38:45 jkh Exp $ + * $Id: cdrom.c,v 1.2 1995/05/27 23:39:26 phk Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -43,12 +43,7 @@ * */ -/* - * These routines deal with getting things off of floppy media, though - * with one exception: genericGetDist() is actually used from lots of places - * since it can think of the world as just "one big floppy" too if that's - * appropriate. - */ +/* These routines deal with getting things off of CDROM media */ #include "sysinstall.h" #include <sys/stat.h> @@ -85,9 +80,11 @@ mediaInitCDROM(Device *dev) return FALSE; } - /* Do a very simple check to see if this looks roughly like a 2.0.5 CDROM - Unfortunately FreeBSD won't let us read the ``label'' AFAIK, which is one - sure way of telling the disc version :-( */ + /* + * Do a very simple check to see if this looks roughly like a 2.0.5 CDROM + * Unfortunately FreeBSD won't let us read the ``label'' AFAIK, which is one + * sure way of telling the disc version :-( + */ if (stat("/cdrom/dists", &sb)) { if (errno == ENOENT) { msgConfirm("Couldn't locate the directory `dists' on the CD.\nIs this a 2.0.5 CDROM?\n"); @@ -108,7 +105,7 @@ mediaGetCDROM(char *file) char buf[PATH_MAX]; snprintf(buf, PATH_MAX, "/cdrom/%s", file); - return open(buf,O_RDONLY); + return open(buf, O_RDONLY); } void diff --git a/usr.sbin/sysinstall/dist.c b/usr.sbin/sysinstall/dist.c index 799782b..f1e0cae 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.26 1995/05/27 10:47:30 jkh Exp $ + * $Id: dist.c,v 1.27 1995/05/27 23:39:27 phk Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -218,7 +218,7 @@ static Distribution XF86FontDistTable[] = { { NULL }, }; -static int +static Boolean distExtract(char *parent, Distribution *me) { int i, status; @@ -227,17 +227,17 @@ distExtract(char *parent, Distribution *me) const char *tmp; Attribs *dist_attr; - status = 0; + status = FALSE; if (mediaDevice->init) if (!(*mediaDevice->init)(mediaDevice)) - return 0; - for (i = 0; me[i].my_name; i++) { + return FALSE; + for (i = 0; me[i].my_name; i++) { /* 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 */ + /* Recurse if actually have a sub-distribution */ if (me[i].my_dist) { status = distExtract(me[i].my_name, me[i].my_dist); goto done; @@ -264,17 +264,20 @@ distExtract(char *parent, Distribution *me) 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; + return FALSE; } msgDebug("Looking for attribute `pieces'\n"); tmp = attr_match(dist_attr, "pieces"); - numchunks = atoi(tmp); - } else + if (tmp) + numchunks = atoi(tmp); + else + numchunks = 0; + } + else numchunks = 0; - msgDebug("Attempting to extract distribution from %u chunks.\n", - numchunks); + msgDebug("Attempting to extract distribution from %u chunks.\n", numchunks); if (numchunks < 2 ) { snprintf(buf, 512, "%s%s", path, dist); @@ -282,13 +285,13 @@ distExtract(char *parent, Distribution *me) strcat(buf,".aa"); fd = (*mediaDevice->get)(buf); if (fd == -1) { - status = 1; + status = FALSE; } else { - status = mediaExtractDist(me[i].my_name, me[i].my_dir, fd); - if (mediaDevice->close) - (*mediaDevice->close)(mediaDevice, fd); - else - close(fd); + status = mediaExtractDist(me[i].my_name, me[i].my_dir, fd); + if (mediaDevice->close) + (*mediaDevice->close)(mediaDevice, fd); + else + close(fd); } goto done; } @@ -297,12 +300,9 @@ distExtract(char *parent, Distribution *me) for (chunk = 0; chunk < numchunks; chunk++) { int n, retval; - snprintf(buf, 512, "%s%s.%c%c", path, dist, - (chunk / 26) + 'a', (chunk % 26) + 'a'); + snprintf(buf, 512, "%s%s.%c%c", path, dist, (chunk / 26) + 'a', (chunk % 26) + 'a'); fd = (*mediaDevice->get)(buf); - - if (fd < 0) - { + if (fd < 0) { msgConfirm("FtpGet failed to retreive piece `%s' in the %s distribution!\nAborting the transfer", chunk, dist); goto punt; } @@ -312,33 +312,38 @@ distExtract(char *parent, Distribution *me) { if (mediaDevice->close) (*mediaDevice->close)(mediaDevice, fd); + else + close(fd); msgConfirm("Write failure on transfer! (wrote %d bytes of %d bytes)", retval, n); goto punt; } } if (mediaDevice->close) (*mediaDevice->close)(mediaDevice, fd); + else + close(fd); } close(fd2); - status = mediaExtractDistEnd(zpid,cpid); + status = mediaExtractDistEnd(zpid, cpid); goto done; punt: close(fd2); - mediaExtractDistEnd(zpid,cpid); - status = 1; + mediaExtractDistEnd(zpid, cpid); + status = FALSE; + done: - if (status) { + if (!status) { if (getenv(NO_CONFIRMATION)) - status = 0; + status = TRUE; 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); + 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) { + 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 d3999c5..2204bae 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: dos.c,v 1.1 1995/05/27 10:38:47 jkh Exp $ + * $Id: dos.c,v 1.2 1995/05/27 23:39:28 phk Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -86,26 +86,14 @@ mediaGetDOS(char *file) char buf[PATH_MAX]; snprintf(buf, PATH_MAX, "/dos/%s", file); - return open(buf,O_RDONLY); + return open(buf, O_RDONLY); } void mediaShutdownDOS(Device *dev) { - extern int getDistpid; - if (!DOSMounted) 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 /dos\n"); if (unmount("/dos", 0) != 0) msgConfirm("Could not unmount the DOS partition: %s\n", strerror(errno)); diff --git a/usr.sbin/sysinstall/floppy.c b/usr.sbin/sysinstall/floppy.c index a2a1212..1f97bc7 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: floppy.c,v 1.1 1995/05/27 10:38:52 jkh Exp $ + * $Id: floppy.c,v 1.2 1995/05/27 23:39:29 phk Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -43,12 +43,7 @@ * */ -/* - * These routines deal with getting things off of floppy media, though - * with one exception: genericGetDist() is actually used from lots of places - * since it can think of the world as just "one big floppy" too if that's - * appropriate. - */ +/* These routines deal with getting things off of floppy media */ #include "sysinstall.h" #include <sys/fcntl.h> @@ -129,6 +124,7 @@ mediaInitFloppy(Device *dev) msgConfirm("Unable to make directory mountpoint for %s!", mountpoint); return FALSE; } + msgConfirm("Please insert media into %s and press return", dev->description); msgDebug("initFloppy: mount floppy %s on /mnt\n", dev->devname); dosargs.fspec = dev->devname; if (mount(MOUNT_MSDOS, "/mnt", 0, (caddr_t)&dosargs) == -1) { @@ -147,7 +143,7 @@ mediaGetFloppy(char *file) snprintf(buf, PATH_MAX, "/mnt/%s", file); - return open(buf,O_RDONLY); + return open(buf, O_RDONLY); } void @@ -156,7 +152,9 @@ mediaShutdownFloppy(Device *dev) if (floppyMounted) { if (vsystem("umount /mnt") != 0) msgDebug("Umount of floppy on /mnt failed: %s (%d)\n", strerror(errno), errno); - else + else { floppyMounted = FALSE; + msgConfirm("You may remove the floppy from %s", dev->description); + } } } diff --git a/usr.sbin/sysinstall/media.c b/usr.sbin/sysinstall/media.c index 8ab18cf..17cce51 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.19 1995/05/27 10:47:34 jkh Exp $ + * $Id: media.c,v 1.20 1995/05/27 23:39:31 phk Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -50,147 +50,6 @@ #include <unistd.h> #include "sysinstall.h" -pid_t getDistpid = 0; - -/* - * This is the generic distribution opening routine. It returns - * a file descriptor that refers to a stream of bytes coming from - * _somewhere_ that can be extracted as a gzip'd tar file. - */ -int -genericGetDist(char *path, Attribs *dist_attrib, Boolean prompt) -{ - int fd; - char buf[512]; - struct stat sb; - int pfd[2], numchunks; - const char *tmp; - - /* reap any previous child corpse - yuck! */ - if (getDistpid) { - int i, j; - - i = waitpid(getDistpid, &j, 0); - if (i < 0 || WEXITSTATUS(j)) - msgNotify("Warning: Previous extraction returned status code %d.", WEXITSTATUS(j)); - getDistpid = 0; - } - - /* How try to figure out how many pieces to expect */ - if (dist_attrib) { - tmp = attr_match(dist_attrib, "pieces"); - numchunks = atoi(tmp); - } - else - numchunks = 1; - - if (!path) - return -1; - if (stat(path, &sb) == 0) { - fd = open(path, O_RDONLY, 0); - return(fd); - } - - snprintf(buf, 512, "%s.tgz", path); - if (stat(buf, &sb) == 0) { - fd = open(buf, O_RDONLY, 0); - return(fd); - } - - snprintf(buf, 512, "%s.aa", path); - if (stat(buf, &sb) == 0 && numchunks == 1) { - fd = open(buf, O_RDONLY, 0); - if (fd != -1) - return fd; - else if (!prompt) { - } - } - - if (numchunks < 2 && !prompt) { - if (!getenv(NO_CONFIRMATION)) - msgConfirm("Cannot find file(s) for distribution in ``%s''!", path); - else - msgDebug("Cannot find file(s) for distribution in ``%s''!\n", path); - return -1; - } - - msgDebug("Attempting to concatenate %u chunks\n", numchunks); - pipe(pfd); - getDistpid = fork(); - if (!getDistpid) { - caddr_t memory; - int chunk; - int retval; - - dup2(pfd[1], 1); close(pfd[1]); - close(pfd[0]); - - for (chunk = 0; chunk < numchunks; chunk++) { - int fd; - unsigned long len, val; - - retval = stat(buf, &sb); - if ((retval != 0) && (prompt != TRUE)) - { - msgConfirm("Cannot find file(s) for distribution in ``%s''!\n", path); - return -1; - } else { - char *tmp = index(buf, '/'); - tmp++; - - while (retval != 0) - { - if (mediaDevice->shutdown) - (*mediaDevice->shutdown)(mediaDevice); - msgConfirm("Please insert the media with the `%s' file on it\n", tmp); - if (mediaDevice->init) - if (!mediaDevice->init(mediaDevice)) - return -1; - retval = stat(buf, &sb); - } - } - - snprintf(buf, 512, "%s.%c%c", path, (chunk / 26) + 'a', (chunk % 26) + 'a'); - if ((fd = open(buf, O_RDONLY)) == -1) - msgFatal("Cannot find file `%s'!", buf); - - if (prompt == TRUE) { - extern int crc(int, unsigned long *, unsigned long *); - - crc(fd, &val, &len); - msgDebug("crc for %s is %lu %lu\n", buf, val, len); - } - - fstat(fd, &sb); - msgDebug("mmap()ing %s (%d)\n", buf, fd); - memory = mmap(0, sb.st_size, PROT_READ, MAP_SHARED, fd, (off_t) 0); - if (memory == (caddr_t) -1) - msgFatal("mmap error: %s\n", strerror(errno)); - - retval = write(1, memory, sb.st_size); - if (retval != sb.st_size) - { - msgConfirm("write didn't write out the complete file!\n(wrote %d bytes of %d bytes)", retval, - sb.st_size); - exit(1); - } - - retval = munmap(memory, sb.st_size); - if (retval != 0) - { - msgConfirm("munmap() returned %d", retval); - exit(1); - } - close(fd); - } - close(1); - msgDebug("Extract of %s finished!!!\n", path); - exit(0); - } - close(pfd[1]); - return(pfd[0]); -} - static int genericHook(char *str, DeviceType type) { diff --git a/usr.sbin/sysinstall/network.c b/usr.sbin/sysinstall/network.c index 187e14c..d6ac179 100644 --- a/usr.sbin/sysinstall/network.c +++ b/usr.sbin/sysinstall/network.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: network.c,v 1.1 1995/05/27 10:38:58 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -43,12 +43,7 @@ * */ -/* - * These routines deal with getting things off of floppy media, though - * with one exception: genericGetDist() is actually used from lots of places - * since it can think of the world as just "one big floppy" too if that's - * appropriate. - */ +/* These routines deal with getting things off of network media */ #include "sysinstall.h" diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h index 98adb0b..7ca3c9d 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.36 1995/05/27 10:47:42 jkh Exp $ + * $Id: sysinstall.h,v 1.37 1995/05/27 23:39:32 phk Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -357,7 +357,6 @@ extern const u_char koi8_r2cp866[]; extern u_char default_scrnmap[]; /* media.c */ -extern int genericGetDist(char *path, Attribs *dist_attrib, Boolean prompt); extern int mediaSetCDROM(char *str); extern int mediaSetFloppy(char *str); extern int mediaSetDOS(char *str); diff --git a/usr.sbin/sysinstall/tape.c b/usr.sbin/sysinstall/tape.c index 6fb6c69..48088a7 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: tape.c,v 1.1 1995/05/27 10:39:02 jkh Exp $ + * $Id: tape.c,v 1.2 1995/05/27 23:39:33 phk Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -43,12 +43,7 @@ * */ -/* - * These routines deal with getting things off of floppy media, though - * with one exception: genericGetDist() is actually used from lots of places - * since it can think of the world as just "one big floppy" too if that's - * appropriate. - */ +/* These routines deal with getting things off of tape media */ #include "sysinstall.h" diff --git a/usr.sbin/sysinstall/tcpip.c b/usr.sbin/sysinstall/tcpip.c index 0d55801..3779ddc 100644 --- a/usr.sbin/sysinstall/tcpip.c +++ b/usr.sbin/sysinstall/tcpip.c @@ -1,5 +1,5 @@ /* - * $Id: tcpip.c,v 1.22 1995/05/27 23:39:34 phk Exp $ + * $Id: tcpip.c,v 1.23 1995/05/27 23:52:55 jkh Exp $ * * Copyright (c) 1995 * Gary J Palmer. All rights reserved. @@ -193,6 +193,7 @@ tcpOpenDialog(Device *devp) int max; char *tmp; char help[FILENAME_MAX]; + char title[80]; /* We need a curses window */ ds_win = newwin(LINES, COLS, 0, 0); @@ -206,8 +207,8 @@ tcpOpenDialog(Device *devp) /* Setup a nice screen for us to splat stuff onto */ draw_box(ds_win, TCP_DIALOG_Y, TCP_DIALOG_X, TCP_DIALOG_HEIGHT, TCP_DIALOG_WIDTH, dialog_attr, border_attr); wattrset(ds_win, dialog_attr); - mvprintw(ds_win, TCP_DIALOG_Y, TCP_DIALOG_X + 20, " Interface %s ", devp->name); - + sprintf(title, " Interface %s ", devp->name); + mvwaddstr(ds_win, TCP_DIALOG_Y, TCP_DIALOG_X + 20, title); draw_box(ds_win, TCP_DIALOG_Y + 9, TCP_DIALOG_X + 8, TCP_DIALOG_HEIGHT - 13, TCP_DIALOG_WIDTH - 17, dialog_attr, border_attr); wattrset(ds_win, dialog_attr); |