summaryrefslogtreecommitdiffstats
path: root/lib/libdisk/create_chunk.c
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>2001-05-13 20:08:54 +0000
committerjkh <jkh@FreeBSD.org>2001-05-13 20:08:54 +0000
commit5b33a2af7cc4f8e49951b70e1fc5b616876450a6 (patch)
treeac04e3b0eea5f057863e3c3ee8b4637d07f2adb8 /lib/libdisk/create_chunk.c
parentc6db5e77fc9682b938a8776c6e2c8cbda527cd2c (diff)
downloadFreeBSD-src-5b33a2af7cc4f8e49951b70e1fc5b616876450a6.zip
FreeBSD-src-5b33a2af7cc4f8e49951b70e1fc5b616876450a6.tar.gz
+ add u_long sector_size to struct disk (documented in libdisk.3)
+ make Open_Disk sense the sector size by trying 512, 1024 and 2048 in this order. This makes the kernel note that dscheck(cd1): bio_bcount 512 is not on a sector boundary (ssize 2048) dscheck(cd1): bio_bcount 1024 is not on a sector boundary (ssize 2048) if 2048 is the sector size. If this worries anyone: the message is from /usr/src/sys/kern/subr_diskslice.c and shutups are to be placed there. + Have read_block and write_block use an additional parameter, the sector size. + replace all barfout calls with return NULL, 0, __LINE__, etc. Note that this does NOT emit diagnostics. More often than not, you don't want library functions to scribble on stderr -- it may not even be available. The right thing is to propagate the error condition to upper management. The app should take care of errors. + use d1->sector_size instead of 512 in various places. I've left many places untouched, especially those writing MBRs. I simply added another arg hardcoded as 512. This is because I would not know what I'm doing... I felt this approach would be reasonably backward compatible and not introduce any new bugs in critical software. Famous last words. Messing with MBRs might soon put me in the same screwup meister category as, uh, never mind. :-) + bump the max no of disks from 20 to 32 (due to PR 24503). PR: 8434 / 8436 / 24503 Submitted by: Jens Schweikhardt <schweikh@schweikhardt.net>
Diffstat (limited to 'lib/libdisk/create_chunk.c')
-rw-r--r--lib/libdisk/create_chunk.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/libdisk/create_chunk.c b/lib/libdisk/create_chunk.c
index 6a4ded3..366e373 100644
--- a/lib/libdisk/create_chunk.c
+++ b/lib/libdisk/create_chunk.c
@@ -56,19 +56,19 @@ msgDebug(char *fmt, ...)
write(DebugFD, dbg, strlen(dbg));
}
-void
+int
Fixup_FreeBSD_Names(struct disk *d, struct chunk *c)
{
struct chunk *c1, *c3;
int j;
- if (!strcmp(c->name, "X")) return;
+ if (!strcmp(c->name, "X")) return 0;
/* reset all names to "X" */
for (c1 = c->part; c1; c1 = c1->next) {
c1->oname = c1->name;
c1->name = malloc(12);
- if(!c1->name) barfout(1, "Malloc failed");
+ if(!c1->name) return -1;
strcpy(c1->name,"X");
}
@@ -96,7 +96,7 @@ Fixup_FreeBSD_Names(struct disk *d, struct chunk *c)
goto newname;
}
strcpy(c1->name, c1->oname);
- newname:
+ newname: ;
}
@@ -121,9 +121,10 @@ Fixup_FreeBSD_Names(struct disk *d, struct chunk *c)
free(c1->oname);
c1->oname = 0;
}
+ return 0;
}
-void
+int
Fixup_Extended_Names(struct disk *d, struct chunk *c)
{
struct chunk *c1;
@@ -133,14 +134,16 @@ Fixup_Extended_Names(struct disk *d, struct chunk *c)
if (c1->type == unused) continue;
free(c1->name);
c1->name = malloc(12);
- if(!c1->name) barfout(1, "malloc failed");
+ if(!c1->name) return -1;
sprintf(c1->name, "%ss%d", d->chunks->name, j++);
if (c1->type == freebsd)
- Fixup_FreeBSD_Names(d, c1);
+ if (Fixup_FreeBSD_Names(d, c1) != 0)
+ return -1;
}
+ return 0;
}
-void
+int
Fixup_Names(struct disk *d)
{
struct chunk *c1, *c2;
@@ -159,7 +162,7 @@ Fixup_Names(struct disk *d)
continue;
#ifdef __i386__
c2->oname = malloc(12);
- if(!c2->oname) barfout(1, "malloc failed");
+ if(!c2->oname) return -1;
for(j = 1; j <= NDOSPART; j++) {
sprintf(c2->oname, "%ss%d", c1->name, j);
for(c3 = c1->part; c3; c3 = c3->next)
@@ -193,6 +196,7 @@ Fixup_Names(struct disk *d)
Fixup_Extended_Names(d, c2);
#endif
}
+ return 0;
}
int
@@ -263,7 +267,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;
- barfout(1, "Serious internal trouble");
+ /* barfout(1, "Serious internal trouble"); */
return 0;
}
OpenPOWER on IntegriCloud