summaryrefslogtreecommitdiffstats
path: root/sbin/i386
diff options
context:
space:
mode:
authorsos <sos@FreeBSD.org>1996-12-01 11:25:38 +0000
committersos <sos@FreeBSD.org>1996-12-01 11:25:38 +0000
commit304d831859d554948e48205432147cf4e04acca8 (patch)
tree3caeb1000fbf433bbefbf62abe3def80c205c219 /sbin/i386
parent33c2e639e1d61f008dac52121511b79f1fb488e6 (diff)
downloadFreeBSD-src-304d831859d554948e48205432147cf4e04acca8.zip
FreeBSD-src-304d831859d554948e48205432147cf4e04acca8.tar.gz
This update adds the support for != 512 byte sector SCSI devices to
the sd & od drivers. There is also slight changes to fdisk & newfs in order to comply with different sectorsizes. Currently sectors of size 512, 1024 & 2048 are supported, the only restriction beeing in fdisk, which hunts for the sectorsize of the device. This is based on patches to od.c and the other system files by John Gumb & Barry Scott, minor changes and the sd.c patches by me. There also exist some patches for the msdos filesys code, but I havn't been able to test those (yet). John Gumb (john@talisker.demon.co.uk) Barry Scott (barry@scottb.demon.co.uk)
Diffstat (limited to 'sbin/i386')
-rw-r--r--sbin/i386/fdisk/fdisk.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/sbin/i386/fdisk/fdisk.c b/sbin/i386/fdisk/fdisk.c
index b89d865..38506b5 100644
--- a/sbin/i386/fdisk/fdisk.c
+++ b/sbin/i386/fdisk/fdisk.c
@@ -54,7 +54,9 @@ static char lbuf[LBUF];
#define RoundCyl(x) ((((x) + cylsecs - 1) / cylsecs) * cylsecs)
-#define SECSIZE 512
+#define MAX_SEC_SIZE 2048 /* maximum section size that is supported */
+#define MIN_SEC_SIZE 512 /* the sector size to start sensing at */
+int secsize = 0; /* the sensed sector size */
const char *disk;
const char *disks[] =
@@ -74,6 +76,8 @@ struct mboot
unsigned char bootinst[DOSPARTOFF];
struct dos_partition parts[4];
unsigned short int signature;
+ /* room to read in MBRs that are bigger then DEV_BSIZE */
+ unsigned char large_sector_overflow[MAX_SEC_SIZE-MIN_SEC_SIZE];
};
struct mboot mboot;
@@ -367,6 +371,7 @@ main(int argc, char *argv[])
if (read_s0())
init_sector0(1);
+ printf("Media sector size is %d\n", secsize);
printf("Warning: BIOS sector numbering starts with sector 1\n");
printf("Information from DOS bootblock is:\n");
if (partition == -1)
@@ -433,7 +438,7 @@ struct dos_partition *partp = ((struct dos_partition *) &mboot.parts) + i;
printf("sysid %d,(%s)\n", partp->dp_typ, get_type(partp->dp_typ));
printf(" start %ld, size %ld (%ld Meg), flag %x\n",
partp->dp_start,
- partp->dp_size, partp->dp_size * 512 / (1024 * 1024),
+ partp->dp_size, partp->dp_size * secsize / (1024 * 1024),
partp->dp_flag);
printf("\tbeg: cyl %d/ sector %d/ head %d;\n\tend: cyl %d/ sector %d/ head %d\n"
,DPCYL(partp->dp_scyl, partp->dp_ssect)
@@ -538,7 +543,7 @@ print_params()
printf("cylinders=%d heads=%d sectors/track=%d (%d blks/cyl)\n\n"
,cyls,heads,sectors,cylsecs);
if((dos_sectors > 63) || (dos_cyls > 1023) || (dos_heads > 255))
- printf(" Figures below won't work with BIOS for partitions not in cyl 1\n");
+ printf("Figures below won't work with BIOS for partitions not in cyl 1\n");
printf("parameters to be used for BIOS calculations are:\n");
printf("cylinders=%d heads=%d sectors/track=%d (%d blks/cyl)\n\n"
,dos_cyls,dos_heads,dos_sectors,dos_cylsecs);
@@ -646,14 +651,28 @@ static ssize_t
read_disk(off_t sector, void *buf)
{
lseek(fd,(sector * 512), 0);
- return read(fd, buf, 512);
+ if( secsize == 0 )
+ for( secsize = MIN_SEC_SIZE; secsize <= MAX_SEC_SIZE; secsize *= 2 )
+ {
+ /* try the read */
+ int size = read(fd, buf, secsize);
+ if( size == secsize )
+ /* it worked so return */
+ return secsize;
+ }
+ else
+ return read( fd, buf, secsize );
+
+ /* we failed to read at any of the sizes */
+ return -1;
}
static ssize_t
write_disk(off_t sector, void *buf)
{
lseek(fd,(sector * 512), 0);
- return write(fd, buf, 512);
+ /* write out in the size that the read_disk found worked */
+ return write(fd, buf, secsize);
}
static int
OpenPOWER on IntegriCloud