summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>2002-01-07 07:47:25 +0000
committerdillon <dillon@FreeBSD.org>2002-01-07 07:47:25 +0000
commit2a7ecd5129c4ef23b82b687a60c1f0279eddfa25 (patch)
tree4cdd36dd2454bfb041aa52facb39ee386d5e869b /lib
parent14705316d2de14cf05110abf6ae92bafba674396 (diff)
downloadFreeBSD-src-2a7ecd5129c4ef23b82b687a60c1f0279eddfa25.zip
FreeBSD-src-2a7ecd5129c4ef23b82b687a60c1f0279eddfa25.tar.gz
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/libdisk/chunk.c12
-rw-r--r--lib/libdisk/libdisk.h9
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/libdisk/chunk.c b/lib/libdisk/chunk.c
index b2e9d3d..a2b18ec 100644
--- a/lib/libdisk/chunk.c
+++ b/lib/libdisk/chunk.c
@@ -361,6 +361,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;
long offset = c->offset;
@@ -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 7281f8e..737d366 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[];
@@ -142,6 +145,12 @@ Sanitize_Bios_Geom(struct disk *disk);
*/
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
*/
OpenPOWER on IntegriCloud