summaryrefslogtreecommitdiffstats
path: root/lib/libdisk
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2002-12-02 21:42:29 +0000
committerjhb <jhb@FreeBSD.org>2002-12-02 21:42:29 +0000
commitcfb76a599318018df7d879ef19e4b9e5872adb08 (patch)
tree4ec6b557080c4694c383e311c7de89b826c71b99 /lib/libdisk
parent0204959e2c86b09fe10009bb6318fe13afdc2c74 (diff)
downloadFreeBSD-src-cfb76a599318018df7d879ef19e4b9e5872adb08.zip
FreeBSD-src-cfb76a599318018df7d879ef19e4b9e5872adb08.tar.gz
Break up a bunch of crazy if statements to use a case statement instead
to be cleaner. Also, when deleting a chunk, try to find the mother chunk as a whole chunk by default if this isn't a BSD partition or a unused or whole chunk. Before we just did this for FreeBSD and FAT slices, which means that other chunk types such as EFI and mbr (mbr is used for slices that don't have their own chunk type). Submitted by: nyan (mostly) Approved by: re
Diffstat (limited to 'lib/libdisk')
-rw-r--r--lib/libdisk/chunk.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/lib/libdisk/chunk.c b/lib/libdisk/chunk.c
index 49df0e5..ee15a49 100644
--- a/lib/libdisk/chunk.c
+++ b/lib/libdisk/chunk.c
@@ -416,25 +416,27 @@ Delete_Chunk(struct disk *d, struct chunk *c)
int
Delete_Chunk2(struct disk *d, struct chunk *c, int rflags)
{
- struct chunk *c1 = 0, *c2, *c3;
- chunk_e type = c->type;
+ struct chunk *c1, *c2, *c3;
u_long offset = c->offset;
- if(type == whole)
+ switch (c->type) {
+ case whole:
+ case unused:
return 1;
-#ifndef PC98
- if (!c1 && (type == freebsd || type == fat || type == unknown))
- c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, extended);
-#endif
- if (!c1 && (type == freebsd || type == fat || type == unknown))
- c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, whole);
-#ifndef PC98
- if (!c1 && type == extended)
+ case extended:
c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, whole);
-#endif
- if (!c1 && type == part)
+ break;
+ case part:
c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, freebsd);
- if (!c1)
+ break;
+ default:
+ c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, extended);
+ if (c1 == NULL)
+ c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end,
+ whole);
+ break;
+ }
+ if (c1 == NULL)
return 1;
for (c2 = c1->part; c2; c2 = c2->next) {
if (c2 == c) {
OpenPOWER on IntegriCloud