diff options
author | phk <phk@FreeBSD.org> | 1995-05-10 05:57:04 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1995-05-10 05:57:04 +0000 |
commit | b06a2da1188043774a21f325c65893b1dd1937ba (patch) | |
tree | a7a3e845ea2cb1759f8334a843c91f607580ff3b /lib/libdisk/create_chunk.c | |
parent | f900359daa37c3aa08178cd6a7f487d8bdde66ac (diff) | |
download | FreeBSD-src-b06a2da1188043774a21f325c65893b1dd1937ba.zip FreeBSD-src-b06a2da1188043774a21f325c65893b1dd1937ba.tar.gz |
Create_Chunk_DWIM() is here, though it doesn't quite do what the name implies.
Diffstat (limited to 'lib/libdisk/create_chunk.c')
-rw-r--r-- | lib/libdisk/create_chunk.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/lib/libdisk/create_chunk.c b/lib/libdisk/create_chunk.c index 2ce62e9..4d530f4 100644 --- a/lib/libdisk/create_chunk.c +++ b/lib/libdisk/create_chunk.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: create_chunk.c,v 1.11 1995/05/08 00:44:46 phk Exp $ + * $Id: create_chunk.c,v 1.12 1995/05/08 01:26:47 phk Exp $ * */ @@ -164,3 +164,35 @@ Create_Chunk(struct disk *d, u_long offset, u_long size, chunk_e type, int subty Fixup_Names(d); return i; } + +struct chunk * +Create_Chunk_DWIM(struct disk *d, struct chunk *parent , u_long size, chunk_e type, int subtype, u_long flags) +{ + int i; + struct chunk *c1; + u_long offset; + + if (!parent) + parent = d->chunks; + if (type == freebsd) + subtype = 0xa5; + for (c1=parent->part; c1 ; c1 = c1->next) { + if (c1->type != unused) continue; + if (c1->size < size) continue; + offset = c1->offset; + goto found; + } + warn("Not enough unused space"); + return 0; + found: + i = Add_Chunk(d,offset,size,"X",type,subtype,flags); + if (i) { + warn("Didn't cut it"); + return 0; + } + Fixup_Names(d); + for (c1=parent->part; c1 ; c1 = c1->next) + if (c1->offset == offset) + return c1; + err(1,"Serious internal trouble"); +} |