From 2a7ecd5129c4ef23b82b687a60c1f0279eddfa25 Mon Sep 17 00:00:00 2001 From: dillon Date: Mon, 7 Jan 2002 07:47:25 +0000 Subject: [PATCH] Modify Delete_Chunk() into Delete_Chunk2() which can take a flags argument. Leave a compatibility shim for Delete_Chunk(). Implement DELCHUNK_RECOVER flag so sysinstall can ask libdisk to recover space when deleting a chunk. --- lib/libdisk/chunk.c | 12 +++++++++++- lib/libdisk/libdisk.h | 9 +++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/libdisk/chunk.c b/lib/libdisk/chunk.c index b2e9d3d9860..a2b18ec2515 100644 --- a/lib/libdisk/chunk.c +++ b/lib/libdisk/chunk.c @@ -360,6 +360,12 @@ Debug_Chunk(struct chunk *c1) int Delete_Chunk(struct disk *d, struct chunk *c) +{ + return(Delete_Chunk2(d, c, 0)); +} + +int +Delete_Chunk2(struct disk *d, struct chunk *c, int rflags) { struct chunk *c1=0, *c2, *c3; chunk_e type = c->type; @@ -402,11 +408,15 @@ Delete_Chunk(struct disk *d, struct chunk *c) /* * Collapse multiple unused elements together, and attempt * to extend the previous chunk into the freed chunk. + * + * We only extend non-unused elements which are marked + * for newfs (we can't extend working filesystems), and + * only if we are called with DELCHUNK_RECOVER. */ for(c2 = c1->part; c2; c2 = c2->next) { if (c2->type != unused) { if (c2->offset + c2->size != offset || - (c2->flags & CHUNK_AUTO_SIZE) == 0 || + (rflags & DELCHUNK_RECOVER) == 0 || (c2->flags & CHUNK_NEWFS) == 0) { continue; } diff --git a/lib/libdisk/libdisk.h b/lib/libdisk/libdisk.h index 7281f8ee8c0..737d3660fad 100644 --- a/lib/libdisk/libdisk.h +++ b/lib/libdisk/libdisk.h @@ -103,6 +103,9 @@ struct chunk { #define CHUNK_AUTO_SIZE 0x0080 #define CHUNK_NEWFS 0x0100 +#define DELCHUNK_NORMAL 0x0000 +#define DELCHUNK_RECOVER 0x0001 + extern const char *chunk_n[]; @@ -141,6 +144,12 @@ Sanitize_Bios_Geom(struct disk *disk); /* Set the bios geometry to something sane */ +int +Delete_Chunk2(struct disk *disk, struct chunk *, int flags); +/* Free a chunk of disk_space modified by the passed + * flags. + */ + int Delete_Chunk(struct disk *disk, struct chunk *); /* Free a chunk of disk_space -- 2.45.0