summaryrefslogtreecommitdiffstats
path: root/release/libdisk
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1995-05-11 05:22:54 +0000
committerphk <phk@FreeBSD.org>1995-05-11 05:22:54 +0000
commit2e780cd86fd6e41356091d32a0e60b54d737f8d3 (patch)
treec4acd58166be0977f64200c6b3779bbb24931b2f /release/libdisk
parenta558882de6fc93c6cd240cfae7fbca856a958d92 (diff)
downloadFreeBSD-src-2e780cd86fd6e41356091d32a0e60b54d737f8d3.zip
FreeBSD-src-2e780cd86fd6e41356091d32a0e60b54d737f8d3.tar.gz
Get the CHUNK_COMPAT_BSD flag right.
Diffstat (limited to 'release/libdisk')
-rw-r--r--release/libdisk/chunk.c5
-rw-r--r--release/libdisk/create_chunk.c74
-rw-r--r--release/libdisk/tst01.c6
3 files changed, 40 insertions, 45 deletions
diff --git a/release/libdisk/chunk.c b/release/libdisk/chunk.c
index 54630be..c100927 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.10 1995/05/07 01:28:16 jkh Exp $
+ * $Id: chunk.c,v 1.11 1995/05/08 02:08:25 phk Exp $
*
*/
@@ -200,6 +200,8 @@ Add_Chunk(struct disk *d, long offset, u_long size, char *name, chunk_e type,
c1->subtype = subtype;
return 0;
}
+ if (type == freebsd)
+ subtype = 0xa5;
c1 = 0;
if(!c1 && (type == freebsd || type == fat || type == unknown))
c1 = Find_Mother_Chunk(d->chunks,offset,end,extended);
@@ -380,6 +382,7 @@ Collapse_Chunk(struct disk *d, struct chunk *c1)
}
if(c3->type == unused) {
c2 = new_chunk();
+ if (!c2) err(1,"malloc failed");
*c2 = *c1;
c1->next = c2;
c1->name = strdup("-");
diff --git a/release/libdisk/create_chunk.c b/release/libdisk/create_chunk.c
index 4d530f4..7af5218 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.12 1995/05/08 01:26:47 phk Exp $
+ * $Id: create_chunk.c,v 1.13 1995/05/10 05:57:02 phk Exp $
*
*/
@@ -91,31 +91,17 @@ Fixup_FreeBSD_Names(struct disk *d, struct chunk *c)
void
Fixup_Extended_Names(struct disk *d, struct chunk *c)
{
- struct chunk *c1, *c3;
- int j;
- char *p=0;
+ struct chunk *c1;
+ int j=5;
for (c1 = c->part; c1 ; c1 = c1->next) {
+ if (c1->type == unused) continue;
+ free(c1->name);
+ c1->name = malloc(12);
+ if(!c1->name) err(1,"malloc failed");
+ sprintf(c1->name,"%ss%d",c->name,j++);
if (c1->type == freebsd)
Fixup_FreeBSD_Names(d,c1);
- if (c1->type == unused) continue;
- if (strcmp(c1->name, "X")) continue;
- for(j=5;j<=29;j++) {
- p = malloc(12);
- if(!p) err(1,"malloc failed");
- sprintf(p,"%ss%d",c->name,j);
- for(c3 = c->part; c3 ; c3 = c3->next)
- if (c3 != c1 && !strcmp(c3->name, p))
- goto match;
- free(c1->name);
- c1->name = p;
- p = 0;
- break;
- match:
- continue;
- }
- if(p)
- free(p);
}
}
@@ -124,32 +110,42 @@ Fixup_Names(struct disk *d)
{
struct chunk *c1, *c2, *c3;
int i,j;
- char *p=0;
c1 = d->chunks;
for(i=1,c2 = c1->part; c2 ; c2 = c2->next) {
- if (c2->type == freebsd)
- Fixup_FreeBSD_Names(d,c2);
- if (c2->type == extended)
- Fixup_Extended_Names(d,c2);
+ c2->flags &= ~CHUNK_BSD_COMPAT;
if (c2->type == unused)
continue;
- p = malloc(12);
- if(!p) err(1,"malloc failed");
+ if (strcmp(c2->name,"X"))
+ continue;
+ c2->oname = malloc(12);
+ if(!c2->oname) err(1,"malloc failed");
for(j=1;j<=NDOSPART;j++) {
- sprintf(p,"%ss%d",c1->name,j);
+ sprintf(c2->oname,"%ss%d",c1->name,j);
for(c3 = c1->part; c3 ; c3 = c3->next)
- if (c3 != c2 && !strcmp(c3->name, p))
+ if (c3 != c2 && !strcmp(c3->name, c2->oname))
goto match;
free(c2->name);
- c2->name = p;
- p = 0;
+ c2->name = c2->oname;
+ c2->oname = 0;
+ break;
+ match:
+ continue;
+ }
+ if (c2->oname)
+ free(c2->oname);
+ }
+ for(c2 = c1->part; c2 ; c2 = c2->next) {
+ if (c2->type == freebsd) {
+ c2->flags |= CHUNK_BSD_COMPAT;
break;
- match:
- continue;
}
- if(p)
- free(p);
+ }
+ for(c2 = c1->part; c2 ; c2 = c2->next) {
+ if (c2->type == freebsd)
+ Fixup_FreeBSD_Names(d,c2);
+ if (c2->type == extended)
+ Fixup_Extended_Names(d,c2);
}
}
@@ -158,8 +154,6 @@ Create_Chunk(struct disk *d, u_long offset, u_long size, chunk_e type, int subty
{
int i;
- if (type == freebsd)
- subtype = 0xa5;
i = Add_Chunk(d,offset,size,"X",type,subtype,flags);
Fixup_Names(d);
return i;
@@ -174,8 +168,6 @@ Create_Chunk_DWIM(struct disk *d, struct chunk *parent , u_long size, chunk_e ty
if (!parent)
parent = d->chunks;
- if (type == freebsd)
- subtype = 0xa5;
for (c1=parent->part; c1 ; c1 = c1->next) {
if (c1->type != unused) continue;
if (c1->size < size) continue;
diff --git a/release/libdisk/tst01.c b/release/libdisk/tst01.c
index b32253a..43a6364 100644
--- a/release/libdisk/tst01.c
+++ b/release/libdisk/tst01.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: tst01.c,v 1.10 1995/05/04 07:00:56 phk Exp $
+ * $Id: tst01.c,v 1.11 1995/05/10 05:57:04 phk Exp $
*
*/
@@ -171,11 +171,11 @@ main(int argc, char **argv)
if (!strcasecmp(*cmds,"dwim") && ncmd == 6) {
printf("dwim = %p\n",
Create_Chunk_DWIM(d,
- (struct chunk *)strtol(cmds[1],0,0)),
+ (struct chunk *)strtol(cmds[1],0,0),
strtol(cmds[2],0,0),
strtol(cmds[3],0,0),
strtol(cmds[4],0,0),
- strtol(cmds[5],0,0) );
+ strtol(cmds[5],0,0)));
continue;
}
if (!strcasecmp(*cmds,"delete") && ncmd == 2) {
OpenPOWER on IntegriCloud