View | Details | Raw Unified | Return to bug 12992
Collapse All | Expand All

(-)msdosfs_fat.c (-4 / +6 lines)
Lines 113-119 Link Here
113
	bn += pmp->pm_fatblk + pmp->pm_curfat * pmp->pm_FATsecs;
113
	bn += pmp->pm_fatblk + pmp->pm_curfat * pmp->pm_FATsecs;
114
114
115
	if (bnp)
115
	if (bnp)
116
		*bnp = bn;
116
		*bnp = bn * pmp->pm_SecBlkRatio;
117
	if (sizep)
117
	if (sizep)
118
		*sizep = size;
118
		*sizep = size;
119
	if (bop)
119
	if (bop)
Lines 182-188 Link Here
182
				return (E2BIG);
182
				return (E2BIG);
183
			}
183
			}
184
			if (bnp)
184
			if (bnp)
185
				*bnp = pmp->pm_rootdirblk + de_cn2bn(pmp, findcn);
185
				*bnp = (pmp->pm_rootdirblk + de_cn2bn(pmp,
186
				    findcn)) * pmp->pm_SecBlkRatio;
186
			if (cnp)
187
			if (cnp)
187
				*cnp = MSDOSFSROOT;
188
				*cnp = MSDOSFSROOT;
188
			if (sp)
189
			if (sp)
Lines 364-370 Link Here
364
				+ ffs(pmp->pm_inusemap[cn / N_INUSEBITS]
365
				+ ffs(pmp->pm_inusemap[cn / N_INUSEBITS]
365
				      ^ (u_int)-1) - 1;
366
				      ^ (u_int)-1) - 1;
366
		}
367
		}
367
		if (bread(pmp->pm_devvp, pmp->pm_fsinfo, 1024, NOCRED, &bpn) != 0) {
368
		if (bread(pmp->pm_devvp, pmp->pm_fsinfo * pmp->pm_SecBlkRatio,
369
			  fsi_size(pmp->pm_SecBlkRatio), NOCRED, &bpn) != 0) {
368
			/*
370
			/*
369
			 * Ignore the error, but turn off FSInfo update for the future.
371
			 * Ignore the error, but turn off FSInfo update for the future.
370
			 */
372
			 */
Lines 394-400 Link Here
394
		 * bwrite()'s and really slow things down.
396
		 * bwrite()'s and really slow things down.
395
		 */
397
		 */
396
		for (i = 1; i < pmp->pm_FATs; i++) {
398
		for (i = 1; i < pmp->pm_FATs; i++) {
397
			fatbn += pmp->pm_FATsecs;
399
			fatbn += (pmp->pm_FATsecs * pmp->pm_SecBlkRatio);
398
			/* getblk() never fails */
400
			/* getblk() never fails */
399
			bpn = getblk(pmp->pm_devvp, fatbn, bp->b_bcount, 0, 0);
401
			bpn = getblk(pmp->pm_devvp, fatbn, bp->b_bcount, 0, 0);
400
			bcopy(bp->b_data, bpn->b_data, bp->b_bcount);
402
			bcopy(bp->b_data, bpn->b_data, bp->b_bcount);
(-)msdosfs_vfsops.c (-17 / +22 lines)
Lines 69-74 Link Here
69
#include <msdosfs/msdosfsmount.h>
69
#include <msdosfs/msdosfsmount.h>
70
#include <msdosfs/fat.h>
70
#include <msdosfs/fat.h>
71
71
72
#ifdef PC98
73
/*
74
 * XXX - The boot signature formatted by NEC PC-98 DOS looks like a
75
 *       garbage or a random value :-{
76
 *       If you want to use that broken-signatured media, define the
77
 *       following symbol even though PC/AT.
78
 *       (ex. mount PC-98 DOS formatted FD on PC/AT)
79
 */
80
#define	MSDOSFS_NOCHECKSIG
81
#endif
82
72
MALLOC_DEFINE(M_MSDOSFSMNT, "MSDOSFS mount", "MSDOSFS mount structure");
83
MALLOC_DEFINE(M_MSDOSFSMNT, "MSDOSFS mount", "MSDOSFS mount structure");
73
static MALLOC_DEFINE(M_MSDOSFSFAT, "MSDOSFS FAT", "MSDOSFS file allocation table");
84
static MALLOC_DEFINE(M_MSDOSFSFAT, "MSDOSFS FAT", "MSDOSFS file allocation table");
74
85
Lines 428-439 Link Here
428
	/*
439
	/*
429
	 * Read the boot sector of the filesystem, and then check the
440
	 * Read the boot sector of the filesystem, and then check the
430
	 * boot signature.  If not a dos boot sector then error out.
441
	 * boot signature.  If not a dos boot sector then error out.
442
	 *
443
	 * NOTE: 2048 is a maximum sector size in current...
431
	 */
444
	 */
432
#ifdef	PC98
445
	error = bread(devvp, 0, 2048, NOCRED, &bp);
433
	error = bread(devvp, 0, 1024, NOCRED, &bp);
434
#else
435
	error = bread(devvp, 0, 512, NOCRED, &bp);
436
#endif
437
	if (error)
446
	if (error)
438
		goto error_exit;
447
		goto error_exit;
439
	bp->b_flags |= B_AGE;
448
	bp->b_flags |= B_AGE;
Lines 445-466 Link Here
445
#ifndef __FreeBSD__
454
#ifndef __FreeBSD__
446
	if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) {
455
	if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) {
447
#endif
456
#endif
448
#ifdef PC98
457
#ifndef MSDOSFS_NOCHECKSIG
449
		if ((bsp->bs50.bsBootSectSig0 != BOOTSIG0
450
		    || bsp->bs50.bsBootSectSig1 != BOOTSIG1)
451
		    && (bsp->bs50.bsBootSectSig0 != 0       /* PC98 DOS 3.3x */
452
		    || bsp->bs50.bsBootSectSig1 != 0)
453
		    && (bsp->bs50.bsBootSectSig0 != 0x90    /* PC98 DOS 5.0  */
454
		    || bsp->bs50.bsBootSectSig1 != 0x3d)
455
		    && (bsp->bs50.bsBootSectSig0 != 0x46    /* PC98 DOS 3.3B */
456
		    || bsp->bs50.bsBootSectSig1 != 0xfa)) {
457
#else
458
		if (bsp->bs50.bsBootSectSig0 != BOOTSIG0
458
		if (bsp->bs50.bsBootSectSig0 != BOOTSIG0
459
		    || bsp->bs50.bsBootSectSig1 != BOOTSIG1) {
459
		    || bsp->bs50.bsBootSectSig1 != BOOTSIG1) {
460
#endif
461
			error = EINVAL;
460
			error = EINVAL;
462
			goto error_exit;
461
			goto error_exit;
463
		}
462
		}
463
#endif
464
#ifndef __FreeBSD__
464
#ifndef __FreeBSD__
465
	}
465
	}
466
#endif
466
#endif
Lines 485-490 Link Here
485
	pmp->pm_Heads = getushort(b50->bpbHeads);
485
	pmp->pm_Heads = getushort(b50->bpbHeads);
486
	pmp->pm_Media = b50->bpbMedia;
486
	pmp->pm_Media = b50->bpbMedia;
487
487
488
	/* calculate the ratio of sector size to DEV_BSIZE */
489
	pmp->pm_SecBlkRatio = pmp->pm_BytesPerSec / DEV_BSIZE;
490
488
#ifndef __FreeBSD__
491
#ifndef __FreeBSD__
489
	if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) {
492
	if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) {
490
#endif
493
#endif
Lines 676-682 Link Here
676
	if (pmp->pm_fsinfo) {
679
	if (pmp->pm_fsinfo) {
677
		struct fsinfo *fp;
680
		struct fsinfo *fp;
678
681
679
		if ((error = bread(devvp, pmp->pm_fsinfo, 1024, NOCRED, &bp)) != 0)
682
		if ((error = bread(devvp, pmp->pm_fsinfo * pmp->pm_SecBlkRatio,
683
				   fsi_size(pmp->pm_SecBlkRatio),
684
				   NOCRED, &bp)) != 0)
680
			goto error_exit;
685
			goto error_exit;
681
		fp = (struct fsinfo *)bp->b_data;
686
		fp = (struct fsinfo *)bp->b_data;
682
		if (!bcmp(fp->fsisig1, "RRaA", 4)
687
		if (!bcmp(fp->fsisig1, "RRaA", 4)
(-)msdosfsmount.h (-2 / +11 lines)
Lines 68-73 Link Here
68
	mode_t pm_mask;		/* mask to and with file protection bits */
68
	mode_t pm_mask;		/* mask to and with file protection bits */
69
	struct vnode *pm_devvp;	/* vnode for block device mntd */
69
	struct vnode *pm_devvp;	/* vnode for block device mntd */
70
	struct bpb50 pm_bpb;	/* BIOS parameter blk for this fs */
70
	struct bpb50 pm_bpb;	/* BIOS parameter blk for this fs */
71
	int pm_SecBlkRatio;	/* How many DEV_BSIZE blocks fit inside a physical sector */
71
	u_long pm_FATsecs;	/* actual number of fat sectors */
72
	u_long pm_FATsecs;	/* actual number of fat sectors */
72
	u_long pm_fatblk;	/* block # of first FAT */
73
	u_long pm_fatblk;	/* block # of first FAT */
73
	u_long pm_rootdirblk;	/* block # (cluster # for FAT32) of root directory number */
74
	u_long pm_rootdirblk;	/* block # (cluster # for FAT32) of root directory number */
Lines 174-186 Link Here
174
 * Map a cluster number into a filesystem relative block number.
175
 * Map a cluster number into a filesystem relative block number.
175
 */
176
 */
176
#define	cntobn(pmp, cn) \
177
#define	cntobn(pmp, cn) \
177
	(de_cn2bn((pmp), (cn)-CLUST_FIRST) + (pmp)->pm_firstcluster)
178
	((de_cn2bn((pmp), (cn)-CLUST_FIRST) + (pmp)->pm_firstcluster) \
179
	 * (pmp)->pm_SecBlkRatio)
178
180
179
/*
181
/*
180
 * Calculate block number for directory entry in root dir, offset dirofs
182
 * Calculate block number for directory entry in root dir, offset dirofs
181
 */
183
 */
182
#define	roottobn(pmp, dirofs) \
184
#define	roottobn(pmp, dirofs) \
183
	(de_blk((pmp), (dirofs)) + (pmp)->pm_rootdirblk)
185
	((de_blk((pmp), (dirofs)) + (pmp)->pm_rootdirblk) \
186
	 * (pmp)->pm_SecBlkRatio)
184
187
185
/*
188
/*
186
 * Calculate block number for directory entry at cluster dirclu, offset
189
 * Calculate block number for directory entry at cluster dirclu, offset
Lines 190-195 Link Here
190
	((dirclu) == MSDOSFSROOT \
193
	((dirclu) == MSDOSFSROOT \
191
	 ? roottobn((pmp), (dirofs)) \
194
	 ? roottobn((pmp), (dirofs)) \
192
	 : cntobn((pmp), (dirclu)))
195
	 : cntobn((pmp), (dirclu)))
196
197
/*
198
 * Calculate fsinfo block size
199
 */
200
#define	fsi_size(sbr) \
201
	(1024 << ((sbr) >> 2))
193
202
194
int msdosfs_init __P((struct vfsconf *vfsp));
203
int msdosfs_init __P((struct vfsconf *vfsp));
195
int msdosfs_mountroot __P((void));
204
int msdosfs_mountroot __P((void));

Return to bug 12992