Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Feb 97 11:35:32 JST
From:      Shunsuke Akiyama <akiyama@kme.mei.co.jp>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/2715: MSDOS-FS 1024/2048 byte/sector media support.
Message-ID:  <9702120235.AA15048@kmegate.kme.mei.co.jp>
Resent-Message-ID: <199702120250.SAA12943@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         2715
>Category:       kern
>Synopsis:       MSDOS-FS 1024/2048 byte/sector media support.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 11 18:50:02 PST 1997
>Last-Modified:
>Originator:     Shunsuke Akiyama
>Organization:
Kyushu Matsushita Electric Co., Ltd.
>Release:        FreeBSD 3.0-970124-SNAP i386
>Environment:

	FreeBSD 3.0-970124-SNAP/MSDOS-FS

>Description:

	In freebsd-scsi list, John Gumb (john@talisker.demon.co.uk) and
	Barry Scott (barry@scottb.demon.co.uk) posted their 1024 & 2048
	byte/sector media support patches.
	I've tested their patches and improved for MSDOS-FS support.
	It's works fine for me and other some FreeBSD environments with
	Fujitsu M2513A MO drive and 2048 byte/sector media.

>How-To-Repeat:

	N/A

>Fix:
	
===================================================================
--- sys/msdosfs/msdosfs_fat.c	1997/01/14 06:47:15	1.11
+++ sys/msdosfs/msdosfs_fat.c	1997/02/11 13:21:57
@@ -116,7 +116,7 @@
 	    * pmp->pm_BytesPerSec;
 	bn += pmp->pm_fatblk;
 	if (bnp)
-		*bnp = bn;
+		*bnp = bn * pmp->pm_SecBlkRatio;
 	if (sizep)
 		*sizep = size;
 	if (bop)
@@ -185,7 +185,7 @@
 				return E2BIG;
 			}
 			if (bnp)
-				*bnp = pmp->pm_rootdirblk + (findcn * pmp->pm_SectPerClust);
+				*bnp = (pmp->pm_rootdirblk + (findcn * pmp->pm_SectPerClust)) * pmp->pm_SecBlkRatio;
 			if (cnp)
 				*cnp = MSDOSFSROOT;
 			return 0;
@@ -340,7 +340,7 @@
 	 * bwrite()'s and really slow things down.
 	 */
 	for (i = 1; i < pmp->pm_FATs; i++) {
-		fatbn += pmp->pm_FATsecs;
+		fatbn += pmp->pm_FATsecs * pmp->pm_SecBlkRatio;
 		/* getblk() never fails */
 		bpn = getblk(pmp->pm_devvp, fatbn, bp->b_bcount, 0, 0);
 		bcopy(bp->b_data, bpn->b_data, bp->b_bcount);
===================================================================
--- sys/msdosfs/msdosfs_vfsops.c	1997/02/10 02:16:37	1.15
+++ sys/msdosfs/msdosfs_vfsops.c	1997/02/11 13:21:58
@@ -58,6 +58,9 @@
 #include <sys/mount.h>
 #include <sys/buf.h>
 #include <sys/file.h>
+#include <sys/disklabel.h>
+#include <sys/ioctl.h>
+#include <sys/errno.h>
 #include <sys/malloc.h>
 
 #include <msdosfs/bpb.h>
@@ -273,6 +276,8 @@
 	struct buf *bp0 = NULL;
 	struct byte_bpb33 *b33;
 	struct byte_bpb50 *b50;
+	struct partinfo msdosfspart;
+	int secsize;
 #ifdef	PC98
 	u_int	pc98_wrk;
 	u_int	Phy_Sector_Size;
@@ -300,14 +305,16 @@
 	if (error)
 		return error;
 	needclose = 1;
-#ifdef HDSUPPORT
+
 	/*
 	 * Put this in when we support reading dos filesystems from
 	 * partitioned harddisks.
 	 */
-	if (VOP_IOCTL(devvp, DIOCGPART, &msdosfspart, FREAD, NOCRED, p) == 0) {
+	if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&msdosfspart, FREAD, NOCRED, p) == 0) {
+		secsize = msdosfspart.disklab->d_secsize;
+	} else {
+		secsize = DEV_BSIZE;
 	}
-#endif
 
 	/*
 	 * Read the boot sector of the filesystem, and then check the boot
@@ -319,7 +326,7 @@
 	devvp->v_flag &= 0xffff; 
 	error = bread(devvp, 0, 1024, NOCRED, &bp0);
 #else
-	error = bread(devvp, 0, 512, NOCRED, &bp0);
+	error = bread(devvp, 0, secsize, NOCRED, &bp0);
 #endif
 	if (error)
 		goto error_exit;
@@ -349,6 +356,9 @@
 	pmp = malloc(sizeof *pmp, M_MSDOSFSMNT, M_WAITOK);
 	bzero((caddr_t)pmp, sizeof *pmp);
 	pmp->pm_mountp = mp;
+
+	/* calculate the ratio of sector size to DEV_BSIZE */
+	pmp->pm_SecBlkRatio = secsize/DEV_BSIZE;
 
 	/*
 	 * Compute several useful quantities from the bpb in the
===================================================================
--- sys/msdosfs/msdosfsmount.h	1997/02/10 02:16:44	1.8
+++ sys/msdosfs/msdosfsmount.h	1997/02/11 13:21:58
@@ -60,6 +60,9 @@
 	mode_t pm_mask;		/* mask to and with file protection bits */
 	struct vnode *pm_devvp;	/* vnode for block device mntd */
 	struct bpb50 pm_bpb;	/* BIOS parameter blk for this fs */
+	int pm_SecBlkRatio;	/* How many DEV_BSIZE blocks fit inside
+				 * a physical sector
+				 */
 	u_long pm_fatblk;	/* block # of first FAT */
 	u_long pm_rootdirblk;	/* block # of root directory */
 	u_long pm_rootdirsize;	/* size in blocks (not clusters) */
@@ -124,20 +127,20 @@
  * Map a cluster number into a filesystem relative block number.
  */
 #define	cntobn(pmp, cn) \
-	((((cn)-CLUST_FIRST) * (pmp)->pm_SectPerClust) + (pmp)->pm_firstcluster)
+	(((((cn)-CLUST_FIRST) * (pmp)->pm_SectPerClust) + (pmp)->pm_firstcluster) * (pmp)->pm_SecBlkRatio)
 
 /*
  * Map a filesystem relative block number back into a cluster number.
  */
 #define	bntocn(pmp, bn) \
-	((((bn) - pmp->pm_firstcluster)/ (pmp)->pm_SectPerClust) + CLUST_FIRST)
+	(((((bn)/((pmp)->pm_SecBlkRatio)) - pmp->pm_firstcluster)/ (pmp)->pm_SectPerClust) + CLUST_FIRST)
 
 /*
  * Calculate block number for directory entry in root dir, offset dirofs
  */
 #define	roottobn(pmp, dirofs) \
-	(((dirofs) / (pmp)->pm_depclust) * (pmp)->pm_SectPerClust \
-	+ (pmp)->pm_rootdirblk)
+	((((dirofs) / (pmp)->pm_depclust) * (pmp)->pm_SectPerClust \
+	+ (pmp)->pm_rootdirblk) * (pmp)->pm_SecBlkRatio)
 
 /*
  * Calculate block number for directory entry at cluster dirclu, offset

>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9702120235.AA15048>