diff options
author | obrien <obrien@FreeBSD.org> | 2001-03-18 21:30:11 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2001-03-18 21:30:11 +0000 |
commit | 981727ddcf88331bb90ab6e04eb90eb45c5f5314 (patch) | |
tree | 6f19e1a756fa276db4c8bf3e3a32f6cdd5215541 /lib | |
parent | 68ae8502935dde5a352a4351e99bb281e64be0b5 (diff) | |
download | FreeBSD-src-981727ddcf88331bb90ab6e04eb90eb45c5f5314.zip FreeBSD-src-981727ddcf88331bb90ab6e04eb90eb45c5f5314.tar.gz |
Libraries should _never_ call exit() themselves (or its alternate spelling
`err()'). libdisk does! and additionally libdisk gets confused on Alpha
disks with foreign disklabels, throws up its hands and exits. This is
the cause of the "going no where without my init" install bug on the Alpha.
So now on the Alpha, rather than call err(), we print the error string and
continue processing.
Submitted by: jkh
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libdisk/blocks.c | 11 | ||||
-rw-r--r-- | lib/libdisk/change.c | 1 | ||||
-rw-r--r-- | lib/libdisk/chunk.c | 15 | ||||
-rw-r--r-- | lib/libdisk/create_chunk.c | 9 | ||||
-rw-r--r-- | lib/libdisk/disk.c | 19 | ||||
-rw-r--r-- | lib/libdisk/disklabel.c | 1 | ||||
-rw-r--r-- | lib/libdisk/libdisk.h | 8 | ||||
-rw-r--r-- | lib/libdisk/rules.c | 1 | ||||
-rw-r--r-- | lib/libdisk/write_disk.c | 1 |
9 files changed, 33 insertions, 33 deletions
diff --git a/lib/libdisk/blocks.c b/lib/libdisk/blocks.c index 10f5b31..28e6a5f 100644 --- a/lib/libdisk/blocks.c +++ b/lib/libdisk/blocks.c @@ -13,7 +13,6 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> -#include <err.h> #include "libdisk.h" void * @@ -23,11 +22,11 @@ read_block(int fd, daddr_t block) foo = malloc(512); if (!foo) - err(1,"malloc"); + barfout(1,"malloc"); if (-1 == lseek(fd, (off_t)block * 512, SEEK_SET)) - err(1, "lseek"); + barfout(1, "lseek"); if (512 != read(fd,foo, 512)) - err(1,"read"); + barfout(1,"read"); return foo; } @@ -35,7 +34,7 @@ void write_block(int fd, daddr_t block, void *foo) { if (-1 == lseek(fd, (off_t)block * 512, SEEK_SET)) - err(1, "lseek"); + barfout(1, "lseek"); if (512 != write(fd,foo, 512)) - err(1,"write"); + barfout(1,"write"); } diff --git a/lib/libdisk/change.c b/lib/libdisk/change.c index 80296a9..a010f33 100644 --- a/lib/libdisk/change.c +++ b/lib/libdisk/change.c @@ -15,7 +15,6 @@ #include <unistd.h> #include <fcntl.h> #include <string.h> -#include <err.h> #include <sys/types.h> #include "libdisk.h" diff --git a/lib/libdisk/chunk.c b/lib/libdisk/chunk.c index 424382a..a8f3b96 100644 --- a/lib/libdisk/chunk.c +++ b/lib/libdisk/chunk.c @@ -15,7 +15,6 @@ #include <unistd.h> #include <string.h> #include <sys/types.h> -#include <err.h> #include "libdisk.h" #define new_chunk() memset(malloc(sizeof(struct chunk)), 0, sizeof(struct chunk)) @@ -97,7 +96,7 @@ Clone_Chunk(struct chunk *c1) if(!c1) return 0; c2 = new_chunk(); - if (!c2) err(1,"malloc failed"); + if (!c2) barfout(1,"malloc failed"); *c2 = *c1; if (c1->private_data && c1->private_clone) c2->private_data = c2->private_clone(c2->private_data); @@ -126,7 +125,7 @@ Insert_Chunk(struct chunk *c2, u_long offset, u_long size, const char *name, return __LINE__; ct = new_chunk(); - if (!ct) err(1,"malloc failed"); + if (!ct) barfout(1,"malloc failed"); memset(ct,0,sizeof *ct); ct->disk = c2->disk; ct->offset = offset; @@ -147,7 +146,7 @@ Insert_Chunk(struct chunk *c2, u_long offset, u_long size, const char *name, if(type==freebsd || type==extended) { cs = new_chunk(); - if (!cs) err(1,"malloc failed"); + if (!cs) barfout(1,"malloc failed"); memset(cs,0,sizeof *cs); cs->disk = c2->disk; cs->offset = offset; @@ -164,7 +163,7 @@ Insert_Chunk(struct chunk *c2, u_long offset, u_long size, const char *name, /* Make a new chunk for any trailing unused space */ if (c2->end > ct->end) { cs = new_chunk(); - if (!cs) err(1,"malloc failed"); + if (!cs) barfout(1,"malloc failed"); *cs = *c2; cs->disk = c2->disk; cs->offset = ct->end + 1; @@ -222,10 +221,10 @@ Add_Chunk(struct disk *d, long offset, u_long size, const char *name, if (type == whole) { d->chunks = c1 = new_chunk(); - if (!c1) err(1,"malloc failed"); + if (!c1) barfout(1,"malloc failed"); memset(c1,0,sizeof *c1); c2 = c1->part = new_chunk(); - if (!c2) err(1,"malloc failed"); + if (!c2) barfout(1,"malloc failed"); memset(c2,0,sizeof *c2); c2->disk = c1->disk = d; c2->offset = c1->offset = offset; @@ -448,7 +447,7 @@ Collapse_Chunk(struct disk *d, struct chunk *c1) } if(c3->type == unused) { c2 = new_chunk(); - if (!c2) err(1,"malloc failed"); + if (!c2) barfout(1,"malloc failed"); *c2 = *c1; c1->next = c2; c1->disk = d; diff --git a/lib/libdisk/create_chunk.c b/lib/libdisk/create_chunk.c index 0a9984d..3f84619 100644 --- a/lib/libdisk/create_chunk.c +++ b/lib/libdisk/create_chunk.c @@ -22,7 +22,6 @@ #include <sys/diskslice.h> #include <sys/types.h> #include <sys/stat.h> -#include <err.h> #include <grp.h> #include <paths.h> #include <pwd.h> @@ -69,7 +68,7 @@ Fixup_FreeBSD_Names(struct disk *d, struct chunk *c) for (c1 = c->part; c1 ; c1 = c1->next) { c1->oname = c1->name; c1->name = malloc(12); - if(!c1->name) err(1,"Malloc failed"); + if(!c1->name) barfout(1,"Malloc failed"); strcpy(c1->name,"X"); } @@ -134,7 +133,7 @@ Fixup_Extended_Names(struct disk *d, struct chunk *c) if (c1->type == unused) continue; free(c1->name); c1->name = malloc(12); - if(!c1->name) err(1,"malloc failed"); + if(!c1->name) barfout(1,"malloc failed"); sprintf(c1->name,"%ss%d",d->chunks->name,j++); if (c1->type == freebsd) Fixup_FreeBSD_Names(d,c1); @@ -156,7 +155,7 @@ Fixup_Names(struct disk *d) continue; #ifndef __alpha__ c2->oname = malloc(12); - if(!c2->oname) err(1,"malloc failed"); + if(!c2->oname) barfout(1,"malloc failed"); for(j=1;j<=NDOSPART;j++) { sprintf(c2->oname,"%ss%d",c1->name,j); for(c3 = c1->part; c3 ; c3 = c3->next) @@ -260,7 +259,7 @@ Create_Chunk_DWIM(struct disk *d, struct chunk *parent , u_long size, chunk_e ty for (c1=parent->part; c1 ; c1 = c1->next) if (c1->offset == offset) return c1; - err(1,"Serious internal trouble"); + barfout(1,"Serious internal trouble"); } int diff --git a/lib/libdisk/disk.c b/lib/libdisk/disk.c index 4c0f685..45f117e 100644 --- a/lib/libdisk/disk.c +++ b/lib/libdisk/disk.c @@ -15,7 +15,6 @@ #include <unistd.h> #include <fcntl.h> #include <string.h> -#include <err.h> #include <sys/sysctl.h> #include <sys/types.h> #include <sys/stat.h> @@ -74,7 +73,7 @@ Int_Open_Disk(const char *name, u_long size) strcat(device,name); d = (struct disk *)malloc(sizeof *d); - if(!d) err(1,"malloc failed"); + if(!d) barfout(1,"malloc failed"); memset(d,0,sizeof *d); fd = open(device,O_RDONLY); @@ -415,7 +414,7 @@ Clone_Disk(struct disk *d) struct disk *d2; d2 = (struct disk*) malloc(sizeof *d2); - if(!d2) err(1,"malloc failed"); + if(!d2) barfout(1,"malloc failed"); *d2 = *d; d2->name = strdup(d2->name); d2->chunks = Clone_Chunk(d2->chunks); @@ -489,7 +488,7 @@ Disk_Names() disklist = (char *)malloc(listsize); error = sysctlbyname("kern.disks", disklist, &listsize, NULL, 0); if (error) - err(1, "sysctlbyname(\"kern.disks\") failed"); + barfout(1, "sysctlbyname(\"kern.disks\") failed"); k = 0; for (dp = disks; ((*dp = strsep(&disklist, " ")) != NULL) && k < MAX_NO_DISKS; k++, dp++); return disks; @@ -540,7 +539,7 @@ Set_Boot_Mgr(struct disk *d, const u_char *b, const size_t s) } else { d->bootipl_size = bootipl_size; d->bootipl = malloc(bootipl_size); - if(!d->bootipl) err(1,"malloc failed"); + if(!d->bootipl) barfout(1,"malloc failed"); memcpy(d->bootipl,bootipl,bootipl_size); } @@ -554,7 +553,7 @@ Set_Boot_Mgr(struct disk *d, const u_char *b, const size_t s) } else { d->bootmenu_size = bootmenu_size; d->bootmenu = malloc(bootmenu_size); - if(!d->bootmenu) err(1,"malloc failed"); + if(!d->bootmenu) barfout(1,"malloc failed"); memcpy(d->bootmenu,bootmenu,bootmenu_size); } #else @@ -568,7 +567,7 @@ Set_Boot_Mgr(struct disk *d, const u_char *b, const size_t s) } else { d->bootmgr_size = s; d->bootmgr = malloc(s); - if(!d->bootmgr) err(1,"malloc failed"); + if(!d->bootmgr) barfout(1,"malloc failed"); memcpy(d->bootmgr,b,s); } #endif @@ -580,16 +579,16 @@ Set_Boot_Blocks(struct disk *d, const u_char *b1, const u_char *b2) #if defined(__i386__) if (d->boot1) free(d->boot1); d->boot1 = malloc(512); - if(!d->boot1) err(1,"malloc failed"); + if(!d->boot1) barfout(1,"malloc failed"); memcpy(d->boot1,b1,512); if (d->boot2) free(d->boot2); d->boot2 = malloc(15*512); - if(!d->boot2) err(1,"malloc failed"); + if(!d->boot2) barfout(1,"malloc failed"); memcpy(d->boot2,b2,15*512); #elif defined(__alpha__) if (d->boot1) free(d->boot1); d->boot1 = malloc(15*512); - if(!d->boot1) err(1,"malloc failed"); + if(!d->boot1) barfout(1,"malloc failed"); memcpy(d->boot1,b1,15*512); #endif } diff --git a/lib/libdisk/disklabel.c b/lib/libdisk/disklabel.c index 2ee6503..a493d2a 100644 --- a/lib/libdisk/disklabel.c +++ b/lib/libdisk/disklabel.c @@ -13,7 +13,6 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> -#include <err.h> #include <sys/disklabel.h> #include "libdisk.h" diff --git a/lib/libdisk/libdisk.h b/lib/libdisk/libdisk.h index 0a33717..bea78ec 100644 --- a/lib/libdisk/libdisk.h +++ b/lib/libdisk/libdisk.h @@ -10,6 +10,14 @@ * */ +#ifdef __i386__ +#include <err.h> +#define barfout(n, errstr) err(n, errstr) +#else +#include <stdio.h> +#define barfout(n, errstr) fprintf(stderr, "\n\n\t***[ %s ]***\t\n\n", errstr) +#endif + #define MAX_NO_DISKS 20 /* Max # of disks Disk_Names() will return */ diff --git a/lib/libdisk/rules.c b/lib/libdisk/rules.c index 7319338..0dc26f7 100644 --- a/lib/libdisk/rules.c +++ b/lib/libdisk/rules.c @@ -17,7 +17,6 @@ #include <sys/types.h> #include <sys/diskslice.h> #include <sys/disklabel.h> -#include <err.h> #include "libdisk.h" int diff --git a/lib/libdisk/write_disk.c b/lib/libdisk/write_disk.c index 0d261ea..842b84a 100644 --- a/lib/libdisk/write_disk.c +++ b/lib/libdisk/write_disk.c @@ -15,7 +15,6 @@ #include <unistd.h> #include <fcntl.h> #include <string.h> -#include <err.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> |