summaryrefslogtreecommitdiff
path: root/lib/libdisk/rules.c
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>1995-04-29 04:00:57 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>1995-04-29 04:00:57 +0000
commitf9c10dfd1a49c87ca42b7ad41173c959bfd5aa64 (patch)
tree11c2e7145c25cef4f5bba439fe31fdbe93c53551 /lib/libdisk/rules.c
parent27bff5727d34ad78ead9babe511735cf46d7b93d (diff)
Notes
Diffstat (limited to 'lib/libdisk/rules.c')
-rw-r--r--lib/libdisk/rules.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/lib/libdisk/rules.c b/lib/libdisk/rules.c
index 7db89ea9e52b..447c6de4f58e 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$
+ * $Id: rules.c,v 1.1 1995/04/29 01:55:24 phk Exp $
*
*/
@@ -20,6 +20,32 @@
#include <err.h>
#include "libdisk.h"
+int
+Aligned(struct disk *d, u_long offset)
+{
+ if (!d->bios_sect)
+ return 1;
+ if (offset % d->bios_sect)
+ return 0;
+ return 1;
+}
+
+u_long
+Prev_Aligned(struct disk *d, u_long offset)
+{
+ if (!d->bios_sect)
+ return offset;
+ return (offset / d->bios_sect) * d->bios_sect;
+}
+
+u_long
+Next_Aligned(struct disk *d, u_long offset)
+{
+ if (!d->bios_sect)
+ return offset;
+ return Prev_Aligned(d,offset + d->bios_sect);
+}
+
/*
* Rule#0:
* Chunks of type 'whole' can have max NDOSPART children.
@@ -44,7 +70,8 @@ Rule_000(struct disk *d, struct chunk *c, char *msg)
/*
* Rule#1:
- * All children of 'whole' must be track-aligned
+ * All children of 'whole' must be track-aligned.
+ * Exception: the end can be unaligned if it matches the end of 'whole'
*/
void
Rule_001(struct disk *d, struct chunk *c, char *msg)
@@ -63,7 +90,7 @@ Rule_001(struct disk *d, struct chunk *c, char *msg)
sprintf(msg+strlen(msg),
"chunk '%s' [%ld..%ld] does not start on a track boundary\n",
c1->name,c1->offset,c1->end);
- if (!Aligned(d,c1->end+1))
+ if (c->end != c1->end && !Aligned(d,c1->end+1))
sprintf(msg+strlen(msg),
"chunk '%s' [%ld..%ld] does not end on a track boundary\n",
c1->name,c1->offset,c1->end);