summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1995-05-04 07:00:57 +0000
committerphk <phk@FreeBSD.org>1995-05-04 07:00:57 +0000
commita0086bd08766f0b26016b7cc81ef7099d54f0324 (patch)
tree94c7de5da084ef7c3c2948cb0784a6a4f0d8c161 /lib
parentafc1e203457a4a033aab45e835fca9a8cfc6aeff (diff)
downloadFreeBSD-src-a0086bd08766f0b26016b7cc81ef7099d54f0324.zip
FreeBSD-src-a0086bd08766f0b26016b7cc81ef7099d54f0324.tar.gz
Make the partitions names even more sensible
CheckRules sets the CHUNK_ALIGN & CHUNK_PAST_1024 flags.
Diffstat (limited to 'lib')
-rw-r--r--lib/libdisk/Makefile2
-rw-r--r--lib/libdisk/create_chunk.c10
-rw-r--r--lib/libdisk/disk.c3
-rw-r--r--lib/libdisk/libdisk.h13
-rw-r--r--lib/libdisk/rules.c45
-rw-r--r--lib/libdisk/tst01.c4
-rw-r--r--lib/libdisk/write_disk.c10
7 files changed, 56 insertions, 31 deletions
diff --git a/lib/libdisk/Makefile b/lib/libdisk/Makefile
index 78ddded..8fc56f0 100644
--- a/lib/libdisk/Makefile
+++ b/lib/libdisk/Makefile
@@ -3,7 +3,7 @@ SRCS= blocks.c disklabel.c dkcksum.c chunk.c disk.c change.c \
create_chunk.c rules.c write_disk.c data.c
CFLAGS+= -Wall -g
-CLEANFILES+= tmp.c tst01 tst01.o
+CLEANFILES+= tmp.c tst01 tst01.o data.c
VPATH= ${.CURDIR}/../../sbin/disklabel
NOPROFILE= yes
NOSHARED= yes
diff --git a/lib/libdisk/create_chunk.c b/lib/libdisk/create_chunk.c
index 06d65ec..95ad84f 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.7 1995/05/03 06:30:50 phk Exp $
+ * $Id: create_chunk.c,v 1.8 1995/05/03 22:36:50 phk Exp $
*
*/
@@ -59,14 +59,16 @@ Fixup_FreeBSD_Names(struct disk *d, struct chunk *c)
for (c1 = c->part; c1 ; c1 = c1->next) {
for(c3 = c->part; c3 ; c3 = c3->next)
if (c1 != c3 && !strcmp(c3->name, c1->oname)) {
- strcpy(c1->name,c1->oname);
- break;
+ goto newname;
}
+ strcpy(c1->name,c1->oname);
+ newname:
}
+
/* Allocate the rest sequentially */
for (c1 = c->part; c1 ; c1 = c1->next) {
- const char order[] = "defghab";
+ const char order[] = "efghabd";
if (c1->type == unused) continue;
if (c1->type == reserved) continue;
if (strcmp("X",c1->name)) continue;
diff --git a/lib/libdisk/disk.c b/lib/libdisk/disk.c
index 5953986..d478465 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.14 1995/05/03 17:37:58 jkh Exp $
+ * $Id: disk.c,v 1.15 1995/05/03 22:36:51 phk Exp $
*
*/
@@ -137,7 +137,6 @@ Int_Open_Disk(char *name, u_long size)
ce = unknown;
break;
}
- flags |= CHUNK_ALIGN;
if (Add_Chunk(d,ds.dss_slices[i].ds_offset,
ds.dss_slices[i].ds_size, sname,ce,subtype,flags))
warn("failed to add chunk for slice %d",i - 1);
diff --git a/lib/libdisk/libdisk.h b/lib/libdisk/libdisk.h
index dfe5db0..06eec58 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.10 1995/05/03 17:37:59 jkh Exp $
+ * $Id: libdisk.h,v 1.11 1995/05/03 22:36:52 phk Exp $
*
*/
@@ -48,7 +48,9 @@ struct chunk {
int subtype;
u_long flags;
# define CHUNK_PAST_1024 1
- /* this chunk cannot be booted from */
+ /* this chunk cannot be booted from because it
+ * extends past cylinder 1024
+ */
# define CHUNK_BSD_COMPAT 2
/* this chunk is in the BSD-compatibility, and has a
* short name too, ie wd0s4f -> wd0f
@@ -56,8 +58,11 @@ struct chunk {
# define CHUNK_BAD144 4
/* this chunk has bad144 mapping */
# define CHUNK_ALIGN 8
+ /* This chunk should be aligned */
# define CHUNK_IS_ROOT 16
/* This 'part' is a rootfs, allocate 'a' */
+# define CHUNK_ACTIVE 32
+ /* This is the active slice in the MBR */
void (*private_free)(void*);
void *(*private_clone)(void*);
@@ -211,8 +216,6 @@ void Fixup_Names(struct disk *);
*
* Make sure only FreeBSD start at offset==0
*
- * Make sure all MBR+extended children are aligned at create.
- *
* Collapse must align.
*
* Make Write_Disk(struct disk*)
@@ -225,7 +228,7 @@ void Fixup_Names(struct disk *);
*
* Make Is_Unchanged(struct disk *d1, struct chunk *c1)
*
- * Make Set_Active_Slice()
+ * don't rename slices unless we have to
*
*Sample output from tst01:
*
diff --git a/lib/libdisk/rules.c b/lib/libdisk/rules.c
index 04bdfd8..de86a03 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.4 1995/04/30 06:09:27 phk Exp $
+ * $Id: rules.c,v 1.5 1995/05/03 06:30:59 phk Exp $
*
*/
@@ -75,32 +75,35 @@ Next_Cyl_Aligned(struct disk *d, u_long offset)
/*
* Rule#0:
* Chunks of type 'whole' can have max NDOSPART children.
+ * Only one of them can have the "active" flag
*/
void
Rule_000(struct disk *d, struct chunk *c, char *msg)
{
- int i;
+ int i=0,j=0;
struct chunk *c1;
if (c->type != whole)
return;
- for (i=0, c1=c->part; c1; c1=c1->next) {
- if (c1->type != reserved)
- continue;
- if (c1->type != reserved)
- continue;
+ for (c1=c->part; c1; c1=c1->next) {
+ if (c1->type != unused) continue;
+ if (c1->type != reserved) continue;
+ if (c1->flags & CHUNK_ACTIVE)
+ j++;
i++;
}
- if (i <= NDOSPART)
- return;
- sprintf(msg+strlen(msg),
- "%d is too many children of the 'whole' chunk. Max is %d\n",
- i, NDOSPART);
+ if (i > NDOSPART)
+ sprintf(msg+strlen(msg),
+ "%d is too many children of the 'whole' chunk. Max is %d\n",
+ i, NDOSPART);
+ if (j > 1)
+ sprintf(msg+strlen(msg),
+ "Too many active children of 'whole'");
}
/*
* Rule#1:
- * All children of 'whole' must be track-aligned.
+ * All children of 'whole' and 'extended' must be track-aligned.
* Exception: the end can be unaligned if it matches the end of 'whole'
*/
void
@@ -109,18 +112,22 @@ Rule_001(struct disk *d, struct chunk *c, char *msg)
int i;
struct chunk *c1;
- if (c->type != whole)
+ if (c->type != whole && c->type != extended)
return;
for (i=0, c1=c->part; c1; c1=c1->next) {
if (c1->type == reserved)
continue;
if (c1->type == unused)
continue;
+ c1->flags |= CHUNK_ALIGN;
if (!Track_Aligned(d,c1->offset))
sprintf(msg+strlen(msg),
"chunk '%s' [%ld..%ld] does not start on a track boundary\n",
c1->name,c1->offset,c1->end);
- if (c->end != c1->end && !Cyl_Aligned(d,c1->end+1))
+ if ((c->type == whole || c->end == c1->end)
+ || Cyl_Aligned(d,c1->end+1))
+ ;
+ else
sprintf(msg+strlen(msg),
"chunk '%s' [%ld..%ld] does not end on a cylinder boundary\n",
c1->name,c1->offset,c1->end);
@@ -176,6 +183,8 @@ Rule_003(struct disk *d, struct chunk *c, char *msg)
/*
* Rule#4:
* Max seven 'part' as children of 'freebsd'
+ * Max one FS_SWAP child per 'freebsd'
+ * Max one CHUNK_IS_ROOT child per 'freebsd'
*/
void
Rule_004(struct disk *d, struct chunk *c, char *msg)
@@ -220,7 +229,11 @@ Check_Chunk(struct disk *d, struct chunk *c, char *msg)
Check_Chunk(d,c->part,msg);
if (c->next)
Check_Chunk(d,c->next,msg);
- return;
+
+ if (c->end >= 1024*d->bios_hd*d->bios_sect)
+ c->flags |= CHUNK_PAST_1024;
+ else
+ c->flags &= ~CHUNK_PAST_1024;
}
char *
diff --git a/lib/libdisk/tst01.c b/lib/libdisk/tst01.c
index 5e98a98..6670963 100644
--- a/lib/libdisk/tst01.c
+++ b/lib/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.8 1995/05/01 04:05:26 phk Exp $
+ * $Id: tst01.c,v 1.9 1995/05/03 17:38:00 jkh Exp $
*
*/
@@ -141,8 +141,8 @@ main(int argc, char **argv)
sprintf(myprompt,"%s %s> ",argv[0],argv[1]);
while(1) {
printf("--==##==--\n");
- Debug_Disk(d);
p = CheckRules(d);
+ Debug_Disk(d);
if (p) {
printf("%s",p);
free(p);
diff --git a/lib/libdisk/write_disk.c b/lib/libdisk/write_disk.c
index 818076a..61dd1ac 100644
--- a/lib/libdisk/write_disk.c
+++ b/lib/libdisk/write_disk.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: write_disk.c,v 1.4 1995/04/30 11:04:16 phk Exp $
+ * $Id: write_disk.c,v 1.6 1995/05/01 04:05:27 phk Exp $
*
*/
@@ -163,8 +163,10 @@ Write_Disk(struct disk *d1)
dp[j].dp_ssect |= i >> 2;
}
+#ifdef DEBUG
printf("S:%lu = (%x/%x/%x)",
c1->offset,dp[j].dp_scyl,dp[j].dp_shd,dp[j].dp_ssect);
+#endif
i = c1->end;
dp[j].dp_esect = i % d1->bios_sect;
@@ -178,10 +180,16 @@ Write_Disk(struct disk *d1)
i -= dp[j].dp_ecyl;
dp[j].dp_esect |= i >> 2;
+#ifdef DEBUG
printf(" E:%lu = (%x/%x/%x)\n",
c1->end,dp[j].dp_ecyl,dp[j].dp_ehd,dp[j].dp_esect);
+#endif
dp[j].dp_typ = c1->subtype;
+ if (c1->flags & CHUNK_ACTIVE)
+ dp[j].dp_flag = 0x80;
+ else
+ dp[j].dp_flag = 0;
}
for(i=0;i<NDOSPART;i++)
if (!s[i])
OpenPOWER on IntegriCloud