From 533d214b966f695a9fa4dee381b20aa03e6b4a91 Mon Sep 17 00:00:00 2001 From: jhb Date: Fri, 10 Jan 2003 19:25:38 +0000 Subject: - Make New_Disk() non-static so it can be used in Create_Chunk_DWIM(). - In Create_Chunk_DWIM(), if there is a freebsd chunk that has no children chunks, then trying to add a child part chunk will fail even though there is free space. Handle this special case by adding an unused chunk the full size of the freebsd chunk as a child of the freebsd chunk before adding the new part chunk. This situation can happen when changing the type of an existing slice to be a FreeBSD slice type or when installing onto a blank disk on Alpha (which has no slices.) Reviewed by: phk MFC after: 2 days --- lib/libdisk/create_chunk.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'lib/libdisk/create_chunk.c') diff --git a/lib/libdisk/create_chunk.c b/lib/libdisk/create_chunk.c index dfccb9d..8ce9057 100644 --- a/lib/libdisk/create_chunk.c +++ b/lib/libdisk/create_chunk.c @@ -33,6 +33,8 @@ __FBSDID("$FreeBSD$"); #include #include "libdisk.h" +struct chunk *New_Chunk(void); + static int Fixup_FreeBSD_Names(struct disk *d, struct chunk *c) { @@ -215,7 +217,7 @@ Create_Chunk(struct disk *d, u_long offset, u_long size, chunk_e type, } struct chunk * -Create_Chunk_DWIM(struct disk *d, const struct chunk *parent , u_long size, +Create_Chunk_DWIM(struct disk *d, struct chunk *parent, u_long size, chunk_e type, int subtype, u_long flags) { int i; @@ -224,6 +226,22 @@ Create_Chunk_DWIM(struct disk *d, const struct chunk *parent , u_long size, if (!parent) parent = d->chunks; + + if (parent->type == freebsd && type == part && parent->part == NULL) { + c1 = New_Chunk(); + if (c1 == NULL) + return (NULL); + c1->disk = parent->disk; + c1->offset = parent->offset; + c1->size = parent->size; + c1->end = parent->offset + parent->size - 1; + c1->type = unused; + if (parent->sname != NULL) + c1->sname = strdup(parent->sname); + c1->name = strdup("-"); + parent->part = c1; + } + for (c1 = parent->part; c1; c1 = c1->next) { if (c1->type != unused) continue; -- cgit v1.1