diff options
| author | Poul-Henning Kamp <phk@FreeBSD.org> | 1995-05-05 07:07:45 +0000 |
|---|---|---|
| committer | Poul-Henning Kamp <phk@FreeBSD.org> | 1995-05-05 07:07:45 +0000 |
| commit | 0be90238f6447d39886428179fa41abb74723386 (patch) | |
| tree | 7d657d7e1371248f8c92d9d0c4e549f66a6277e7 /lib/libdisk | |
| parent | 3fb099396942922bae91671fe9e63b21a7ca9cd0 (diff) | |
Notes
Diffstat (limited to 'lib/libdisk')
| -rw-r--r-- | lib/libdisk/chunk.c | 43 | ||||
| -rw-r--r-- | lib/libdisk/rules.c | 6 |
2 files changed, 41 insertions, 8 deletions
diff --git a/lib/libdisk/chunk.c b/lib/libdisk/chunk.c index d49a94efe2fe..0a07a5c62fe9 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 de86a037cb0e..39d54ff324c1 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); } /* |
