diff options
author | jkh <jkh@FreeBSD.org> | 1995-05-08 21:39:40 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1995-05-08 21:39:40 +0000 |
commit | 1aa6f0255a93cada013e339b339895f4d6c1b066 (patch) | |
tree | bbc7db4913e184339a9fef242727b484f56afaa6 | |
parent | db10ed51dd5e2127eff1c14b27784304cce58d3e (diff) | |
download | FreeBSD-src-1aa6f0255a93cada013e339b339895f4d6c1b066.zip FreeBSD-src-1aa6f0255a93cada013e339b339895f4d6c1b066.tar.gz |
Sync these up so that they'll get into my CVS tree at home, where I'll continue
working on the distribution extract stuff.
-rw-r--r-- | release/sysinstall/devices.c | 30 | ||||
-rw-r--r-- | release/sysinstall/dist.c | 43 | ||||
-rw-r--r-- | release/sysinstall/globals.c | 6 | ||||
-rw-r--r-- | release/sysinstall/install.c | 11 | ||||
-rw-r--r-- | release/sysinstall/misc.c | 18 | ||||
-rw-r--r-- | release/sysinstall/sysinstall.h | 6 | ||||
-rw-r--r-- | usr.sbin/sade/devices.c | 30 | ||||
-rw-r--r-- | usr.sbin/sade/globals.c | 6 | ||||
-rw-r--r-- | usr.sbin/sade/install.c | 11 | ||||
-rw-r--r-- | usr.sbin/sade/misc.c | 18 | ||||
-rw-r--r-- | usr.sbin/sade/sade.h | 6 | ||||
-rw-r--r-- | usr.sbin/sysinstall/devices.c | 30 | ||||
-rw-r--r-- | usr.sbin/sysinstall/dist.c | 43 | ||||
-rw-r--r-- | usr.sbin/sysinstall/globals.c | 6 | ||||
-rw-r--r-- | usr.sbin/sysinstall/install.c | 11 | ||||
-rw-r--r-- | usr.sbin/sysinstall/misc.c | 18 | ||||
-rw-r--r-- | usr.sbin/sysinstall/sysinstall.h | 6 |
17 files changed, 255 insertions, 44 deletions
diff --git a/release/sysinstall/devices.c b/release/sysinstall/devices.c index a087fdf..6fa547a 100644 --- a/release/sysinstall/devices.c +++ b/release/sysinstall/devices.c @@ -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.10 1995/05/08 01:27:06 jkh Exp $ + * $Id: devices.c,v 1.11 1995/05/08 10:20:46 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -47,6 +47,14 @@ /* Where we start displaying chunk information on the screen */ #define CHUNK_START_ROW 5 +static char *cdrom_table[] = { + "cd0a", "cd1a", /* SCSI */ + "mcd0a", "mcd1a", /* Mitsumi (old model) */ + "scd0a", "scd1a", /* Sony CDROM */ + "matcd0a", "matcd1a", /* Matsushita (SB) */ + NULL, +}; + /* Get all device information for a given device class */ static Device * device_get_all(DeviceType which, int *ndevs) @@ -66,11 +74,27 @@ device_get_all(DeviceType which, int *ndevs) strcpy(devs[i].name, names[i]); devs[i].type = DEVICE_TYPE_DISK; } - devs[i].name[0] = '\0'; free(names); } } - /* put detection for other classes here just as soon as I figure out how */ + if (which == DEVICE_TYPE_CDROM || which == DEVICE_TYPE_ANY) { + char try[FILENAME_MAX]; + int i, fd; + + for (i = 0; cdrom_table[i]; i++) { + snprintf(try, FILENAME_MAX, "/mnt/dev/%s", cdrom_table[i]); + fd = open(try); + if (fd > 0) { + close(fd); + devs = safe_realloc(devs, sizeof(Device) * (*ndevs + 2)); + strcpy(devs[*ndevs].name, cdrom_table[i]); + devs[(*ndevs)++].type = DEVICE_TYPE_CDROM; + break; + } + } + } + /* Terminate the devices array */ + devs[*ndevs].name[0] = '\0'; return devs; } diff --git a/release/sysinstall/dist.c b/release/sysinstall/dist.c index 2733bb2..90b592d 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: install.c,v 1.5 1995/05/04 03:51:16 jkh Exp $ + * $Id: dist.c,v 1.1 1995/05/04 19:48:10 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -90,3 +90,44 @@ distSetEverything(char *str) SrcDists = DIST_SRC_ALL; return 0; } + +struct { + char *my_name; + unsigned int my_bit; +} DistTable[] = { +{ "bin", DIST_BIN }, +{ "games", DIST_GAMES }, +{ "manpages", DIST_MANPAGES }, +{ "proflibs", DIST_PROFLIBS }, +{ "dict", DIST_DICT }, +{ "src", DIST_SRC }, +{ "des", DIST_DES }, +{ "compat1x", DIST_COMPAT1X }, +{ "xf86311l", DIST_XFREE86 }, +{ NULL, 0 }, +}; + +Boolean +dist_extract(char *name) +{ + int fd; + + return FALSE; +} + +void +distExtractAll(void) +{ + int i, fd; + + while (Dists) { + for (i = 0; DistTable[i].my_name; i++) { + if (Dists & DistTable[i].my_bit) { + if (dist_extract(DistTable[i].my_name)) + Dists &= ~DistTable[i].my_bit; + else + continue; + } + } + } +} diff --git a/release/sysinstall/globals.c b/release/sysinstall/globals.c index 587ffe6..7fc4436 100644 --- a/release/sysinstall/globals.c +++ b/release/sysinstall/globals.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: globals.c,v 1.1.1.1 1995/04/27 12:50:34 jkh Exp $ + * $Id: globals.c,v 1.2 1995/05/06 09:34:16 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -56,6 +56,8 @@ Boolean DialogActive; Boolean ColorDisplay; Boolean OnVTY; Variable *VarHead; /* The head of the variable chain */ +DeviceType MediaType; /* Where we're installing from */ +char *MediaDevice; /* More detail on how to find it */ /* * Yes, I know some of these are already automatically initialized as @@ -72,5 +74,7 @@ globalsInit(void) OnVTY = FALSE; DialogActive = FALSE; VarHead = NULL; + MediaType = DEVICE_TYPE_NONE; + MediaDevice = NULL; } diff --git a/release/sysinstall/install.c b/release/sysinstall/install.c index ab68f1e..45a5f3c 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.11 1995/05/08 06:06:25 jkh Exp $ + * $Id: install.c,v 1.12 1995/05/08 10:20:51 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -86,8 +86,10 @@ installHook(char *str) for (i = 0; Disks[i]; i++) Disks[i] = device_slice_disk(Disks[i]); + /* Whap partitions on all the FreeBSD slices created */ partition_disks(); + /* Try and write it out */ if (!write_disks()) { int scroll, choice, curr, max; @@ -95,7 +97,7 @@ installHook(char *str) scroll = choice = curr = max = 0; dmenuOpen(&MenuInstall, &choice, &scroll, &curr, &max); cpio_extract(); - extract_dists(); + distExtractAll(); install_configuration_files(); do_final_setup(); SystemWasInstalled = TRUE; @@ -243,11 +245,6 @@ cpio_extract(void) } void -extract_dists(void) -{ -} - -void install_configuration_files(void) { } diff --git a/release/sysinstall/misc.c b/release/sysinstall/misc.c index 794c498..500b454 100644 --- a/release/sysinstall/misc.c +++ b/release/sysinstall/misc.c @@ -1,7 +1,7 @@ /* * Miscellaneous support routines.. * - * $Id: misc.c,v 1.2 1995/04/29 19:33:04 jkh Exp $ + * $Id: misc.c,v 1.3 1995/05/01 21:56:27 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -104,12 +104,28 @@ safe_malloc(size_t size) { void *ptr; + if (size <= 0) + msgFatal("Invalid malloc size of %d!", size); ptr = malloc(size); if (!ptr) msgFatal("Out of memory!"); return ptr; } +/* A realloc that checks errors */ +void * +safe_realloc(void *orig, size_t size) +{ + void *ptr; + + if (size <= 0) + msgFatal("Invalid realloc size of %d!", size); + ptr = realloc(orig, size); + if (!ptr) + msgFatal("Out of memory!"); + return ptr; +} + /* * These next routines are kind of specialized just for building string lists * for dialog_menu(). diff --git a/release/sysinstall/sysinstall.h b/release/sysinstall/sysinstall.h index f9e3ec7..1a29cc2 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.12 1995/05/08 06:06:28 jkh Exp $ + * $Id: sysinstall.h,v 1.13 1995/05/08 10:20:56 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -153,7 +153,7 @@ typedef struct _variable { } Variable; typedef enum { - DEVICE_TYPE_ANY, + DEVICE_TYPE_NONE, DEVICE_TYPE_DISK, DEVICE_TYPE_FLOPPY, DEVICE_TYPE_NETWORK, @@ -161,6 +161,7 @@ typedef enum { DEVICE_TYPE_TAPE, DEVICE_TYPE_SERIAL, DEVICE_TYPE_PARALLEL, + DEVICE_TYPE_ANY, } DeviceType; /* A "device" from sysinstall's point of view */ @@ -284,6 +285,7 @@ extern char *string_prune(char *str); extern char *string_skipwhite(char *str); extern void safe_free(void *ptr); extern void *safe_malloc(size_t size); +extern void *safe_realloc(void *orig, size_t size); extern char **item_add(char **list, char *item, int *curr, int *max); extern char **item_add_pair(char **list, char *item1, char *item2, int *curr, int *max); diff --git a/usr.sbin/sade/devices.c b/usr.sbin/sade/devices.c index a087fdf..6fa547a 100644 --- a/usr.sbin/sade/devices.c +++ b/usr.sbin/sade/devices.c @@ -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.10 1995/05/08 01:27:06 jkh Exp $ + * $Id: devices.c,v 1.11 1995/05/08 10:20:46 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -47,6 +47,14 @@ /* Where we start displaying chunk information on the screen */ #define CHUNK_START_ROW 5 +static char *cdrom_table[] = { + "cd0a", "cd1a", /* SCSI */ + "mcd0a", "mcd1a", /* Mitsumi (old model) */ + "scd0a", "scd1a", /* Sony CDROM */ + "matcd0a", "matcd1a", /* Matsushita (SB) */ + NULL, +}; + /* Get all device information for a given device class */ static Device * device_get_all(DeviceType which, int *ndevs) @@ -66,11 +74,27 @@ device_get_all(DeviceType which, int *ndevs) strcpy(devs[i].name, names[i]); devs[i].type = DEVICE_TYPE_DISK; } - devs[i].name[0] = '\0'; free(names); } } - /* put detection for other classes here just as soon as I figure out how */ + if (which == DEVICE_TYPE_CDROM || which == DEVICE_TYPE_ANY) { + char try[FILENAME_MAX]; + int i, fd; + + for (i = 0; cdrom_table[i]; i++) { + snprintf(try, FILENAME_MAX, "/mnt/dev/%s", cdrom_table[i]); + fd = open(try); + if (fd > 0) { + close(fd); + devs = safe_realloc(devs, sizeof(Device) * (*ndevs + 2)); + strcpy(devs[*ndevs].name, cdrom_table[i]); + devs[(*ndevs)++].type = DEVICE_TYPE_CDROM; + break; + } + } + } + /* Terminate the devices array */ + devs[*ndevs].name[0] = '\0'; return devs; } diff --git a/usr.sbin/sade/globals.c b/usr.sbin/sade/globals.c index 587ffe6..7fc4436 100644 --- a/usr.sbin/sade/globals.c +++ b/usr.sbin/sade/globals.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: globals.c,v 1.1.1.1 1995/04/27 12:50:34 jkh Exp $ + * $Id: globals.c,v 1.2 1995/05/06 09:34:16 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -56,6 +56,8 @@ Boolean DialogActive; Boolean ColorDisplay; Boolean OnVTY; Variable *VarHead; /* The head of the variable chain */ +DeviceType MediaType; /* Where we're installing from */ +char *MediaDevice; /* More detail on how to find it */ /* * Yes, I know some of these are already automatically initialized as @@ -72,5 +74,7 @@ globalsInit(void) OnVTY = FALSE; DialogActive = FALSE; VarHead = NULL; + MediaType = DEVICE_TYPE_NONE; + MediaDevice = NULL; } diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c index ab68f1e..45a5f3c 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.11 1995/05/08 06:06:25 jkh Exp $ + * $Id: install.c,v 1.12 1995/05/08 10:20:51 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -86,8 +86,10 @@ installHook(char *str) for (i = 0; Disks[i]; i++) Disks[i] = device_slice_disk(Disks[i]); + /* Whap partitions on all the FreeBSD slices created */ partition_disks(); + /* Try and write it out */ if (!write_disks()) { int scroll, choice, curr, max; @@ -95,7 +97,7 @@ installHook(char *str) scroll = choice = curr = max = 0; dmenuOpen(&MenuInstall, &choice, &scroll, &curr, &max); cpio_extract(); - extract_dists(); + distExtractAll(); install_configuration_files(); do_final_setup(); SystemWasInstalled = TRUE; @@ -243,11 +245,6 @@ cpio_extract(void) } void -extract_dists(void) -{ -} - -void install_configuration_files(void) { } diff --git a/usr.sbin/sade/misc.c b/usr.sbin/sade/misc.c index 794c498..500b454 100644 --- a/usr.sbin/sade/misc.c +++ b/usr.sbin/sade/misc.c @@ -1,7 +1,7 @@ /* * Miscellaneous support routines.. * - * $Id: misc.c,v 1.2 1995/04/29 19:33:04 jkh Exp $ + * $Id: misc.c,v 1.3 1995/05/01 21:56:27 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -104,12 +104,28 @@ safe_malloc(size_t size) { void *ptr; + if (size <= 0) + msgFatal("Invalid malloc size of %d!", size); ptr = malloc(size); if (!ptr) msgFatal("Out of memory!"); return ptr; } +/* A realloc that checks errors */ +void * +safe_realloc(void *orig, size_t size) +{ + void *ptr; + + if (size <= 0) + msgFatal("Invalid realloc size of %d!", size); + ptr = realloc(orig, size); + if (!ptr) + msgFatal("Out of memory!"); + return ptr; +} + /* * These next routines are kind of specialized just for building string lists * for dialog_menu(). diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h index f9e3ec7..1a29cc2 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.12 1995/05/08 06:06:28 jkh Exp $ + * $Id: sysinstall.h,v 1.13 1995/05/08 10:20:56 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -153,7 +153,7 @@ typedef struct _variable { } Variable; typedef enum { - DEVICE_TYPE_ANY, + DEVICE_TYPE_NONE, DEVICE_TYPE_DISK, DEVICE_TYPE_FLOPPY, DEVICE_TYPE_NETWORK, @@ -161,6 +161,7 @@ typedef enum { DEVICE_TYPE_TAPE, DEVICE_TYPE_SERIAL, DEVICE_TYPE_PARALLEL, + DEVICE_TYPE_ANY, } DeviceType; /* A "device" from sysinstall's point of view */ @@ -284,6 +285,7 @@ extern char *string_prune(char *str); extern char *string_skipwhite(char *str); extern void safe_free(void *ptr); extern void *safe_malloc(size_t size); +extern void *safe_realloc(void *orig, size_t size); extern char **item_add(char **list, char *item, int *curr, int *max); extern char **item_add_pair(char **list, char *item1, char *item2, int *curr, int *max); diff --git a/usr.sbin/sysinstall/devices.c b/usr.sbin/sysinstall/devices.c index a087fdf..6fa547a 100644 --- a/usr.sbin/sysinstall/devices.c +++ b/usr.sbin/sysinstall/devices.c @@ -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.10 1995/05/08 01:27:06 jkh Exp $ + * $Id: devices.c,v 1.11 1995/05/08 10:20:46 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -47,6 +47,14 @@ /* Where we start displaying chunk information on the screen */ #define CHUNK_START_ROW 5 +static char *cdrom_table[] = { + "cd0a", "cd1a", /* SCSI */ + "mcd0a", "mcd1a", /* Mitsumi (old model) */ + "scd0a", "scd1a", /* Sony CDROM */ + "matcd0a", "matcd1a", /* Matsushita (SB) */ + NULL, +}; + /* Get all device information for a given device class */ static Device * device_get_all(DeviceType which, int *ndevs) @@ -66,11 +74,27 @@ device_get_all(DeviceType which, int *ndevs) strcpy(devs[i].name, names[i]); devs[i].type = DEVICE_TYPE_DISK; } - devs[i].name[0] = '\0'; free(names); } } - /* put detection for other classes here just as soon as I figure out how */ + if (which == DEVICE_TYPE_CDROM || which == DEVICE_TYPE_ANY) { + char try[FILENAME_MAX]; + int i, fd; + + for (i = 0; cdrom_table[i]; i++) { + snprintf(try, FILENAME_MAX, "/mnt/dev/%s", cdrom_table[i]); + fd = open(try); + if (fd > 0) { + close(fd); + devs = safe_realloc(devs, sizeof(Device) * (*ndevs + 2)); + strcpy(devs[*ndevs].name, cdrom_table[i]); + devs[(*ndevs)++].type = DEVICE_TYPE_CDROM; + break; + } + } + } + /* Terminate the devices array */ + devs[*ndevs].name[0] = '\0'; return devs; } diff --git a/usr.sbin/sysinstall/dist.c b/usr.sbin/sysinstall/dist.c index 2733bb2..90b592d 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: install.c,v 1.5 1995/05/04 03:51:16 jkh Exp $ + * $Id: dist.c,v 1.1 1995/05/04 19:48:10 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -90,3 +90,44 @@ distSetEverything(char *str) SrcDists = DIST_SRC_ALL; return 0; } + +struct { + char *my_name; + unsigned int my_bit; +} DistTable[] = { +{ "bin", DIST_BIN }, +{ "games", DIST_GAMES }, +{ "manpages", DIST_MANPAGES }, +{ "proflibs", DIST_PROFLIBS }, +{ "dict", DIST_DICT }, +{ "src", DIST_SRC }, +{ "des", DIST_DES }, +{ "compat1x", DIST_COMPAT1X }, +{ "xf86311l", DIST_XFREE86 }, +{ NULL, 0 }, +}; + +Boolean +dist_extract(char *name) +{ + int fd; + + return FALSE; +} + +void +distExtractAll(void) +{ + int i, fd; + + while (Dists) { + for (i = 0; DistTable[i].my_name; i++) { + if (Dists & DistTable[i].my_bit) { + if (dist_extract(DistTable[i].my_name)) + Dists &= ~DistTable[i].my_bit; + else + continue; + } + } + } +} diff --git a/usr.sbin/sysinstall/globals.c b/usr.sbin/sysinstall/globals.c index 587ffe6..7fc4436 100644 --- a/usr.sbin/sysinstall/globals.c +++ b/usr.sbin/sysinstall/globals.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: globals.c,v 1.1.1.1 1995/04/27 12:50:34 jkh Exp $ + * $Id: globals.c,v 1.2 1995/05/06 09:34:16 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -56,6 +56,8 @@ Boolean DialogActive; Boolean ColorDisplay; Boolean OnVTY; Variable *VarHead; /* The head of the variable chain */ +DeviceType MediaType; /* Where we're installing from */ +char *MediaDevice; /* More detail on how to find it */ /* * Yes, I know some of these are already automatically initialized as @@ -72,5 +74,7 @@ globalsInit(void) OnVTY = FALSE; DialogActive = FALSE; VarHead = NULL; + MediaType = DEVICE_TYPE_NONE; + MediaDevice = NULL; } diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c index ab68f1e..45a5f3c 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.11 1995/05/08 06:06:25 jkh Exp $ + * $Id: install.c,v 1.12 1995/05/08 10:20:51 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -86,8 +86,10 @@ installHook(char *str) for (i = 0; Disks[i]; i++) Disks[i] = device_slice_disk(Disks[i]); + /* Whap partitions on all the FreeBSD slices created */ partition_disks(); + /* Try and write it out */ if (!write_disks()) { int scroll, choice, curr, max; @@ -95,7 +97,7 @@ installHook(char *str) scroll = choice = curr = max = 0; dmenuOpen(&MenuInstall, &choice, &scroll, &curr, &max); cpio_extract(); - extract_dists(); + distExtractAll(); install_configuration_files(); do_final_setup(); SystemWasInstalled = TRUE; @@ -243,11 +245,6 @@ cpio_extract(void) } void -extract_dists(void) -{ -} - -void install_configuration_files(void) { } diff --git a/usr.sbin/sysinstall/misc.c b/usr.sbin/sysinstall/misc.c index 794c498..500b454 100644 --- a/usr.sbin/sysinstall/misc.c +++ b/usr.sbin/sysinstall/misc.c @@ -1,7 +1,7 @@ /* * Miscellaneous support routines.. * - * $Id: misc.c,v 1.2 1995/04/29 19:33:04 jkh Exp $ + * $Id: misc.c,v 1.3 1995/05/01 21:56:27 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -104,12 +104,28 @@ safe_malloc(size_t size) { void *ptr; + if (size <= 0) + msgFatal("Invalid malloc size of %d!", size); ptr = malloc(size); if (!ptr) msgFatal("Out of memory!"); return ptr; } +/* A realloc that checks errors */ +void * +safe_realloc(void *orig, size_t size) +{ + void *ptr; + + if (size <= 0) + msgFatal("Invalid realloc size of %d!", size); + ptr = realloc(orig, size); + if (!ptr) + msgFatal("Out of memory!"); + return ptr; +} + /* * These next routines are kind of specialized just for building string lists * for dialog_menu(). diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h index f9e3ec7..1a29cc2 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.12 1995/05/08 06:06:28 jkh Exp $ + * $Id: sysinstall.h,v 1.13 1995/05/08 10:20:56 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -153,7 +153,7 @@ typedef struct _variable { } Variable; typedef enum { - DEVICE_TYPE_ANY, + DEVICE_TYPE_NONE, DEVICE_TYPE_DISK, DEVICE_TYPE_FLOPPY, DEVICE_TYPE_NETWORK, @@ -161,6 +161,7 @@ typedef enum { DEVICE_TYPE_TAPE, DEVICE_TYPE_SERIAL, DEVICE_TYPE_PARALLEL, + DEVICE_TYPE_ANY, } DeviceType; /* A "device" from sysinstall's point of view */ @@ -284,6 +285,7 @@ extern char *string_prune(char *str); extern char *string_skipwhite(char *str); extern void safe_free(void *ptr); extern void *safe_malloc(size_t size); +extern void *safe_realloc(void *orig, size_t size); extern char **item_add(char **list, char *item, int *curr, int *max); extern char **item_add_pair(char **list, char *item1, char *item2, int *curr, int *max); |