diff --git a/lib/libdisk/Makefile b/lib/libdisk/Makefile index e4396f542af9..6a5fcdbd7f4c 100644 --- a/lib/libdisk/Makefile +++ b/lib/libdisk/Makefile @@ -1,6 +1,6 @@ .PATH: /usr/src/sbin/disklabel OBJS= tst01.o blocks.o disklabel.o dkcksum.o chunk.o disk.o change.o \ - create_chunk.o + create_chunk.o rules.o CFLAGS+= -Wall test: tst01 diff --git a/lib/libdisk/change.c b/lib/libdisk/change.c index 17dd7827984e..b1db61c34a21 100644 --- a/lib/libdisk/change.c +++ b/lib/libdisk/change.c @@ -17,7 +17,6 @@ #include #include #include -#include #include "libdisk.h" struct disk * diff --git a/lib/libdisk/chunk.c b/lib/libdisk/chunk.c index 088b5ab2b12a..a286cb11d7f6 100644 --- a/lib/libdisk/chunk.c +++ b/lib/libdisk/chunk.c @@ -15,11 +15,11 @@ #include #include #include -#include #include #include "libdisk.h" CHAR_N; + #define new_chunk() malloc(sizeof(struct chunk)) /* Is c2 completely inside c1 ? */ @@ -206,6 +206,10 @@ Add_Chunk(struct disk *d, u_long offset, u_long size, char *name, chunk_e type, c1 = Find_Mother_Chunk(d->chunks,offset,end,whole); if(!c1 && type == part) c1 = Find_Mother_Chunk(d->chunks,offset,end,freebsd); + if(!c1 && type == reserved) + c1 = Find_Mother_Chunk(d->chunks,offset,end,extended); + if(!c1 && type == reserved) + c1 = Find_Mother_Chunk(d->chunks,offset,end,whole); if(!c1) return __LINE__; for(c2=c1->part;c2;c2=c2->next) { @@ -252,26 +256,25 @@ Bios_Limit_Chunk(struct chunk *c1, u_long limit) } int -Delete_Chunk(struct disk *d, u_long offset, u_long end, chunk_e type) +Delete_Chunk(struct disk *d, struct chunk *c) { struct chunk *c1=0,*c2,*c3; + chunk_e type = c->type; if(type == whole) return 1; if(!c1 && (type == freebsd || type == fat || type == foo)) - c1 = Find_Mother_Chunk(d->chunks,offset,end,extended); + c1 = Find_Mother_Chunk(d->chunks,c->offset,c->end,extended); if(!c1 && (type == freebsd || type == fat || type == foo)) - c1 = Find_Mother_Chunk(d->chunks,offset,end,whole); + c1 = Find_Mother_Chunk(d->chunks,c->offset,c->end,whole); if(!c1 && type == extended) - c1 = Find_Mother_Chunk(d->chunks,offset,end,whole); + c1 = Find_Mother_Chunk(d->chunks,c->offset,c->end,whole); if(!c1 && type == part) - c1 = Find_Mother_Chunk(d->chunks,offset,end,freebsd); + c1 = Find_Mother_Chunk(d->chunks,c->offset,c->end,freebsd); if(!c1) return 1; for(c2=c1->part;c2;c2=c2->next) { - if (c2->offset == offset && - c2->end == end && - c2->type == type) { + if (c2 == c) { c2->type = unused; c2->subtype = 0; c2->flags = 0; @@ -329,7 +332,7 @@ Collapse_Chunk(struct disk *d, struct chunk *c1) return 0; if(c3->type == unused && c3->size == c1->size) { - Delete_Chunk(d,c1->offset, c1->end, c1->type); + Delete_Chunk(d,c1); return 1; } if(c3->type == unused) { diff --git a/lib/libdisk/create_chunk.c b/lib/libdisk/create_chunk.c index 6664820b80b4..7abcac9a0e2d 100644 --- a/lib/libdisk/create_chunk.c +++ b/lib/libdisk/create_chunk.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include "libdisk.h" diff --git a/lib/libdisk/disk.c b/lib/libdisk/disk.c index 5ff2a217a25d..4f78c5ae46e2 100644 --- a/lib/libdisk/disk.c +++ b/lib/libdisk/disk.c @@ -20,7 +20,6 @@ #include #include #include -#include #include "libdisk.h" #define DOSPTYP_EXTENDED 5 @@ -66,6 +65,7 @@ Int_Open_Disk(char *name, u_long size) size = ds.dss_slices[WHOLE_DISK_SLICE].ds_size; Add_Chunk(d, 0, size, name,whole,0,0); + Add_Chunk(d, 0, 1, "-",reserved,0,0); for(i=2;i wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp + * ---------------------------------------------------------------------------- + * + * $Id$ + * + */ typedef enum {whole, foo, fat, freebsd, extended, part, unused, reserved} chunk_e; + #define CHAR_N static char *chunk_n[] = { \ "whole","foo","fat","freebsd","extended","part","unused","reserved"}; struct disk { char *name; u_long flags; -#define DISK_ON_TRACK 1 -#define DISK_REAL_GEOM 2 +# define DISK_ON_TRACK 1 +# define DISK_REAL_GEOM 2 u_long real_cyl; u_long real_hd; u_long real_sect; @@ -26,36 +38,79 @@ struct chunk { char *name; chunk_e type; int subtype; -#define SUBTYPE_BSD_FS 1 -#define SUBTYPE_BSD_SWAP 2 -#define SUBTYPE_BSD_UNUSED 3 +# define SUBTYPE_BSD_FS 1 +# define SUBTYPE_BSD_SWAP 2 +# define SUBTYPE_BSD_UNUSED 3 u_long flags; -#define CHUNK_PAST_1024 1 - /* this chunk cannot be booted from */ -#define CHUNK_BSD_COMPAT 2 - /* this chunk is in the BSD-compatibility, and has a short name - * too, ie wd0s4f -> wd0f - */ -#define CHUNK_BAD144 4 - /* this chunk has bad144 mapping */ -#define CHUNK_ALIGN 8 +# define CHUNK_PAST_1024 1 + /* this chunk cannot be booted from */ +# define CHUNK_BSD_COMPAT 2 + /* this chunk is in the BSD-compatibility, and has a + * short name too, ie wd0s4f -> wd0f + */ +# define CHUNK_BAD144 4 + /* this chunk has bad144 mapping */ +# define CHUNK_ALIGN 8 }; -struct disk *Open_Disk(char *devname); -void Free_Disk(struct disk *disk); -void Debug_Disk(struct disk *disk); -struct disk *Clone_Disk(struct disk *disk); +struct disk * +Open_Disk(char *devname); + /* Will open the named disk, and return populated tree. + */ -struct disk *Set_Phys_Geom(struct disk *disk, u_long cyl, u_long heads, u_long sects); -void Set_Bios_Geom(struct disk *disk, u_long cyl, u_long heads, u_long sects); +struct disk * +Clone_Disk(struct disk *disk); + /* Clone a copy of a tree. Useful for "Undo" functionality + */ -int Delete_Chunk(struct disk *disk, u_long offset, u_long end, chunk_e type); -void Collapse_Disk(struct disk *disk); -int Collapse_Chunk(struct disk *disk, struct chunk *chunk); +void +Free_Disk(struct disk *disk); + /* Free a tree made with Open_Disk() or Clone_Disk() + */ -int Create_Chunk(struct disk *disk, u_long offset, u_long size, chunk_e type, int subtype, u_long flags); +void +Debug_Disk(struct disk *disk); + /* Print the content of the tree to stdout + */ -/* Implementation details */ +struct disk * +Set_Phys_Geom(struct disk *disk, u_long cyl, u_long heads, u_long sects); + /* Use a different physical geometry. Makes sense for ST506 disks only. + * The tree returned is read from the disk, using this geometry. + */ + +void +Set_Bios_Geom(struct disk *disk, u_long cyl, u_long heads, u_long sects); + /* Set the geometry the bios uses. + */ + +int +Delete_Chunk(struct disk *disk, struct chunk *); + /* Free a chunk of disk_space + */ + +void +Collapse_Disk(struct disk *disk); + /* Experimental, do not use. + */ +int +Collapse_Chunk(struct disk *disk, struct chunk *chunk); + /* Experimental, do not use. + */ + +int +Create_Chunk(struct disk *disk, u_long offset, u_long size, chunk_e type, int subtype, u_long flags); + /* Create a chunk with the specified paramters + */ + +char * +CheckRules(struct disk *); + /* Return char* to warnings about broken design rules in this disklayout + */ + +/* + * Implementation details >>> DO NOT USE <<< + */ struct disk *Int_Open_Disk(char *devname, u_long maxsize); diff --git a/lib/libdisk/rules.c b/lib/libdisk/rules.c new file mode 100644 index 000000000000..7db89ea9e52b --- /dev/null +++ b/lib/libdisk/rules.c @@ -0,0 +1,95 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp + * ---------------------------------------------------------------------------- + * + * $Id$ + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "libdisk.h" + +/* + * Rule#0: + * Chunks of type 'whole' can have max NDOSPART children. + */ +void +Rule_000(struct disk *d, struct chunk *c, char *msg) +{ + int i; + struct chunk *c1; + + if (c->type != whole) + return; + for (i=0, c1=c->part; c1; c1=c1->next) + if (c1->type != unused) + i++; + if (i <= NDOSPART) + return; + sprintf(msg+strlen(msg), + "%d is too many children of the 'whole' chunk. Max is %d\n", + i, NDOSPART); +} + +/* + * Rule#1: + * All children of 'whole' must be track-aligned + */ +void +Rule_001(struct disk *d, struct chunk *c, char *msg) +{ + int i; + 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 == unused) + continue; + if (!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 (!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); + } +} + +void +Check_Chunk(struct disk *d, struct chunk *c, char *msg) +{ + Rule_000(d,c,msg); + Rule_001(d,c,msg); + if (c->part) + Check_Chunk(d,c->part,msg); + if (c->next) + Check_Chunk(d,c->next,msg); + return; +} + +char * +CheckRules(struct disk *d) +{ + char msg[BUFSIZ]; + + *msg = '\0'; + Check_Chunk(d,d->chunks,msg); + if (*msg) + return strdup(msg); + return 0; +} diff --git a/lib/libdisk/tst01.c b/lib/libdisk/tst01.c index bcc13448cf66..9320356584c0 100644 --- a/lib/libdisk/tst01.c +++ b/lib/libdisk/tst01.c @@ -14,37 +14,8 @@ #include #include #include -#include -#include -#include -#include #include "libdisk.h" -void -fprint_diskslices(FILE *fi, struct diskslices *ds) -{ - int i; - - printf("@%p: struct diskslices\n",ds); - printf("\tdss_first_bsd_slice = %d\n",ds->dss_first_bsd_slice); - printf("\tdss_nslices = %d\n",ds->dss_nslices); - for(i=0;idss_nslices;i++) { - printf("\tdss_slices[%d] = struct diskslice",i); - if (i == 0) - printf(" /* FreeBSD compatibility slice */\n"); - else if (i == 1) - printf(" /* Whole disk slice */\n"); - else if (i < 6) - printf(" /* Primary MBR slice %d */\n",i-1); - else - printf("\n"); - printf("\t\tds_offset = %lu\n",ds->dss_slices[i].ds_offset); - printf("\t\tds_size = %lu\n",ds->dss_slices[i].ds_size); - printf("\t\tds_type = %u\n",ds->dss_slices[i].ds_type); - printf("\t\tds_openmask = %u\n",ds->dss_slices[i].ds_openmask); - } -} - int main(int argc, char **argv) { @@ -55,12 +26,12 @@ main(int argc, char **argv) d = Open_Disk(argv[i]); if (!d) continue; Debug_Disk(d); - Delete_Chunk(d,0,4108599,freebsd); - Debug_Disk(d); - printf("Create=%d\n",Create_Chunk(d,0,32768,fat,0,0)); - printf("Create=%d\n",Create_Chunk(d,192512,409600,freebsd,0,0)); - printf("Create=%d\n",Create_Chunk(d,192512,409600,part,0,0)); + if (d->chunks->size == 1411200) + Set_Bios_Geom(d,1024,15,63); + else + Set_Bios_Geom(d,2003,64,32); Debug_Disk(d); + printf("<%s>\n",CheckRules(d)); } exit (0); } diff --git a/release/libdisk/Makefile b/release/libdisk/Makefile index e4396f542af9..6a5fcdbd7f4c 100644 --- a/release/libdisk/Makefile +++ b/release/libdisk/Makefile @@ -1,6 +1,6 @@ .PATH: /usr/src/sbin/disklabel OBJS= tst01.o blocks.o disklabel.o dkcksum.o chunk.o disk.o change.o \ - create_chunk.o + create_chunk.o rules.o CFLAGS+= -Wall test: tst01 diff --git a/release/libdisk/change.c b/release/libdisk/change.c index 17dd7827984e..b1db61c34a21 100644 --- a/release/libdisk/change.c +++ b/release/libdisk/change.c @@ -17,7 +17,6 @@ #include #include #include -#include #include "libdisk.h" struct disk * diff --git a/release/libdisk/chunk.c b/release/libdisk/chunk.c index 088b5ab2b12a..a286cb11d7f6 100644 --- a/release/libdisk/chunk.c +++ b/release/libdisk/chunk.c @@ -15,11 +15,11 @@ #include #include #include -#include #include #include "libdisk.h" CHAR_N; + #define new_chunk() malloc(sizeof(struct chunk)) /* Is c2 completely inside c1 ? */ @@ -206,6 +206,10 @@ Add_Chunk(struct disk *d, u_long offset, u_long size, char *name, chunk_e type, c1 = Find_Mother_Chunk(d->chunks,offset,end,whole); if(!c1 && type == part) c1 = Find_Mother_Chunk(d->chunks,offset,end,freebsd); + if(!c1 && type == reserved) + c1 = Find_Mother_Chunk(d->chunks,offset,end,extended); + if(!c1 && type == reserved) + c1 = Find_Mother_Chunk(d->chunks,offset,end,whole); if(!c1) return __LINE__; for(c2=c1->part;c2;c2=c2->next) { @@ -252,26 +256,25 @@ Bios_Limit_Chunk(struct chunk *c1, u_long limit) } int -Delete_Chunk(struct disk *d, u_long offset, u_long end, chunk_e type) +Delete_Chunk(struct disk *d, struct chunk *c) { struct chunk *c1=0,*c2,*c3; + chunk_e type = c->type; if(type == whole) return 1; if(!c1 && (type == freebsd || type == fat || type == foo)) - c1 = Find_Mother_Chunk(d->chunks,offset,end,extended); + c1 = Find_Mother_Chunk(d->chunks,c->offset,c->end,extended); if(!c1 && (type == freebsd || type == fat || type == foo)) - c1 = Find_Mother_Chunk(d->chunks,offset,end,whole); + c1 = Find_Mother_Chunk(d->chunks,c->offset,c->end,whole); if(!c1 && type == extended) - c1 = Find_Mother_Chunk(d->chunks,offset,end,whole); + c1 = Find_Mother_Chunk(d->chunks,c->offset,c->end,whole); if(!c1 && type == part) - c1 = Find_Mother_Chunk(d->chunks,offset,end,freebsd); + c1 = Find_Mother_Chunk(d->chunks,c->offset,c->end,freebsd); if(!c1) return 1; for(c2=c1->part;c2;c2=c2->next) { - if (c2->offset == offset && - c2->end == end && - c2->type == type) { + if (c2 == c) { c2->type = unused; c2->subtype = 0; c2->flags = 0; @@ -329,7 +332,7 @@ Collapse_Chunk(struct disk *d, struct chunk *c1) return 0; if(c3->type == unused && c3->size == c1->size) { - Delete_Chunk(d,c1->offset, c1->end, c1->type); + Delete_Chunk(d,c1); return 1; } if(c3->type == unused) { diff --git a/release/libdisk/create_chunk.c b/release/libdisk/create_chunk.c index 6664820b80b4..7abcac9a0e2d 100644 --- a/release/libdisk/create_chunk.c +++ b/release/libdisk/create_chunk.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include "libdisk.h" diff --git a/release/libdisk/disk.c b/release/libdisk/disk.c index 5ff2a217a25d..4f78c5ae46e2 100644 --- a/release/libdisk/disk.c +++ b/release/libdisk/disk.c @@ -20,7 +20,6 @@ #include #include #include -#include #include "libdisk.h" #define DOSPTYP_EXTENDED 5 @@ -66,6 +65,7 @@ Int_Open_Disk(char *name, u_long size) size = ds.dss_slices[WHOLE_DISK_SLICE].ds_size; Add_Chunk(d, 0, size, name,whole,0,0); + Add_Chunk(d, 0, 1, "-",reserved,0,0); for(i=2;i wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp + * ---------------------------------------------------------------------------- + * + * $Id$ + * + */ typedef enum {whole, foo, fat, freebsd, extended, part, unused, reserved} chunk_e; + #define CHAR_N static char *chunk_n[] = { \ "whole","foo","fat","freebsd","extended","part","unused","reserved"}; struct disk { char *name; u_long flags; -#define DISK_ON_TRACK 1 -#define DISK_REAL_GEOM 2 +# define DISK_ON_TRACK 1 +# define DISK_REAL_GEOM 2 u_long real_cyl; u_long real_hd; u_long real_sect; @@ -26,36 +38,79 @@ struct chunk { char *name; chunk_e type; int subtype; -#define SUBTYPE_BSD_FS 1 -#define SUBTYPE_BSD_SWAP 2 -#define SUBTYPE_BSD_UNUSED 3 +# define SUBTYPE_BSD_FS 1 +# define SUBTYPE_BSD_SWAP 2 +# define SUBTYPE_BSD_UNUSED 3 u_long flags; -#define CHUNK_PAST_1024 1 - /* this chunk cannot be booted from */ -#define CHUNK_BSD_COMPAT 2 - /* this chunk is in the BSD-compatibility, and has a short name - * too, ie wd0s4f -> wd0f - */ -#define CHUNK_BAD144 4 - /* this chunk has bad144 mapping */ -#define CHUNK_ALIGN 8 +# define CHUNK_PAST_1024 1 + /* this chunk cannot be booted from */ +# define CHUNK_BSD_COMPAT 2 + /* this chunk is in the BSD-compatibility, and has a + * short name too, ie wd0s4f -> wd0f + */ +# define CHUNK_BAD144 4 + /* this chunk has bad144 mapping */ +# define CHUNK_ALIGN 8 }; -struct disk *Open_Disk(char *devname); -void Free_Disk(struct disk *disk); -void Debug_Disk(struct disk *disk); -struct disk *Clone_Disk(struct disk *disk); +struct disk * +Open_Disk(char *devname); + /* Will open the named disk, and return populated tree. + */ -struct disk *Set_Phys_Geom(struct disk *disk, u_long cyl, u_long heads, u_long sects); -void Set_Bios_Geom(struct disk *disk, u_long cyl, u_long heads, u_long sects); +struct disk * +Clone_Disk(struct disk *disk); + /* Clone a copy of a tree. Useful for "Undo" functionality + */ -int Delete_Chunk(struct disk *disk, u_long offset, u_long end, chunk_e type); -void Collapse_Disk(struct disk *disk); -int Collapse_Chunk(struct disk *disk, struct chunk *chunk); +void +Free_Disk(struct disk *disk); + /* Free a tree made with Open_Disk() or Clone_Disk() + */ -int Create_Chunk(struct disk *disk, u_long offset, u_long size, chunk_e type, int subtype, u_long flags); +void +Debug_Disk(struct disk *disk); + /* Print the content of the tree to stdout + */ -/* Implementation details */ +struct disk * +Set_Phys_Geom(struct disk *disk, u_long cyl, u_long heads, u_long sects); + /* Use a different physical geometry. Makes sense for ST506 disks only. + * The tree returned is read from the disk, using this geometry. + */ + +void +Set_Bios_Geom(struct disk *disk, u_long cyl, u_long heads, u_long sects); + /* Set the geometry the bios uses. + */ + +int +Delete_Chunk(struct disk *disk, struct chunk *); + /* Free a chunk of disk_space + */ + +void +Collapse_Disk(struct disk *disk); + /* Experimental, do not use. + */ +int +Collapse_Chunk(struct disk *disk, struct chunk *chunk); + /* Experimental, do not use. + */ + +int +Create_Chunk(struct disk *disk, u_long offset, u_long size, chunk_e type, int subtype, u_long flags); + /* Create a chunk with the specified paramters + */ + +char * +CheckRules(struct disk *); + /* Return char* to warnings about broken design rules in this disklayout + */ + +/* + * Implementation details >>> DO NOT USE <<< + */ struct disk *Int_Open_Disk(char *devname, u_long maxsize); diff --git a/release/libdisk/rules.c b/release/libdisk/rules.c new file mode 100644 index 000000000000..7db89ea9e52b --- /dev/null +++ b/release/libdisk/rules.c @@ -0,0 +1,95 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp + * ---------------------------------------------------------------------------- + * + * $Id$ + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "libdisk.h" + +/* + * Rule#0: + * Chunks of type 'whole' can have max NDOSPART children. + */ +void +Rule_000(struct disk *d, struct chunk *c, char *msg) +{ + int i; + struct chunk *c1; + + if (c->type != whole) + return; + for (i=0, c1=c->part; c1; c1=c1->next) + if (c1->type != unused) + i++; + if (i <= NDOSPART) + return; + sprintf(msg+strlen(msg), + "%d is too many children of the 'whole' chunk. Max is %d\n", + i, NDOSPART); +} + +/* + * Rule#1: + * All children of 'whole' must be track-aligned + */ +void +Rule_001(struct disk *d, struct chunk *c, char *msg) +{ + int i; + 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 == unused) + continue; + if (!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 (!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); + } +} + +void +Check_Chunk(struct disk *d, struct chunk *c, char *msg) +{ + Rule_000(d,c,msg); + Rule_001(d,c,msg); + if (c->part) + Check_Chunk(d,c->part,msg); + if (c->next) + Check_Chunk(d,c->next,msg); + return; +} + +char * +CheckRules(struct disk *d) +{ + char msg[BUFSIZ]; + + *msg = '\0'; + Check_Chunk(d,d->chunks,msg); + if (*msg) + return strdup(msg); + return 0; +} diff --git a/release/libdisk/tst01.c b/release/libdisk/tst01.c index bcc13448cf66..9320356584c0 100644 --- a/release/libdisk/tst01.c +++ b/release/libdisk/tst01.c @@ -14,37 +14,8 @@ #include #include #include -#include -#include -#include -#include #include "libdisk.h" -void -fprint_diskslices(FILE *fi, struct diskslices *ds) -{ - int i; - - printf("@%p: struct diskslices\n",ds); - printf("\tdss_first_bsd_slice = %d\n",ds->dss_first_bsd_slice); - printf("\tdss_nslices = %d\n",ds->dss_nslices); - for(i=0;idss_nslices;i++) { - printf("\tdss_slices[%d] = struct diskslice",i); - if (i == 0) - printf(" /* FreeBSD compatibility slice */\n"); - else if (i == 1) - printf(" /* Whole disk slice */\n"); - else if (i < 6) - printf(" /* Primary MBR slice %d */\n",i-1); - else - printf("\n"); - printf("\t\tds_offset = %lu\n",ds->dss_slices[i].ds_offset); - printf("\t\tds_size = %lu\n",ds->dss_slices[i].ds_size); - printf("\t\tds_type = %u\n",ds->dss_slices[i].ds_type); - printf("\t\tds_openmask = %u\n",ds->dss_slices[i].ds_openmask); - } -} - int main(int argc, char **argv) { @@ -55,12 +26,12 @@ main(int argc, char **argv) d = Open_Disk(argv[i]); if (!d) continue; Debug_Disk(d); - Delete_Chunk(d,0,4108599,freebsd); - Debug_Disk(d); - printf("Create=%d\n",Create_Chunk(d,0,32768,fat,0,0)); - printf("Create=%d\n",Create_Chunk(d,192512,409600,freebsd,0,0)); - printf("Create=%d\n",Create_Chunk(d,192512,409600,part,0,0)); + if (d->chunks->size == 1411200) + Set_Bios_Geom(d,1024,15,63); + else + Set_Bios_Geom(d,2003,64,32); Debug_Disk(d); + printf("<%s>\n",CheckRules(d)); } exit (0); }