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.
This commit is contained in:
Matthew Dillon 2002-01-07 07:47:25 +00:00
parent db38d34abb
commit d010343b82
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=88995
2 changed files with 20 additions and 1 deletions

View File

@ -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;
}

View File

@ -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