diff options
| author | Matthew Dillon <dillon@FreeBSD.org> | 2002-01-07 07:47:25 +0000 |
|---|---|---|
| committer | Matthew Dillon <dillon@FreeBSD.org> | 2002-01-07 07:47:25 +0000 |
| commit | d010343b8241df25267354260d67e037033629ee (patch) | |
| tree | 4cdd36dd2454bfb041aa52facb39ee386d5e869b | |
| parent | db38d34abb9c75c9f2ea382a419ec9669d48004f (diff) | |
Notes
| -rw-r--r-- | lib/libdisk/chunk.c | 12 | ||||
| -rw-r--r-- | lib/libdisk/libdisk.h | 9 |
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/libdisk/chunk.c b/lib/libdisk/chunk.c index b2e9d3d9860e..a2b18ec25157 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 7281f8ee8c06..737d3660fad3 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 */ |
