diff options
author | phk <phk@FreeBSD.org> | 1995-04-30 11:04:16 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1995-04-30 11:04:16 +0000 |
commit | 207cc9aa1b7958de0f80495004bef9a3d7cd67bd (patch) | |
tree | e2d59f880d13ec0362f8f6337a1f6cb182b43c1a | |
parent | 5eb0a0c02bef0c30ced9bca8f78a0f78c3febe1b (diff) | |
download | FreeBSD-src-207cc9aa1b7958de0f80495004bef9a3d7cd67bd.zip FreeBSD-src-207cc9aa1b7958de0f80495004bef9a3d7cd67bd.tar.gz |
get bootblocks right.
Add mbr and bteasy17 to tst01
read partitions from kernel instead of disk.
Still problems with writing labels, discussing with Bruce.
Extended slices doesn't get written yet.
-rw-r--r-- | lib/libdisk/create_chunk.c | 3 | ||||
-rw-r--r-- | lib/libdisk/disk.c | 107 | ||||
-rw-r--r-- | lib/libdisk/libdisk.h | 3 | ||||
-rw-r--r-- | lib/libdisk/tst01.c | 64 | ||||
-rw-r--r-- | lib/libdisk/write_disk.c | 8 | ||||
-rw-r--r-- | release/libdisk/create_chunk.c | 3 | ||||
-rw-r--r-- | release/libdisk/disk.c | 107 | ||||
-rw-r--r-- | release/libdisk/libdisk.h | 3 | ||||
-rw-r--r-- | release/libdisk/tst01.c | 64 | ||||
-rw-r--r-- | release/libdisk/write_disk.c | 8 |
10 files changed, 266 insertions, 104 deletions
diff --git a/lib/libdisk/create_chunk.c b/lib/libdisk/create_chunk.c index 27652e6..0bb6c08 100644 --- a/lib/libdisk/create_chunk.c +++ b/lib/libdisk/create_chunk.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: create_chunk.c,v 1.3 1995/04/29 07:21:10 phk Exp $ + * $Id: create_chunk.c,v 1.4 1995/04/30 06:09:25 phk Exp $ * */ @@ -128,7 +128,6 @@ int Create_Chunk(struct disk *d, u_long offset, u_long size, chunk_e type, int subtype, u_long flags) { int i; - u_long l1,l2,end = offset + size; i = Add_Chunk(d,offset,size,"X",type,subtype,flags); Fixup_Names(d); diff --git a/lib/libdisk/disk.c b/lib/libdisk/disk.c index c73d819..f421224 100644 --- a/lib/libdisk/disk.c +++ b/lib/libdisk/disk.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: disk.c,v 1.6 1995/04/30 06:09:26 phk Exp $ + * $Id: disk.c,v 1.7 1995/04/30 07:30:43 phk Exp $ * */ @@ -65,6 +65,12 @@ Int_Open_Disk(char *name, u_long size) return 0; } + for(i=0;i<ds.dss_nslices;i++) + if(ds.dss_slices[i].ds_openmask) + printf(" open(%d)=0x%2x", + i,ds.dss_slices[i].ds_openmask); + printf("\n"); + if (!size) size = ds.dss_slices[WHOLE_DISK_SLICE].ds_size; @@ -97,7 +103,7 @@ Int_Open_Disk(char *name, u_long size) if (Add_Chunk(d, 0, 1, "-",reserved,0,0)) warn("Failed to add MBR chunk"); - for(i=BASE_SLICE;i < 12 && i<ds.dss_nslices;i++) { + for(i=BASE_SLICE;i<ds.dss_nslices;i++) { char sname[20]; chunk_e ce; u_long flags=0; @@ -105,12 +111,13 @@ Int_Open_Disk(char *name, u_long size) if (! ds.dss_slices[i].ds_size) continue; sprintf(sname,"%ss%d",name,i-1); + subtype = ds.dss_slices[i].ds_type; switch (ds.dss_slices[i].ds_type) { case 0xa5: ce = freebsd; break; case 0x1: - case 0x6: + case 0x4: ce = fat; break; case DOSPTYP_EXTENDED: @@ -118,7 +125,6 @@ Int_Open_Disk(char *name, u_long size) break; default: ce = foo; - subtype = -ds.dss_slices[i].ds_type; break; } flags |= CHUNK_ALIGN; @@ -129,45 +135,56 @@ Int_Open_Disk(char *name, u_long size) if (Add_Chunk(d,ds.dss_slices[i].ds_offset, 1, "-",reserved, subtype, flags)) warn("failed to add MBR chunk for slice %d",i - 1); - if (ds.dss_slices[i].ds_type == 0xa5) { - struct disklabel *dl; + if (ds.dss_slices[i].ds_type != 0xa5) + continue; + { + struct disklabel dl; + char pname[20]; + int j,k; - dl = read_disklabel(fd, - ds.dss_slices[i].ds_offset + LABELSECTOR); - if(dl) { - char pname[20]; - int j; - u_long l; - if (dl->d_partitions[RAW_PART].p_offset == 0 && - dl->d_partitions[RAW_PART].p_size == - ds.dss_slices[i].ds_size) - l = ds.dss_slices[i].ds_offset; - else - l = 0; - for(j=0; j < dl->d_npartitions; j++) { - sprintf(pname,"%s%c",sname,j+'a'); - if (j == RAW_PART || j == 3) - continue; - if (!dl->d_partitions[j].p_size) - continue; - if (Add_Chunk(d, - dl->d_partitions[j].p_offset + - l, - dl->d_partitions[j].p_size, - pname,part,0,0)) - warn( - "Failed to add chunk for partition %c [%lu,%lu]", - j + 'a',dl->d_partitions[j].p_offset,dl->d_partitions[j].p_size); - } - sprintf(pname,"%sd",sname); - if (dl->d_partitions[3].p_size) - Add_Chunk(d, - dl->d_partitions[3].p_offset + - l, - dl->d_partitions[3].p_size, - pname,part,0,0); - free(dl); + strcpy(pname,"/dev/r"); + strcat(pname,sname); + j = open(pname,O_RDONLY); + if (j < 0) { + warn("open(%s)",pname); + continue; + } + k = ioctl(j,DIOCGDINFO,&dl); + if (k < 0) { + warn("ioctl(%s,DIOCGDINFO)",pname); + close(j); + continue; + } + close(j); + + for(j=0; j <= dl.d_npartitions; j++) { + if (j == RAW_PART) + continue; + if (j == 3) + continue; + if (j == dl.d_npartitions) { + j = 3; + dl.d_npartitions=0; } + if (!dl.d_partitions[j].p_size) + continue; + if (dl.d_partitions[j].p_size + + dl.d_partitions[j].p_offset > + ds.dss_slices[i].ds_size) + continue; + sprintf(pname,"%s%c",sname,j+'a'); + if (Add_Chunk(d, + dl.d_partitions[j].p_offset + + ds.dss_slices[i].ds_offset, + dl.d_partitions[j].p_size, + pname,part, + dl.d_partitions[j].p_fstype, + 0) && j != 3) + warn( + "Failed to add chunk for partition %c [%lu,%lu]", + j + 'a',dl.d_partitions[j].p_offset, + dl.d_partitions[j].p_size); + } } } close(fd); @@ -216,8 +233,8 @@ Clone_Disk(struct disk *d) memcpy(d2->boot1,d->boot1,512); } if(d2->boot2) { - d2->boot2 = malloc(512*7); - memcpy(d2->boot2,d->boot2,512*7); + d2->boot2 = malloc(512*15); + memcpy(d2->boot2,d->boot2,512*15); } return d2; } @@ -284,7 +301,7 @@ Set_Boot_Blocks(struct disk *d, u_char *b1, u_char *b2) if(!d->boot1) err(1,"malloc failed"); memcpy(d->boot1,b1,512); if (d->boot2) free(d->boot2); - d->boot2 = malloc(7*512); + d->boot2 = malloc(15*512); if(!d->boot2) err(1,"malloc failed"); - memcpy(d->boot2,b2,7*512); + memcpy(d->boot2,b2,15*512); } diff --git a/lib/libdisk/libdisk.h b/lib/libdisk/libdisk.h index 827fd4b..dab99a4 100644 --- a/lib/libdisk/libdisk.h +++ b/lib/libdisk/libdisk.h @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: libdisk.h,v 1.5 1995/04/29 07:21:11 phk Exp $ + * $Id: libdisk.h,v 1.6 1995/04/30 06:09:27 phk Exp $ * */ @@ -187,6 +187,7 @@ struct disklabel * read_disklabel(int, daddr_t); u_short dkcksum(struct disklabel *); struct chunk * Find_Mother_Chunk(struct chunk *, u_long , u_long , chunk_e); struct disk * Int_Open_Disk(char *name, u_long size); +void Fixup_Names(struct disk *); #define dprintf printf diff --git a/lib/libdisk/tst01.c b/lib/libdisk/tst01.c index e175b5c..2e8fe53 100644 --- a/lib/libdisk/tst01.c +++ b/lib/libdisk/tst01.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: tst01.c,v 1.5 1995/04/29 07:21:13 phk Exp $ + * $Id: tst01.c,v 1.6 1995/04/30 06:09:28 phk Exp $ * */ @@ -24,6 +24,55 @@ CHAR_N; +u_char mbr[] = { +250,51,192,142,208,188,0,124,139,244,80,7,80,31,251,252,191,0,6,185,0,1, +242,165,234,29,6,0,0,190,190,7,179,4,128,60,128,116,14,128,60,0,117,28, +131,198,16,254,203,117,239,205,24,139,20,139,76,2,139,238,131,198,16,254, +203,116,26,128,60,0,116,244,190,139,6,172,60,0,116,11,86,187,7,0,180,14, +205,16,94,235,240,235,254,191,5,0,187,0,124,184,1,2,87,205,19,95,115,12, +51,192,205,19,79,117,237,190,163,6,235,211,190,194,6,191,254,125,129,61, +85,170,117,199,139,245,234,0,124,0,0,73,110,118,97,108,105,100,32,112,97, +114,116,105,116,105,111,110,32,116,97,98,108,101,0,69,114,114,111,114,32, +108,111,97,100,105,110,103,32,111,112,101,114,97,116,105,110,103,32,115, +121,115,116,101,109,0,77,105,115,115,105,110,103,32,111,112,101,114,97, +116,105,110,103,32,115,121,115,116,101,109,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128, +1,1,0,4,15,63,60,63,0,0,0,241,239,0,0,0,0,1,61,5,15,63,243,48,240,0,0,144, +208,2,0,0,0,1,244,165,15,63,170,192,192,3,0,144,208,2,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,85,170 +}; + +u_char bteasy17[] = { +51,192,142,192,142,216,142,208,188,0,124,252,139,244,191,0,6,185,0,1,242, +165,234,96,6,0,0,139,213,88,162,72,7,60,53,116,28,180,16,246,228,5,174, +4,150,246,68,4,255,116,62,198,4,128,232,218,0,138,116,1,139,76,2,235,8, +232,207,0,185,1,0,50,209,187,0,124,184,1,2,205,19,114,30,129,191,254,1, +85,170,117,22,234,0,124,0,0,128,250,129,116,2,178,128,139,234,66,128,242, +179,136,22,58,7,191,190,7,185,4,0,198,6,45,7,49,50,246,136,45,138,69,4, +60,0,116,35,60,5,116,31,254,198,190,42,7,232,113,0,190,72,7,70,70,139,28, +10,255,116,5,50,125,4,117,243,141,183,114,7,232,90,0,131,199,16,254,6,45, +7,226,203,128,62,117,4,2,116,11,190,59,7,10,246,117,10,205,24,235,172,190, +42,7,232,57,0,232,54,0,50,228,205,26,139,218,131,195,96,180,1,205,22,180, +0,117,11,205,26,59,211,114,242,160,72,7,235,10,205,22,138,196,60,28,116, +243,4,246,60,49,114,214,60,53,119,210,80,190,40,7,187,27,6,83,252,172,80, +36,127,180,14,205,16,88,168,128,116,242,195,86,184,1,3,187,0,6,185,1,0, +50,246,205,19,94,198,6,72,7,63,195,13,138,13,10,70,48,32,46,32,46,32,46, +160,100,105,115,107,32,49,13,10,10,68,101,102,97,117,108,116,58,32,70,63, +160,0,1,0,4,0,6,3,7,7,10,10,99,14,100,14,101,20,128,20,129,25,130,30,147, +36,165,39,159,43,117,47,82,47,219,50,64,55,242,61,0,100,111,243,72,80,70, +211,79,115,178,85,110,105,248,78,111,118,101,108,236,77,105,110,105,248, +76,105,110,117,248,65,109,111,101,98,225,66,83,196,66,83,68,233,80,67,73, +216,67,80,205,86,101,110,105,248,68,111,115,115,101,227,63,191,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,85,170 +}; + int main(int argc, char **argv) { @@ -46,7 +95,7 @@ main(int argc, char **argv) sprintf(myprompt,"%s %s> ",argv[0],argv[1]); while(1) { - printf("\n\n\n\n"); + printf("--==##==--\n"); Debug_Disk(d); p = CheckRules(d); if (p) { @@ -140,6 +189,14 @@ main(int argc, char **argv) d = db; continue; } + if (!strcasecmp(*cmds,"bteasy")) { + Set_Boot_Mgr(d,bteasy17); + continue; + } + if (!strcasecmp(*cmds,"mbr")) { + Set_Boot_Mgr(d,mbr); + continue; + } if (!strcasecmp(*cmds,"boot")) { extern u_char boot1[],boot2[]; Set_Boot_Blocks(d,boot1,boot2); @@ -158,10 +215,13 @@ main(int argc, char **argv) printf("\tallfreebsd\n"); printf("\tbios cyl hd sect\n"); printf("\tboot\n"); + printf("\tbteasy17\n"); printf("\tcollapse [pointer]\n"); printf("\tcreate offset size enum subtype flags\n"); + printf("\t\tsubtype(part): swap=1, ffs=7\n"); printf("\tdelete pointer\n"); printf("\tlist\n"); + printf("\tmbr\n"); printf("\tphys cyl hd sect\n"); printf("\tquit\n"); printf("\tread [disk]\n"); diff --git a/lib/libdisk/write_disk.c b/lib/libdisk/write_disk.c index 51e4e4a..d4d1c8a 100644 --- a/lib/libdisk/write_disk.c +++ b/lib/libdisk/write_disk.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: write_disk.c,v 1.2 1995/04/30 06:09:29 phk Exp $ + * $Id: write_disk.c,v 1.3 1995/04/30 07:30:45 phk Exp $ * */ @@ -64,6 +64,7 @@ Write_FreeBSD(int fd, struct disk *new, struct disk *old, struct chunk *c1) } dl->d_partitions[j].p_size = c2->size; dl->d_partitions[j].p_offset = c2->offset - c1->offset; + dl->d_partitions[j].p_fstype = c2->subtype; } @@ -71,10 +72,12 @@ Write_FreeBSD(int fd, struct disk *new, struct disk *old, struct chunk *c1) strcpy(dl->d_typename,c1->name); + dl->d_secsize = 512; dl->d_secperunit = new->chunks->size; dl->d_secpercyl = new->real_cyl ? new->real_cyl : new->bios_cyl; dl->d_ntracks = new->real_hd ? new->real_hd : new->bios_hd; dl->d_nsectors = new->real_sect ? new->real_sect : new->bios_sect; + dl->d_secpercyl = dl->d_ntracks * dl->d_nsectors; dl->d_npartitions = MAXPARTITIONS; @@ -97,7 +100,6 @@ int Write_Extended(int fd, struct disk *new, struct disk *old, struct chunk *c1) { printf("--> Write_Extended()\n"); - Print_Chunk(c1); return 0; } @@ -186,6 +188,8 @@ Write_Disk(struct disk *d1) case foo: dp[j].dp_typ = - c1->subtype; break; + default: + break; } } for(i=0;i<NDOSPART;i++) diff --git a/release/libdisk/create_chunk.c b/release/libdisk/create_chunk.c index 27652e6..0bb6c08 100644 --- a/release/libdisk/create_chunk.c +++ b/release/libdisk/create_chunk.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: create_chunk.c,v 1.3 1995/04/29 07:21:10 phk Exp $ + * $Id: create_chunk.c,v 1.4 1995/04/30 06:09:25 phk Exp $ * */ @@ -128,7 +128,6 @@ int Create_Chunk(struct disk *d, u_long offset, u_long size, chunk_e type, int subtype, u_long flags) { int i; - u_long l1,l2,end = offset + size; i = Add_Chunk(d,offset,size,"X",type,subtype,flags); Fixup_Names(d); diff --git a/release/libdisk/disk.c b/release/libdisk/disk.c index c73d819..f421224 100644 --- a/release/libdisk/disk.c +++ b/release/libdisk/disk.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: disk.c,v 1.6 1995/04/30 06:09:26 phk Exp $ + * $Id: disk.c,v 1.7 1995/04/30 07:30:43 phk Exp $ * */ @@ -65,6 +65,12 @@ Int_Open_Disk(char *name, u_long size) return 0; } + for(i=0;i<ds.dss_nslices;i++) + if(ds.dss_slices[i].ds_openmask) + printf(" open(%d)=0x%2x", + i,ds.dss_slices[i].ds_openmask); + printf("\n"); + if (!size) size = ds.dss_slices[WHOLE_DISK_SLICE].ds_size; @@ -97,7 +103,7 @@ Int_Open_Disk(char *name, u_long size) if (Add_Chunk(d, 0, 1, "-",reserved,0,0)) warn("Failed to add MBR chunk"); - for(i=BASE_SLICE;i < 12 && i<ds.dss_nslices;i++) { + for(i=BASE_SLICE;i<ds.dss_nslices;i++) { char sname[20]; chunk_e ce; u_long flags=0; @@ -105,12 +111,13 @@ Int_Open_Disk(char *name, u_long size) if (! ds.dss_slices[i].ds_size) continue; sprintf(sname,"%ss%d",name,i-1); + subtype = ds.dss_slices[i].ds_type; switch (ds.dss_slices[i].ds_type) { case 0xa5: ce = freebsd; break; case 0x1: - case 0x6: + case 0x4: ce = fat; break; case DOSPTYP_EXTENDED: @@ -118,7 +125,6 @@ Int_Open_Disk(char *name, u_long size) break; default: ce = foo; - subtype = -ds.dss_slices[i].ds_type; break; } flags |= CHUNK_ALIGN; @@ -129,45 +135,56 @@ Int_Open_Disk(char *name, u_long size) if (Add_Chunk(d,ds.dss_slices[i].ds_offset, 1, "-",reserved, subtype, flags)) warn("failed to add MBR chunk for slice %d",i - 1); - if (ds.dss_slices[i].ds_type == 0xa5) { - struct disklabel *dl; + if (ds.dss_slices[i].ds_type != 0xa5) + continue; + { + struct disklabel dl; + char pname[20]; + int j,k; - dl = read_disklabel(fd, - ds.dss_slices[i].ds_offset + LABELSECTOR); - if(dl) { - char pname[20]; - int j; - u_long l; - if (dl->d_partitions[RAW_PART].p_offset == 0 && - dl->d_partitions[RAW_PART].p_size == - ds.dss_slices[i].ds_size) - l = ds.dss_slices[i].ds_offset; - else - l = 0; - for(j=0; j < dl->d_npartitions; j++) { - sprintf(pname,"%s%c",sname,j+'a'); - if (j == RAW_PART || j == 3) - continue; - if (!dl->d_partitions[j].p_size) - continue; - if (Add_Chunk(d, - dl->d_partitions[j].p_offset + - l, - dl->d_partitions[j].p_size, - pname,part,0,0)) - warn( - "Failed to add chunk for partition %c [%lu,%lu]", - j + 'a',dl->d_partitions[j].p_offset,dl->d_partitions[j].p_size); - } - sprintf(pname,"%sd",sname); - if (dl->d_partitions[3].p_size) - Add_Chunk(d, - dl->d_partitions[3].p_offset + - l, - dl->d_partitions[3].p_size, - pname,part,0,0); - free(dl); + strcpy(pname,"/dev/r"); + strcat(pname,sname); + j = open(pname,O_RDONLY); + if (j < 0) { + warn("open(%s)",pname); + continue; + } + k = ioctl(j,DIOCGDINFO,&dl); + if (k < 0) { + warn("ioctl(%s,DIOCGDINFO)",pname); + close(j); + continue; + } + close(j); + + for(j=0; j <= dl.d_npartitions; j++) { + if (j == RAW_PART) + continue; + if (j == 3) + continue; + if (j == dl.d_npartitions) { + j = 3; + dl.d_npartitions=0; } + if (!dl.d_partitions[j].p_size) + continue; + if (dl.d_partitions[j].p_size + + dl.d_partitions[j].p_offset > + ds.dss_slices[i].ds_size) + continue; + sprintf(pname,"%s%c",sname,j+'a'); + if (Add_Chunk(d, + dl.d_partitions[j].p_offset + + ds.dss_slices[i].ds_offset, + dl.d_partitions[j].p_size, + pname,part, + dl.d_partitions[j].p_fstype, + 0) && j != 3) + warn( + "Failed to add chunk for partition %c [%lu,%lu]", + j + 'a',dl.d_partitions[j].p_offset, + dl.d_partitions[j].p_size); + } } } close(fd); @@ -216,8 +233,8 @@ Clone_Disk(struct disk *d) memcpy(d2->boot1,d->boot1,512); } if(d2->boot2) { - d2->boot2 = malloc(512*7); - memcpy(d2->boot2,d->boot2,512*7); + d2->boot2 = malloc(512*15); + memcpy(d2->boot2,d->boot2,512*15); } return d2; } @@ -284,7 +301,7 @@ Set_Boot_Blocks(struct disk *d, u_char *b1, u_char *b2) if(!d->boot1) err(1,"malloc failed"); memcpy(d->boot1,b1,512); if (d->boot2) free(d->boot2); - d->boot2 = malloc(7*512); + d->boot2 = malloc(15*512); if(!d->boot2) err(1,"malloc failed"); - memcpy(d->boot2,b2,7*512); + memcpy(d->boot2,b2,15*512); } diff --git a/release/libdisk/libdisk.h b/release/libdisk/libdisk.h index 827fd4b..dab99a4 100644 --- a/release/libdisk/libdisk.h +++ b/release/libdisk/libdisk.h @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: libdisk.h,v 1.5 1995/04/29 07:21:11 phk Exp $ + * $Id: libdisk.h,v 1.6 1995/04/30 06:09:27 phk Exp $ * */ @@ -187,6 +187,7 @@ struct disklabel * read_disklabel(int, daddr_t); u_short dkcksum(struct disklabel *); struct chunk * Find_Mother_Chunk(struct chunk *, u_long , u_long , chunk_e); struct disk * Int_Open_Disk(char *name, u_long size); +void Fixup_Names(struct disk *); #define dprintf printf diff --git a/release/libdisk/tst01.c b/release/libdisk/tst01.c index e175b5c..2e8fe53 100644 --- a/release/libdisk/tst01.c +++ b/release/libdisk/tst01.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: tst01.c,v 1.5 1995/04/29 07:21:13 phk Exp $ + * $Id: tst01.c,v 1.6 1995/04/30 06:09:28 phk Exp $ * */ @@ -24,6 +24,55 @@ CHAR_N; +u_char mbr[] = { +250,51,192,142,208,188,0,124,139,244,80,7,80,31,251,252,191,0,6,185,0,1, +242,165,234,29,6,0,0,190,190,7,179,4,128,60,128,116,14,128,60,0,117,28, +131,198,16,254,203,117,239,205,24,139,20,139,76,2,139,238,131,198,16,254, +203,116,26,128,60,0,116,244,190,139,6,172,60,0,116,11,86,187,7,0,180,14, +205,16,94,235,240,235,254,191,5,0,187,0,124,184,1,2,87,205,19,95,115,12, +51,192,205,19,79,117,237,190,163,6,235,211,190,194,6,191,254,125,129,61, +85,170,117,199,139,245,234,0,124,0,0,73,110,118,97,108,105,100,32,112,97, +114,116,105,116,105,111,110,32,116,97,98,108,101,0,69,114,114,111,114,32, +108,111,97,100,105,110,103,32,111,112,101,114,97,116,105,110,103,32,115, +121,115,116,101,109,0,77,105,115,115,105,110,103,32,111,112,101,114,97, +116,105,110,103,32,115,121,115,116,101,109,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128, +1,1,0,4,15,63,60,63,0,0,0,241,239,0,0,0,0,1,61,5,15,63,243,48,240,0,0,144, +208,2,0,0,0,1,244,165,15,63,170,192,192,3,0,144,208,2,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,85,170 +}; + +u_char bteasy17[] = { +51,192,142,192,142,216,142,208,188,0,124,252,139,244,191,0,6,185,0,1,242, +165,234,96,6,0,0,139,213,88,162,72,7,60,53,116,28,180,16,246,228,5,174, +4,150,246,68,4,255,116,62,198,4,128,232,218,0,138,116,1,139,76,2,235,8, +232,207,0,185,1,0,50,209,187,0,124,184,1,2,205,19,114,30,129,191,254,1, +85,170,117,22,234,0,124,0,0,128,250,129,116,2,178,128,139,234,66,128,242, +179,136,22,58,7,191,190,7,185,4,0,198,6,45,7,49,50,246,136,45,138,69,4, +60,0,116,35,60,5,116,31,254,198,190,42,7,232,113,0,190,72,7,70,70,139,28, +10,255,116,5,50,125,4,117,243,141,183,114,7,232,90,0,131,199,16,254,6,45, +7,226,203,128,62,117,4,2,116,11,190,59,7,10,246,117,10,205,24,235,172,190, +42,7,232,57,0,232,54,0,50,228,205,26,139,218,131,195,96,180,1,205,22,180, +0,117,11,205,26,59,211,114,242,160,72,7,235,10,205,22,138,196,60,28,116, +243,4,246,60,49,114,214,60,53,119,210,80,190,40,7,187,27,6,83,252,172,80, +36,127,180,14,205,16,88,168,128,116,242,195,86,184,1,3,187,0,6,185,1,0, +50,246,205,19,94,198,6,72,7,63,195,13,138,13,10,70,48,32,46,32,46,32,46, +160,100,105,115,107,32,49,13,10,10,68,101,102,97,117,108,116,58,32,70,63, +160,0,1,0,4,0,6,3,7,7,10,10,99,14,100,14,101,20,128,20,129,25,130,30,147, +36,165,39,159,43,117,47,82,47,219,50,64,55,242,61,0,100,111,243,72,80,70, +211,79,115,178,85,110,105,248,78,111,118,101,108,236,77,105,110,105,248, +76,105,110,117,248,65,109,111,101,98,225,66,83,196,66,83,68,233,80,67,73, +216,67,80,205,86,101,110,105,248,68,111,115,115,101,227,63,191,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,85,170 +}; + int main(int argc, char **argv) { @@ -46,7 +95,7 @@ main(int argc, char **argv) sprintf(myprompt,"%s %s> ",argv[0],argv[1]); while(1) { - printf("\n\n\n\n"); + printf("--==##==--\n"); Debug_Disk(d); p = CheckRules(d); if (p) { @@ -140,6 +189,14 @@ main(int argc, char **argv) d = db; continue; } + if (!strcasecmp(*cmds,"bteasy")) { + Set_Boot_Mgr(d,bteasy17); + continue; + } + if (!strcasecmp(*cmds,"mbr")) { + Set_Boot_Mgr(d,mbr); + continue; + } if (!strcasecmp(*cmds,"boot")) { extern u_char boot1[],boot2[]; Set_Boot_Blocks(d,boot1,boot2); @@ -158,10 +215,13 @@ main(int argc, char **argv) printf("\tallfreebsd\n"); printf("\tbios cyl hd sect\n"); printf("\tboot\n"); + printf("\tbteasy17\n"); printf("\tcollapse [pointer]\n"); printf("\tcreate offset size enum subtype flags\n"); + printf("\t\tsubtype(part): swap=1, ffs=7\n"); printf("\tdelete pointer\n"); printf("\tlist\n"); + printf("\tmbr\n"); printf("\tphys cyl hd sect\n"); printf("\tquit\n"); printf("\tread [disk]\n"); diff --git a/release/libdisk/write_disk.c b/release/libdisk/write_disk.c index 51e4e4a..d4d1c8a 100644 --- a/release/libdisk/write_disk.c +++ b/release/libdisk/write_disk.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: write_disk.c,v 1.2 1995/04/30 06:09:29 phk Exp $ + * $Id: write_disk.c,v 1.3 1995/04/30 07:30:45 phk Exp $ * */ @@ -64,6 +64,7 @@ Write_FreeBSD(int fd, struct disk *new, struct disk *old, struct chunk *c1) } dl->d_partitions[j].p_size = c2->size; dl->d_partitions[j].p_offset = c2->offset - c1->offset; + dl->d_partitions[j].p_fstype = c2->subtype; } @@ -71,10 +72,12 @@ Write_FreeBSD(int fd, struct disk *new, struct disk *old, struct chunk *c1) strcpy(dl->d_typename,c1->name); + dl->d_secsize = 512; dl->d_secperunit = new->chunks->size; dl->d_secpercyl = new->real_cyl ? new->real_cyl : new->bios_cyl; dl->d_ntracks = new->real_hd ? new->real_hd : new->bios_hd; dl->d_nsectors = new->real_sect ? new->real_sect : new->bios_sect; + dl->d_secpercyl = dl->d_ntracks * dl->d_nsectors; dl->d_npartitions = MAXPARTITIONS; @@ -97,7 +100,6 @@ int Write_Extended(int fd, struct disk *new, struct disk *old, struct chunk *c1) { printf("--> Write_Extended()\n"); - Print_Chunk(c1); return 0; } @@ -186,6 +188,8 @@ Write_Disk(struct disk *d1) case foo: dp[j].dp_typ = - c1->subtype; break; + default: + break; } } for(i=0;i<NDOSPART;i++) |