From fcdd2c3c7df0c8c6c5d4ad141ab5094bba6a72dd Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Wed, 3 May 1995 06:30:59 +0000 Subject: [PATCH] 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. --- lib/libdisk/Makefile | 19 ++---------- lib/libdisk/create_chunk.c | 55 +++++++++++++++++++++------------- lib/libdisk/disk.c | 7 +++-- lib/libdisk/libdisk.h | 4 ++- lib/libdisk/rules.c | 20 ++++++++++--- release/libdisk/Makefile | 19 ++---------- release/libdisk/create_chunk.c | 55 +++++++++++++++++++++------------- release/libdisk/disk.c | 7 +++-- release/libdisk/libdisk.h | 4 ++- release/libdisk/rules.c | 20 ++++++++++--- 10 files changed, 122 insertions(+), 88 deletions(-) diff --git a/lib/libdisk/Makefile b/lib/libdisk/Makefile index aaf6116fbca2..78dddedbe744 100644 --- a/lib/libdisk/Makefile +++ b/lib/libdisk/Makefile @@ -10,21 +10,8 @@ NOSHARED= yes .include -# 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 diff --git a/lib/libdisk/create_chunk.c b/lib/libdisk/create_chunk.c index a2027e2e7cbd..9e3a079488c5 100644 --- a/lib/libdisk/create_chunk.c +++ b/lib/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.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;jname,"%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++) { diff --git a/lib/libdisk/disk.c b/lib/libdisk/disk.c index e0701ce7de45..03c30c5b3f47 100644 --- a/lib/libdisk/disk.c +++ b/lib/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.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;itype != 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"); } } diff --git a/release/libdisk/Makefile b/release/libdisk/Makefile index aaf6116fbca2..78dddedbe744 100644 --- a/release/libdisk/Makefile +++ b/release/libdisk/Makefile @@ -10,21 +10,8 @@ NOSHARED= yes .include -# 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 diff --git a/release/libdisk/create_chunk.c b/release/libdisk/create_chunk.c index a2027e2e7cbd..9e3a079488c5 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.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;jname,"%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++) { diff --git a/release/libdisk/disk.c b/release/libdisk/disk.c index e0701ce7de45..03c30c5b3f47 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.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;itype != 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"); } }