Get the CHUNK_COMPAT_BSD flag right.

This commit is contained in:
Poul-Henning Kamp 1995-05-11 05:22:54 +00:00
parent 4767b31211
commit 8f9c995787
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=8436
6 changed files with 88 additions and 98 deletions

View File

@ -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("-");

View File

@ -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) {
c2->flags &= ~CHUNK_BSD_COMPAT;
if (c2->type == unused)
continue;
if (strcmp(c2->name,"X"))
continue;
c2->oname = malloc(12);
if(!c2->oname) err(1,"malloc failed");
for(j=1;j<=NDOSPART;j++) {
sprintf(c2->oname,"%ss%d",c1->name,j);
for(c3 = c1->part; c3 ; c3 = c3->next)
if (c3 != c2 && !strcmp(c3->name, c2->oname))
goto match;
free(c2->name);
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;
}
}
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);
if (c2->type == unused)
continue;
p = malloc(12);
if(!p) err(1,"malloc failed");
for(j=1;j<=NDOSPART;j++) {
sprintf(p,"%ss%d",c1->name,j);
for(c3 = c1->part; c3 ; c3 = c3->next)
if (c3 != c2 && !strcmp(c3->name, p))
goto match;
free(c2->name);
c2->name = p;
p = 0;
break;
match:
continue;
}
if(p)
free(p);
}
}
@ -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;

View File

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

View File

@ -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("-");

View File

@ -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) {
c2->flags &= ~CHUNK_BSD_COMPAT;
if (c2->type == unused)
continue;
if (strcmp(c2->name,"X"))
continue;
c2->oname = malloc(12);
if(!c2->oname) err(1,"malloc failed");
for(j=1;j<=NDOSPART;j++) {
sprintf(c2->oname,"%ss%d",c1->name,j);
for(c3 = c1->part; c3 ; c3 = c3->next)
if (c3 != c2 && !strcmp(c3->name, c2->oname))
goto match;
free(c2->name);
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;
}
}
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);
if (c2->type == unused)
continue;
p = malloc(12);
if(!p) err(1,"malloc failed");
for(j=1;j<=NDOSPART;j++) {
sprintf(p,"%ss%d",c1->name,j);
for(c3 = c1->part; c3 ; c3 = c3->next)
if (c3 != c2 && !strcmp(c3->name, p))
goto match;
free(c2->name);
c2->name = p;
p = 0;
break;
match:
continue;
}
if(p)
free(p);
}
}
@ -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;

View File

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