diff options
author | phk <phk@FreeBSD.org> | 1995-04-29 04:00:57 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1995-04-29 04:00:57 +0000 |
commit | 093fd20263c83b8fbfb88a7cdb49236a80c9448a (patch) | |
tree | 11c2e7145c25cef4f5bba439fe31fdbe93c53551 /lib/libdisk/rules.c | |
parent | f7bf327ed4f468193062d32f7b6bb2cc4b521e9b (diff) | |
download | FreeBSD-src-093fd20263c83b8fbfb88a7cdb49236a80c9448a.zip FreeBSD-src-093fd20263c83b8fbfb88a7cdb49236a80c9448a.tar.gz |
Next Iteration, getting better.
Made an All_FreeBSD() function.
Added a cmd-line interface (lowest rank) to the tst01 program.
The tst01 program is harmless (worst it can do is coredump), but it
is instructive to run, you can see what the slice-code things of your
disk...
Diffstat (limited to 'lib/libdisk/rules.c')
-rw-r--r-- | lib/libdisk/rules.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/lib/libdisk/rules.c b/lib/libdisk/rules.c index 7db89ea..447c6de 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); |