diff options
author | phk <phk@FreeBSD.org> | 1995-05-03 22:36:52 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1995-05-03 22:36:52 +0000 |
commit | 3a333cad859d44b252ad9f74ed4e333d4c0eeaeb (patch) | |
tree | d3172256de629248edc621730939916b87dcf99f /release/libdisk | |
parent | 455d2a327bf7898d4a18138d09508e0f2318e82f (diff) | |
download | FreeBSD-src-3a333cad859d44b252ad9f74ed4e333d4c0eeaeb.zip FreeBSD-src-3a333cad859d44b252ad9f74ed4e333d4c0eeaeb.tar.gz |
Add the private void *pointer to the chunks, and the functions to manage it.
Make the reassignment of partition names less bogus.
Diffstat (limited to 'release/libdisk')
-rw-r--r-- | release/libdisk/chunk.c | 9 | ||||
-rw-r--r-- | release/libdisk/create_chunk.c | 21 | ||||
-rw-r--r-- | release/libdisk/disk.c | 4 | ||||
-rw-r--r-- | release/libdisk/libdisk.h | 15 |
4 files changed, 41 insertions, 8 deletions
diff --git a/release/libdisk/chunk.c b/release/libdisk/chunk.c index ef4192d..d49a94e 100644 --- a/release/libdisk/chunk.c +++ b/release/libdisk/chunk.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: chunk.c,v 1.4 1995/04/30 06:09:24 phk Exp $ + * $Id: chunk.c,v 1.5 1995/05/01 21:30:22 jkh Exp $ * */ @@ -79,6 +79,8 @@ Free_Chunk(struct chunk *c1) { /* XXX remove all chunks which "ref" us */ if(!c1) return; + if(c1->private && c1->private_free) + (*c1->private_free)(c1->private); if(c1->part) Free_Chunk(c1->part); if(c1->next) @@ -96,6 +98,8 @@ Clone_Chunk(struct chunk *c1) c2 = new_chunk(); if (!c2) err(1,"malloc failed"); *c2 = *c1; + if (c1->private && c1->private_clone) + c2->private_clone(c2->private); c2->name = strdup(c2->name); c2->next = Clone_Chunk(c2->next); c2->part = Clone_Chunk(c2->part); @@ -109,13 +113,12 @@ Insert_Chunk(struct chunk *c2, u_long offset, u_long size, char *name, chunk_e t ct = new_chunk(); if (!ct) err(1,"malloc failed"); + memset(ct,0,sizeof *ct); ct->offset = offset; ct->size = size; ct->end = offset + size - 1; ct->type = type; ct->name = strdup(name); - ct->next = 0; - ct->part = 0; ct->subtype = subtype; ct->flags = flags; diff --git a/release/libdisk/create_chunk.c b/release/libdisk/create_chunk.c index 9e3a079..06d65ec 100644 --- a/release/libdisk/create_chunk.c +++ b/release/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.6 1995/05/01 04:05:24 phk Exp $ + * $Id: create_chunk.c,v 1.7 1995/05/03 06:30:50 phk Exp $ * */ @@ -30,8 +30,12 @@ Fixup_FreeBSD_Names(struct disk *d, struct chunk *c) if (!strcmp(c->name, "X")) return; /* reset all names to "X" */ - for (c1 = c->part; c1 ; c1 = c1->next) + for (c1 = c->part; c1 ; c1 = c1->next) { + c1->oname = c1->name; + c1->name = malloc(12); + if(!c1->name) err(1,"Malloc failed"); strcpy(c1->name,"X"); + } /* Allocate the first swap-partition we find */ for (c1 = c->part; c1 ; c1 = c1->next) { @@ -51,6 +55,15 @@ Fixup_FreeBSD_Names(struct disk *d, struct chunk *c) break; } + /* Try to give them the same as they had before */ + for (c1 = c->part; c1 ; c1 = c1->next) { + for(c3 = c->part; c3 ; c3 = c3->next) + if (c1 != c3 && !strcmp(c3->name, c1->oname)) { + strcpy(c1->name,c1->oname); + break; + } + } + /* Allocate the rest sequentially */ for (c1 = c->part; c1 ; c1 = c1->next) { const char order[] = "defghab"; @@ -69,6 +82,10 @@ Fixup_FreeBSD_Names(struct disk *d, struct chunk *c) continue; } } + for (c1 = c->part; c1 ; c1 = c1->next) { + free(c1->oname); + c1->oname = 0; + } } void diff --git a/release/libdisk/disk.c b/release/libdisk/disk.c index 884a3ae..5953986 100644 --- a/release/libdisk/disk.c +++ b/release/libdisk/disk.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: disk.c,v 1.13 1995/05/03 06:30:55 phk Exp $ + * $Id: disk.c,v 1.14 1995/05/03 17:37:58 jkh Exp $ * */ @@ -186,7 +186,7 @@ Int_Open_Disk(char *name, u_long size) dl.d_partitions[j].p_size, pname,part, dl.d_partitions[j].p_fstype, - j == 0 ? CHUNK_IS_ROOT : 0) && j != 3) + 0) && j != 3) warn( "Failed to add chunk for partition %c [%lu,%lu]", j + 'a',dl.d_partitions[j].p_offset, diff --git a/release/libdisk/libdisk.h b/release/libdisk/libdisk.h index b3305a5..dfe5db0 100644 --- a/release/libdisk/libdisk.h +++ b/release/libdisk/libdisk.h @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: libdisk.h,v 1.9 1995/05/03 06:30:57 phk Exp $ + * $Id: libdisk.h,v 1.10 1995/05/03 17:37:59 jkh Exp $ * */ @@ -40,6 +40,10 @@ struct chunk { u_long size; u_long end; char *name; + char *oname; + /* Used during Fixup_Names() to avoid renaming more than + * absolutely needed. + */ chunk_e type; int subtype; u_long flags; @@ -54,6 +58,15 @@ struct chunk { # define CHUNK_ALIGN 8 # define CHUNK_IS_ROOT 16 /* This 'part' is a rootfs, allocate 'a' */ + + void (*private_free)(void*); + void *(*private_clone)(void*); + void *private; + /* For data private to the application, and the management + * thereof. If the functions are not provided, no storage + * management is done, Cloning will just copy the pointer + * and freeing will just forget it. + */ }; struct disk * |