Date: Fri, 6 Aug 1999 07:44:49 +0900 (JST) From: chi@bd.mbn.or.jp To: FreeBSD-gnats-submit@freebsd.org Subject: misc/12992: sector size independent patch for msdosfs(640MB MO,etc) Message-ID: <199908052244.HAA24119@bd.mbn.or.jp>
index | next in thread | raw e-mail
>Number: 12992
>Category: misc
>Synopsis: sector size independent patch for msdosfs(640MB MO,etc)
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Thu Aug 5 15:50:00 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator: Chiharu Shibata
>Release: FreeBSD 3.2-RELEASE i386
>Organization:
FreeBSD(98) development team
>Environment:
Using 640MB MO, GIGA-MO, DVD-RAM, and 1.25MB FD of NEC PC-98.
>Description:
Our msdosfs code only handles 512 bytes/sector media, so we cannot
use 640MB MO, 1.3GB MO (aka GIGA-MO) and DVD-RAM whose sector sizes
are not 512 bytes/sector.
1.25MB FD of NEC PC-98 has same problem.
This is the patch which can handle those non-512 bytes/sector media,
useful both FreeBSD and FreeBSD(98).
>How-To-Repeat:
>Fix:
This patch was once reviewed committers ML via Mr. Kato, and
comments are reflected.
diff -ru /sys/msdosfs/msdosfs_fat.c msdosfs_fat.c
--- /sys/msdosfs/msdosfs_fat.c Thu Apr 16 02:46:42 1998
+++ msdosfs_fat.c Wed Jul 28 17:14:11 1999
@@ -113,7 +113,7 @@
bn += pmp->pm_fatblk + pmp->pm_curfat * pmp->pm_FATsecs;
if (bnp)
- *bnp = bn;
+ *bnp = bn * pmp->pm_SecBlkRatio;
if (sizep)
*sizep = size;
if (bop)
@@ -182,7 +182,8 @@
return (E2BIG);
}
if (bnp)
- *bnp = pmp->pm_rootdirblk + de_cn2bn(pmp, findcn);
+ *bnp = (pmp->pm_rootdirblk + de_cn2bn(pmp,
+ findcn)) * pmp->pm_SecBlkRatio;
if (cnp)
*cnp = MSDOSFSROOT;
if (sp)
@@ -364,7 +365,8 @@
+ ffs(pmp->pm_inusemap[cn / N_INUSEBITS]
^ (u_int)-1) - 1;
}
- if (bread(pmp->pm_devvp, pmp->pm_fsinfo, 1024, NOCRED, &bpn) != 0) {
+ if (bread(pmp->pm_devvp, pmp->pm_fsinfo * pmp->pm_SecBlkRatio,
+ fsi_size(pmp->pm_SecBlkRatio), NOCRED, &bpn) != 0) {
/*
* Ignore the error, but turn off FSInfo update for the future.
*/
@@ -394,7 +396,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);
diff -ru /sys/msdosfs/msdosfs_vfsops.c msdosfs_vfsops.c
--- /sys/msdosfs/msdosfs_vfsops.c Wed Apr 21 07:43:34 1999
+++ msdosfs_vfsops.c Wed Jul 28 17:14:12 1999
@@ -69,6 +69,17 @@
#include <msdosfs/msdosfsmount.h>
#include <msdosfs/fat.h>
+#ifdef PC98
+/*
+ * XXX - The boot signature formatted by NEC PC-98 DOS looks like a
+ * garbage or a random value :-{
+ * If you want to use that broken-signatured media, define the
+ * following symbol even though PC/AT.
+ * (ex. mount PC-98 DOS formatted FD on PC/AT)
+ */
+#define MSDOSFS_NOCHECKSIG
+#endif
+
MALLOC_DEFINE(M_MSDOSFSMNT, "MSDOSFS mount", "MSDOSFS mount structure");
static MALLOC_DEFINE(M_MSDOSFSFAT, "MSDOSFS FAT", "MSDOSFS file allocation table");
@@ -428,12 +439,10 @@
/*
* Read the boot sector of the filesystem, and then check the
* boot signature. If not a dos boot sector then error out.
+ *
+ * NOTE: 2048 is a maximum sector size in current...
*/
-#ifdef PC98
- error = bread(devvp, 0, 1024, NOCRED, &bp);
-#else
- error = bread(devvp, 0, 512, NOCRED, &bp);
-#endif
+ error = bread(devvp, 0, 2048, NOCRED, &bp);
if (error)
goto error_exit;
bp->b_flags |= B_AGE;
@@ -445,22 +454,13 @@
#ifndef __FreeBSD__
if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) {
#endif
-#ifdef PC98
- if ((bsp->bs50.bsBootSectSig0 != BOOTSIG0
- || bsp->bs50.bsBootSectSig1 != BOOTSIG1)
- && (bsp->bs50.bsBootSectSig0 != 0 /* PC98 DOS 3.3x */
- || bsp->bs50.bsBootSectSig1 != 0)
- && (bsp->bs50.bsBootSectSig0 != 0x90 /* PC98 DOS 5.0 */
- || bsp->bs50.bsBootSectSig1 != 0x3d)
- && (bsp->bs50.bsBootSectSig0 != 0x46 /* PC98 DOS 3.3B */
- || bsp->bs50.bsBootSectSig1 != 0xfa)) {
-#else
+#ifndef MSDOSFS_NOCHECKSIG
if (bsp->bs50.bsBootSectSig0 != BOOTSIG0
|| bsp->bs50.bsBootSectSig1 != BOOTSIG1) {
-#endif
error = EINVAL;
goto error_exit;
}
+#endif
#ifndef __FreeBSD__
}
#endif
@@ -485,6 +485,9 @@
pmp->pm_Heads = getushort(b50->bpbHeads);
pmp->pm_Media = b50->bpbMedia;
+ /* calculate the ratio of sector size to DEV_BSIZE */
+ pmp->pm_SecBlkRatio = pmp->pm_BytesPerSec / DEV_BSIZE;
+
#ifndef __FreeBSD__
if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) {
#endif
@@ -676,7 +679,9 @@
if (pmp->pm_fsinfo) {
struct fsinfo *fp;
- if ((error = bread(devvp, pmp->pm_fsinfo, 1024, NOCRED, &bp)) != 0)
+ if ((error = bread(devvp, pmp->pm_fsinfo * pmp->pm_SecBlkRatio,
+ fsi_size(pmp->pm_SecBlkRatio),
+ NOCRED, &bp)) != 0)
goto error_exit;
fp = (struct fsinfo *)bp->b_data;
if (!bcmp(fp->fsisig1, "RRaA", 4)
diff -ru /sys/msdosfs/msdosfsmount.h msdosfsmount.h
--- /sys/msdosfs/msdosfsmount.h Tue Feb 24 01:44:37 1998
+++ msdosfsmount.h Wed Jul 28 17:14:12 1999
@@ -68,6 +68,7 @@
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_FATsecs; /* actual number of fat sectors */
u_long pm_fatblk; /* block # of first FAT */
u_long pm_rootdirblk; /* block # (cluster # for FAT32) of root directory number */
@@ -174,13 +175,15 @@
* Map a cluster number into a filesystem relative block number.
*/
#define cntobn(pmp, cn) \
- (de_cn2bn((pmp), (cn)-CLUST_FIRST) + (pmp)->pm_firstcluster)
+ ((de_cn2bn((pmp), (cn)-CLUST_FIRST) + (pmp)->pm_firstcluster) \
+ * (pmp)->pm_SecBlkRatio)
/*
* Calculate block number for directory entry in root dir, offset dirofs
*/
#define roottobn(pmp, dirofs) \
- (de_blk((pmp), (dirofs)) + (pmp)->pm_rootdirblk)
+ ((de_blk((pmp), (dirofs)) + (pmp)->pm_rootdirblk) \
+ * (pmp)->pm_SecBlkRatio)
/*
* Calculate block number for directory entry at cluster dirclu, offset
@@ -190,6 +193,12 @@
((dirclu) == MSDOSFSROOT \
? roottobn((pmp), (dirofs)) \
: cntobn((pmp), (dirclu)))
+
+/*
+ * Calculate fsinfo block size
+ */
+#define fsi_size(sbr) \
+ (1024 << ((sbr) >> 2))
int msdosfs_init __P((struct vfsconf *vfsp));
int msdosfs_mountroot __P((void));
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199908052244.HAA24119>
