diff options
author | phk <phk@FreeBSD.org> | 1995-05-01 04:05:27 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1995-05-01 04:05:27 +0000 |
commit | 632f39cd533df1a0c9395254371443c5a394ba45 (patch) | |
tree | c46a25276d72afe90b217d8e55e20c80503b4c84 /release/libdisk | |
parent | 7cb2df48bc34ef37bbb1cf9d3e8ac4b8899a75c9 (diff) | |
download | FreeBSD-src-632f39cd533df1a0c9395254371443c5a394ba45.zip FreeBSD-src-632f39cd533df1a0c9395254371443c5a394ba45.tar.gz |
start CHS is 0xff,0xff,0xff if past 1024.
end CHS is 1023,bios_hd,bios_sect if past 1024. This way we can find
bios the geometry again.
Added a primitive "scan" to tst01.
Diffstat (limited to 'release/libdisk')
-rw-r--r-- | release/libdisk/create_chunk.c | 4 | ||||
-rw-r--r-- | release/libdisk/tst01.c | 54 | ||||
-rw-r--r-- | release/libdisk/write_disk.c | 29 |
3 files changed, 68 insertions, 19 deletions
diff --git a/release/libdisk/create_chunk.c b/release/libdisk/create_chunk.c index 0bb6c08..a2027e2 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.4 1995/04/30 06:09:25 phk Exp $ + * $Id: create_chunk.c,v 1.5 1995/04/30 11:04:12 phk Exp $ * */ @@ -129,6 +129,8 @@ Create_Chunk(struct disk *d, u_long offset, u_long size, chunk_e type, int subty { int i; + if (type == freebsd) + subtype = 0xa5; i = Add_Chunk(d,offset,size,"X",type,subtype,flags); Fixup_Names(d); return i; diff --git a/release/libdisk/tst01.c b/release/libdisk/tst01.c index 2e8fe53..68ecb3d 100644 --- a/release/libdisk/tst01.c +++ b/release/libdisk/tst01.c @@ -6,13 +6,14 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: tst01.c,v 1.6 1995/04/30 06:09:28 phk Exp $ + * $Id: tst01.c,v 1.7 1995/04/30 11:04:16 phk Exp $ * */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <fcntl.h> #include <string.h> #include <err.h> #ifdef READLINE @@ -74,6 +75,52 @@ u_char bteasy17[] = { }; int +scan_block(int fd, daddr_t block) +{ + u_char foo[512]; + + if (-1 == lseek(fd,block * 512,SEEK_SET)) + err(1,"lseek"); + if (512 != read(fd,foo, 512)) + return 1; + return 0; +} + +void +Scan_Disk(struct disk *d) +{ + char device[64]; + u_long l; + int i,j,fd; + + strcpy(device,"/dev/r"); + strcat(device,d->name); + + fd = open(device,O_RDWR); + if (fd < 0) { + warn("open(%s) failed",device); + return; + } + for(i=-1,l=0;;l++) { + j = scan_block(fd,l); + if (j != i) { + if (i == -1) { + printf("%c: %lu.",j ? 'B' : 'G', l); + fflush(stdout); + } else if (i == 0) { + printf(".%lu\nB: %lu.",l-1,l); + fflush(stdout); + } else { + printf(".%lu\nG: %lu.",l-1,l); + fflush(stdout); + } + i = j; + } + } + close(fd); +} + +int main(int argc, char **argv) { struct disk *d,*db; @@ -189,6 +236,10 @@ main(int argc, char **argv) d = db; continue; } + if (!strcasecmp(*cmds,"scan")) { + Scan_Disk(d); + continue; + } if (!strcasecmp(*cmds,"bteasy")) { Set_Boot_Mgr(d,bteasy17); continue; @@ -225,6 +276,7 @@ main(int argc, char **argv) printf("\tphys cyl hd sect\n"); printf("\tquit\n"); printf("\tread [disk]\n"); + printf("\tscan\n"); printf("\twrite\n"); printf("\nENUM:\n\t"); for(i=0;chunk_n[i];i++) diff --git a/release/libdisk/write_disk.c b/release/libdisk/write_disk.c index c97727c..818076a 100644 --- a/release/libdisk/write_disk.c +++ b/release/libdisk/write_disk.c @@ -151,7 +151,6 @@ Write_Disk(struct disk *d1) dp[j].dp_ssect = 0xff; dp[j].dp_shd = 0xff; dp[j].dp_scyl = 0xff; - } else { dp[j].dp_ssect = i % d1->bios_sect; i -= dp[j].dp_ssect++; @@ -163,26 +162,22 @@ Write_Disk(struct disk *d1) i -= dp[j].dp_scyl; dp[j].dp_ssect |= i >> 2; } + printf("S:%lu = (%x/%x/%x)", c1->offset,dp[j].dp_scyl,dp[j].dp_shd,dp[j].dp_ssect); i = c1->end; - if (i >= 1024*d1->bios_sect*d1->bios_hd) { - dp[j].dp_esect = 0xff; - dp[j].dp_ehd = 0xff; - dp[j].dp_ecyl = 0xff; - } else { - dp[j].dp_esect = i % d1->bios_sect; - i -= dp[j].dp_esect++; - i /= d1->bios_sect; - dp[j].dp_ehd = i % d1->bios_hd; - i -= dp[j].dp_ehd; - i /= d1->bios_hd; - dp[j].dp_ecyl = i; - i -= dp[j].dp_ecyl; - dp[j].dp_esect |= i >> 2; - - } + dp[j].dp_esect = i % d1->bios_sect; + i -= dp[j].dp_esect++; + i /= d1->bios_sect; + dp[j].dp_ehd = i % d1->bios_hd; + i -= dp[j].dp_ehd; + i /= d1->bios_hd; + if (i>1023) i = 1023; + dp[j].dp_ecyl = i; + i -= dp[j].dp_ecyl; + dp[j].dp_esect |= i >> 2; + printf(" E:%lu = (%x/%x/%x)\n", c1->end,dp[j].dp_ecyl,dp[j].dp_ehd,dp[j].dp_esect); |