summaryrefslogtreecommitdiffstats
path: root/sbin
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
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')
-rw-r--r--sbin/fdisk/fdisk.c29
-rw-r--r--sbin/i386/fdisk/fdisk.c29
-rw-r--r--sbin/newfs/mkfs.c4
-rw-r--r--sbin/newfs/newfs.c17
4 files changed, 66 insertions, 13 deletions
diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c
index b89d865..38506b5 100644
--- a/sbin/fdisk/fdisk.c
+++ b/sbin/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
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
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c
index d67090b..20d6832 100644
--- a/sbin/newfs/mkfs.c
+++ b/sbin/newfs/mkfs.c
@@ -82,6 +82,7 @@ extern int nsectors; /* # sectors/track */
extern int nphyssectors; /* # sectors/track including spares */
extern int secpercyl; /* sectors per cylinder */
extern int sectorsize; /* bytes/sector */
+extern int realsectorsize; /* bytes/sector in hardware*/
extern int rpm; /* revolutions/minute of drive */
extern int interleave; /* hardware sector interleave */
extern int trackskew; /* sector 0 skew, per track */
@@ -209,7 +210,8 @@ mkfs(pp, fsys, fi, fo)
*/
if (fssize <= 0)
printf("preposterous size %d\n", fssize), exit(13);
- wtfs(fssize - 1, sectorsize, (char *)&sblock);
+ wtfs(fssize - (realsectorsize / DEV_BSIZE), realsectorsize,
+ (char *)&sblock);
/*
* collect and verify the sector and track info
*/
diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c
index c9f2504..44058b1 100644
--- a/sbin/newfs/newfs.c
+++ b/sbin/newfs/newfs.c
@@ -167,9 +167,7 @@ int secpercyl; /* sectors per cylinder */
int trackspares = -1; /* spare sectors per track */
int cylspares = -1; /* spare sectors per cylinder */
int sectorsize; /* bytes/sector */
-#ifdef tahoe
int realsectorsize; /* bytes/sector in hardware */
-#endif
int rpm; /* revolutions/minute of drive */
int interleave; /* hardware sector interleave */
int trackskew = -1; /* sector 0 skew, per track */
@@ -530,11 +528,26 @@ main(argc, argv)
fssize /= secperblk;
pp->p_size /= secperblk;
}
+#else
+ realsectorsize = sectorsize;
+ if (sectorsize != DEV_BSIZE) { /* XXX */
+ int secperblk = sectorsize / DEV_BSIZE;
+
+ sectorsize = DEV_BSIZE;
+ nsectors *= secperblk;
+ nphyssectors *= secperblk;
+ secpercyl *= secperblk;
+ fssize *= secperblk;
+ pp->p_size *= secperblk;
+ }
#endif
mkfs(pp, special, fsi, fso);
#ifdef tahoe
if (realsectorsize != DEV_BSIZE)
pp->p_size *= DEV_BSIZE / realsectorsize;
+#else
+ if (realsectorsize != DEV_BSIZE)
+ pp->p_size /= realsectorsize /DEV_BSIZE;
#endif
if (!Nflag)
close(fso);
OpenPOWER on IntegriCloud