diff options
-rw-r--r-- | lib/libdisk/Makefile | 19 | ||||
-rw-r--r-- | lib/libdisk/create_chunk.c | 53 | ||||
-rw-r--r-- | lib/libdisk/disk.c | 7 | ||||
-rw-r--r-- | lib/libdisk/libdisk.h | 4 | ||||
-rw-r--r-- | lib/libdisk/rules.c | 20 | ||||
-rw-r--r-- | release/libdisk/Makefile | 19 | ||||
-rw-r--r-- | release/libdisk/create_chunk.c | 53 | ||||
-rw-r--r-- | release/libdisk/disk.c | 7 | ||||
-rw-r--r-- | release/libdisk/libdisk.h | 4 | ||||
-rw-r--r-- | release/libdisk/rules.c | 20 |
10 files changed, 120 insertions, 86 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 <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 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; + + /* 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 (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(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 (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++) { 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;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; } diff --git a/lib/libdisk/libdisk.h b/lib/libdisk/libdisk.h index 99956967919f..8758178a9419 100644 --- a/lib/libdisk/libdisk.h +++ b/lib/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.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 * diff --git a/lib/libdisk/rules.c b/lib/libdisk/rules.c index ef50415e15ba..04bdfd8c6de7 100644 --- a/lib/libdisk/rules.c +++ b/lib/libdisk/rules.c @@ -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"); } } 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 <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 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; + + /* 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 (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(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 (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++) { 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;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; } diff --git a/release/libdisk/libdisk.h b/release/libdisk/libdisk.h index 99956967919f..8758178a9419 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.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 * diff --git a/release/libdisk/rules.c b/release/libdisk/rules.c index ef50415e15ba..04bdfd8c6de7 100644 --- a/release/libdisk/rules.c +++ b/release/libdisk/rules.c @@ -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"); } } |