Make the target for tst01 more sensible.

Remove bogus targets.
Allocate partition letters as follows:
	lowest offset "flags & CHUNK_IS_ROOT" gets 'a',
	lowest offset "subtype==FS_SWAP" gets 'b'
	the rest is allocated in offset order from this sequence "defghab".
This will generally make sense.
Added rules to complain if more than one CHUNK_IS_ROOT or more than one
FS_SWAP per FreeBSD chunk.
Set CHUNK_IS_ROOT on the 'a' partition in Open_Disk.
Run Fixup_Names in Open_Disk.
This commit is contained in:
Poul-Henning Kamp 1995-05-03 06:30:59 +00:00
parent 8d34651b6c
commit fcdd2c3c7d
10 changed files with 122 additions and 88 deletions

View File

@ -10,21 +10,8 @@ NOSHARED= yes
.include <bsd.lib.mk>
# Custom weird and funky targets that we'll leave here.
test: tst01
cp tst01 /0
./tst01 wd1
fd: tst01
-umount /dev/fd1
-umount /mnt
mount /dev/fd1 /mnt
strip tst01
gzip < tst01 > /mnt/stand/disklayout
chmod 755 /mnt/stand/disklayout
-umount /mnt
BOOTS=/usr/mdec
data.c:
file2c 'const unsigned char boot1[] = {' '};' \
< ${BOOTS}/boot1 > tmp.c
@ -32,5 +19,5 @@ data.c:
< ${BOOTS}/boot2 >> tmp.c
mv tmp.c data.c
tst01: tst01.o
cc ${CFLAGS} -static tst01.o -o tst01 -L${.CURDIR} -ldisk
tst01: tst01.o libdisk.a
cc ${CFLAGS} -static tst01.o -o tst01 libdisk.a

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.5 1995/04/30 11:04:12 phk Exp $
* $Id: create_chunk.c,v 1.6 1995/05/01 04:05:24 phk Exp $
*
*/
@ -26,31 +26,48 @@ Fixup_FreeBSD_Names(struct disk *d, struct chunk *c)
{
struct chunk *c1, *c3;
int j;
char *p=0;
if (!strcmp(c->name, "X")) return;
for (c1 = c->part; c1 ; c1 = c1->next) {
/* reset all names to "X" */
for (c1 = c->part; c1 ; c1 = c1->next)
strcpy(c1->name,"X");
/* Allocate the first swap-partition we find */
for (c1 = c->part; c1 ; c1 = c1->next) {
if (c1->type == unused) continue;
if (c1->type == reserved) continue;
if (strcmp(c1->name, "X")) continue;
for(j=0;j<8;j++) {
if (j == 2)
continue;
p = malloc(12);
if(!p) err(1,"malloc failed");
sprintf(p,"%s%c",c->name,j+'a');
if (c1->subtype != FS_SWAP) continue;
sprintf(c1->name,"%s%c",c->name,SWAP_PART+'a');
break;
}
/* Allocate the first root-partition we find */
for (c1 = c->part; c1 ; c1 = c1->next) {
if (c1->type == unused) continue;
if (c1->type == reserved) continue;
if (!(c1->flags & CHUNK_IS_ROOT)) continue;
sprintf(c1->name,"%s%c",c->name,0+'a');
break;
}
/* Allocate the rest sequentially */
for (c1 = c->part; c1 ; c1 = c1->next) {
const char order[] = "defghab";
if (c1->type == unused) continue;
if (c1->type == reserved) continue;
if (strcmp("X",c1->name)) continue;
for(j=0;j<strlen(order);j++) {
sprintf(c1->name,"%s%c",c->name,order[j]);
for(c3 = c->part; c3 ; c3 = c3->next)
if (c3 != c1 && !strcmp(c3->name, p))
if (c1 != c3 && !strcmp(c3->name, c1->name))
goto match;
free(c1->name);
c1->name = p;
p = 0;
break;
match:
continue;
match:
strcpy(c1->name,"X");
continue;
}
if(p)
free(p);
}
}
@ -103,8 +120,6 @@ Fixup_Names(struct disk *d)
continue;
if (c2->type == reserved)
continue;
if (strcmp(c2->name,"X"))
continue;
p = malloc(12);
if(!p) err(1,"malloc failed");
for(j=1;j<=NDOSPART;j++) {

View File

@ -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.11 1995/05/02 19:52:27 jkh Exp $
* $Id: disk.c,v 1.12 1995/05/02 20:16:16 jkh Exp $
*
*/
@ -65,7 +65,7 @@ Int_Open_Disk(char *name, u_long size)
return 0;
}
#if 0
#ifdef DEBUG
for(i=0;i<ds.dss_nslices;i++)
if(ds.dss_slices[i].ds_openmask)
printf(" open(%d)=0x%2x",
@ -174,7 +174,7 @@ Int_Open_Disk(char *name, u_long size)
dl.d_partitions[j].p_size,
pname,part,
dl.d_partitions[j].p_fstype,
0) && j != 3)
j == 0 ? CHUNK_IS_ROOT : 0) && j != 3)
warn(
"Failed to add chunk for partition %c [%lu,%lu]",
j + 'a',dl.d_partitions[j].p_offset,
@ -183,6 +183,7 @@ Int_Open_Disk(char *name, u_long size)
}
}
close(fd);
Fixup_Names(d);
return d;
}

View File

@ -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.7 1995/04/30 11:04:14 phk Exp $
* $Id: libdisk.h,v 1.8 1995/05/01 21:30:24 jkh Exp $
*
*/
@ -53,6 +53,8 @@ struct chunk {
# define CHUNK_BAD144 4
/* this chunk has bad144 mapping */
# define CHUNK_ALIGN 8
# define CHUNK_IS_ROOT 16
/* This 'part' is a rootfs, allocate 'a' */
};
struct disk *

View File

@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: rules.c,v 1.3 1995/04/29 07:21:12 phk Exp $
* $Id: rules.c,v 1.4 1995/04/30 06:09:27 phk Exp $
*
*/
@ -180,19 +180,31 @@ Rule_003(struct disk *d, struct chunk *c, char *msg)
void
Rule_004(struct disk *d, struct chunk *c, char *msg)
{
int i;
int i=0,j=0,k=0;
struct chunk *c1;
if (c->type != freebsd)
return;
for (i=0, c1=c->part; c1; c1=c1->next) {
for (c1=c->part; c1; c1=c1->next) {
if (c1->type != part)
continue;
if (c1->subtype == FS_SWAP)
j++;
if (c1->flags & CHUNK_IS_ROOT)
k++;
i++;
}
if (i > 7) {
sprintf(msg+strlen(msg),
"Max seven 'part' allowed as child of 'freebsd'\n");
"Max seven 'part' per 'freebsd' chunk\n");
}
if (j > 1) {
sprintf(msg+strlen(msg),
"Max one subtype=FS_SWAP child per 'freebsd' chunk\n");
}
if (k > 1) {
sprintf(msg+strlen(msg),
"Max one CHUNK_IS_ROOT child per 'freebsd' chunk\n");
}
}

View File

@ -10,21 +10,8 @@ NOSHARED= yes
.include <bsd.lib.mk>
# Custom weird and funky targets that we'll leave here.
test: tst01
cp tst01 /0
./tst01 wd1
fd: tst01
-umount /dev/fd1
-umount /mnt
mount /dev/fd1 /mnt
strip tst01
gzip < tst01 > /mnt/stand/disklayout
chmod 755 /mnt/stand/disklayout
-umount /mnt
BOOTS=/usr/mdec
data.c:
file2c 'const unsigned char boot1[] = {' '};' \
< ${BOOTS}/boot1 > tmp.c
@ -32,5 +19,5 @@ data.c:
< ${BOOTS}/boot2 >> tmp.c
mv tmp.c data.c
tst01: tst01.o
cc ${CFLAGS} -static tst01.o -o tst01 -L${.CURDIR} -ldisk
tst01: tst01.o libdisk.a
cc ${CFLAGS} -static tst01.o -o tst01 libdisk.a

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.5 1995/04/30 11:04:12 phk Exp $
* $Id: create_chunk.c,v 1.6 1995/05/01 04:05:24 phk Exp $
*
*/
@ -26,31 +26,48 @@ Fixup_FreeBSD_Names(struct disk *d, struct chunk *c)
{
struct chunk *c1, *c3;
int j;
char *p=0;
if (!strcmp(c->name, "X")) return;
for (c1 = c->part; c1 ; c1 = c1->next) {
/* reset all names to "X" */
for (c1 = c->part; c1 ; c1 = c1->next)
strcpy(c1->name,"X");
/* Allocate the first swap-partition we find */
for (c1 = c->part; c1 ; c1 = c1->next) {
if (c1->type == unused) continue;
if (c1->type == reserved) continue;
if (strcmp(c1->name, "X")) continue;
for(j=0;j<8;j++) {
if (j == 2)
continue;
p = malloc(12);
if(!p) err(1,"malloc failed");
sprintf(p,"%s%c",c->name,j+'a');
if (c1->subtype != FS_SWAP) continue;
sprintf(c1->name,"%s%c",c->name,SWAP_PART+'a');
break;
}
/* Allocate the first root-partition we find */
for (c1 = c->part; c1 ; c1 = c1->next) {
if (c1->type == unused) continue;
if (c1->type == reserved) continue;
if (!(c1->flags & CHUNK_IS_ROOT)) continue;
sprintf(c1->name,"%s%c",c->name,0+'a');
break;
}
/* Allocate the rest sequentially */
for (c1 = c->part; c1 ; c1 = c1->next) {
const char order[] = "defghab";
if (c1->type == unused) continue;
if (c1->type == reserved) continue;
if (strcmp("X",c1->name)) continue;
for(j=0;j<strlen(order);j++) {
sprintf(c1->name,"%s%c",c->name,order[j]);
for(c3 = c->part; c3 ; c3 = c3->next)
if (c3 != c1 && !strcmp(c3->name, p))
if (c1 != c3 && !strcmp(c3->name, c1->name))
goto match;
free(c1->name);
c1->name = p;
p = 0;
break;
match:
continue;
match:
strcpy(c1->name,"X");
continue;
}
if(p)
free(p);
}
}
@ -103,8 +120,6 @@ Fixup_Names(struct disk *d)
continue;
if (c2->type == reserved)
continue;
if (strcmp(c2->name,"X"))
continue;
p = malloc(12);
if(!p) err(1,"malloc failed");
for(j=1;j<=NDOSPART;j++) {

View File

@ -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.11 1995/05/02 19:52:27 jkh Exp $
* $Id: disk.c,v 1.12 1995/05/02 20:16:16 jkh Exp $
*
*/
@ -65,7 +65,7 @@ Int_Open_Disk(char *name, u_long size)
return 0;
}
#if 0
#ifdef DEBUG
for(i=0;i<ds.dss_nslices;i++)
if(ds.dss_slices[i].ds_openmask)
printf(" open(%d)=0x%2x",
@ -174,7 +174,7 @@ Int_Open_Disk(char *name, u_long size)
dl.d_partitions[j].p_size,
pname,part,
dl.d_partitions[j].p_fstype,
0) && j != 3)
j == 0 ? CHUNK_IS_ROOT : 0) && j != 3)
warn(
"Failed to add chunk for partition %c [%lu,%lu]",
j + 'a',dl.d_partitions[j].p_offset,
@ -183,6 +183,7 @@ Int_Open_Disk(char *name, u_long size)
}
}
close(fd);
Fixup_Names(d);
return d;
}

View File

@ -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.7 1995/04/30 11:04:14 phk Exp $
* $Id: libdisk.h,v 1.8 1995/05/01 21:30:24 jkh Exp $
*
*/
@ -53,6 +53,8 @@ struct chunk {
# define CHUNK_BAD144 4
/* this chunk has bad144 mapping */
# define CHUNK_ALIGN 8
# define CHUNK_IS_ROOT 16
/* This 'part' is a rootfs, allocate 'a' */
};
struct disk *

View File

@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: rules.c,v 1.3 1995/04/29 07:21:12 phk Exp $
* $Id: rules.c,v 1.4 1995/04/30 06:09:27 phk Exp $
*
*/
@ -180,19 +180,31 @@ Rule_003(struct disk *d, struct chunk *c, char *msg)
void
Rule_004(struct disk *d, struct chunk *c, char *msg)
{
int i;
int i=0,j=0,k=0;
struct chunk *c1;
if (c->type != freebsd)
return;
for (i=0, c1=c->part; c1; c1=c1->next) {
for (c1=c->part; c1; c1=c1->next) {
if (c1->type != part)
continue;
if (c1->subtype == FS_SWAP)
j++;
if (c1->flags & CHUNK_IS_ROOT)
k++;
i++;
}
if (i > 7) {
sprintf(msg+strlen(msg),
"Max seven 'part' allowed as child of 'freebsd'\n");
"Max seven 'part' per 'freebsd' chunk\n");
}
if (j > 1) {
sprintf(msg+strlen(msg),
"Max one subtype=FS_SWAP child per 'freebsd' chunk\n");
}
if (k > 1) {
sprintf(msg+strlen(msg),
"Max one CHUNK_IS_ROOT child per 'freebsd' chunk\n");
}
}