summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1995-05-05 07:07:45 +0000
committerphk <phk@FreeBSD.org>1995-05-05 07:07:45 +0000
commit2ef08387ece9dfb2b32d6216f5af056ae59dcd26 (patch)
tree7d657d7e1371248f8c92d9d0c4e549f66a6277e7
parent0011fb1aaea0a02fc1d274e1644f5be9e8a5eed8 (diff)
downloadFreeBSD-src-2ef08387ece9dfb2b32d6216f5af056ae59dcd26.zip
FreeBSD-src-2ef08387ece9dfb2b32d6216f5af056ae59dcd26.tar.gz
If in Create_Chunk we (type==freebsd && (flags&CHUNK_ALIGN)), then we will
align this chunk properly. Have at it Jordan...
-rw-r--r--lib/libdisk/chunk.c43
-rw-r--r--lib/libdisk/rules.c6
-rw-r--r--release/libdisk/chunk.c43
-rw-r--r--release/libdisk/rules.c6
4 files changed, 82 insertions, 16 deletions
diff --git a/lib/libdisk/chunk.c b/lib/libdisk/chunk.c
index d49a94e..0a07a5c 100644
--- a/lib/libdisk/chunk.c
+++ b/lib/libdisk/chunk.c
@@ -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.5 1995/05/01 21:30:22 jkh Exp $
+ * $Id: chunk.c,v 1.6 1995/05/03 22:36:49 phk Exp $
*
*/
@@ -18,8 +18,6 @@
#include <err.h>
#include "libdisk.h"
-CHAR_N;
-
#define new_chunk() malloc(sizeof(struct chunk))
/* Is c2 completely inside c1 ? */
@@ -218,8 +216,43 @@ Add_Chunk(struct disk *d, u_long offset, u_long size, char *name, chunk_e type,
for(c2=c1->part;c2;c2=c2->next) {
if (c2->type != unused)
continue;
- if(Chunk_Inside(c2,&ct))
- return Insert_Chunk(c2,offset,size,name,type,subtype,flags);
+ if(Chunk_Inside(c2,&ct)) {
+ if (type != freebsd)
+ goto doit;
+ if (!(flags & CHUNK_ALIGN))
+ goto doit;
+ if (offset == d->chunks->offset
+ && end == d->chunks->end)
+ goto doit;
+
+ /* Round down to prev cylinder */
+ offset = Prev_Cyl_Aligned(d,offset);
+ /* Stay inside the parent */
+ if (offset < c2->offset)
+ offset = c2->offset;
+ /* Round up to next cylinder */
+ offset = Next_Cyl_Aligned(d,offset);
+ /* Keep one track clear in front of parent */
+ if (offset == c1->offset)
+ offset = Next_Track_Aligned(d,offset+1);
+
+ /* Work on the (end+1) */
+ size += offset;
+ /* Round up to cylinder */
+ size = Next_Cyl_Aligned(d,size);
+ /* Stay inside parent */
+ if ((size-1) > c2->end)
+ size = c2->end+1;
+ /* Round down to cylinder */
+ size = Prev_Cyl_Aligned(d,size);
+
+ /* Convert back to size */
+ size -= offset;
+
+ doit:
+ return Insert_Chunk(c2,offset,size,name,
+ type,subtype,flags);
+ }
}
return __LINE__;
}
diff --git a/lib/libdisk/rules.c b/lib/libdisk/rules.c
index de86a03..39d54ff 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.5 1995/05/03 06:30:59 phk Exp $
+ * $Id: rules.c,v 1.6 1995/05/04 07:00:56 phk Exp $
*
*/
@@ -43,7 +43,7 @@ Next_Track_Aligned(struct disk *d, u_long offset)
{
if (!d->bios_sect)
return offset;
- return Prev_Track_Aligned(d,offset + d->bios_sect);
+ return Prev_Track_Aligned(d,offset + d->bios_sect-1);
}
int
@@ -69,7 +69,7 @@ Next_Cyl_Aligned(struct disk *d, u_long offset)
{
if (!d->bios_sect || !d->bios_hd)
return offset;
- return Prev_Cyl_Aligned(d,offset + (d->bios_sect * d->bios_hd));
+ return Prev_Cyl_Aligned(d,offset + (d->bios_sect * d->bios_hd)-1);
}
/*
diff --git a/release/libdisk/chunk.c b/release/libdisk/chunk.c
index d49a94e..0a07a5c 100644
--- a/release/libdisk/chunk.c
+++ b/release/libdisk/chunk.c
@@ -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.5 1995/05/01 21:30:22 jkh Exp $
+ * $Id: chunk.c,v 1.6 1995/05/03 22:36:49 phk Exp $
*
*/
@@ -18,8 +18,6 @@
#include <err.h>
#include "libdisk.h"
-CHAR_N;
-
#define new_chunk() malloc(sizeof(struct chunk))
/* Is c2 completely inside c1 ? */
@@ -218,8 +216,43 @@ Add_Chunk(struct disk *d, u_long offset, u_long size, char *name, chunk_e type,
for(c2=c1->part;c2;c2=c2->next) {
if (c2->type != unused)
continue;
- if(Chunk_Inside(c2,&ct))
- return Insert_Chunk(c2,offset,size,name,type,subtype,flags);
+ if(Chunk_Inside(c2,&ct)) {
+ if (type != freebsd)
+ goto doit;
+ if (!(flags & CHUNK_ALIGN))
+ goto doit;
+ if (offset == d->chunks->offset
+ && end == d->chunks->end)
+ goto doit;
+
+ /* Round down to prev cylinder */
+ offset = Prev_Cyl_Aligned(d,offset);
+ /* Stay inside the parent */
+ if (offset < c2->offset)
+ offset = c2->offset;
+ /* Round up to next cylinder */
+ offset = Next_Cyl_Aligned(d,offset);
+ /* Keep one track clear in front of parent */
+ if (offset == c1->offset)
+ offset = Next_Track_Aligned(d,offset+1);
+
+ /* Work on the (end+1) */
+ size += offset;
+ /* Round up to cylinder */
+ size = Next_Cyl_Aligned(d,size);
+ /* Stay inside parent */
+ if ((size-1) > c2->end)
+ size = c2->end+1;
+ /* Round down to cylinder */
+ size = Prev_Cyl_Aligned(d,size);
+
+ /* Convert back to size */
+ size -= offset;
+
+ doit:
+ return Insert_Chunk(c2,offset,size,name,
+ type,subtype,flags);
+ }
}
return __LINE__;
}
diff --git a/release/libdisk/rules.c b/release/libdisk/rules.c
index de86a03..39d54ff 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.5 1995/05/03 06:30:59 phk Exp $
+ * $Id: rules.c,v 1.6 1995/05/04 07:00:56 phk Exp $
*
*/
@@ -43,7 +43,7 @@ Next_Track_Aligned(struct disk *d, u_long offset)
{
if (!d->bios_sect)
return offset;
- return Prev_Track_Aligned(d,offset + d->bios_sect);
+ return Prev_Track_Aligned(d,offset + d->bios_sect-1);
}
int
@@ -69,7 +69,7 @@ Next_Cyl_Aligned(struct disk *d, u_long offset)
{
if (!d->bios_sect || !d->bios_hd)
return offset;
- return Prev_Cyl_Aligned(d,offset + (d->bios_sect * d->bios_hd));
+ return Prev_Cyl_Aligned(d,offset + (d->bios_sect * d->bios_hd)-1);
}
/*
OpenPOWER on IntegriCloud