Subject: Re: kern/3459: msdosfs_mountfs fails for bigger sector size than 512 bytes
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Michael van Elst <mlelstv@serpens.de>
List: netbsd-bugs
Date: 10/08/2006 14:00:04
The following reply was made to PR kern/3459; it has been noted by GNATS.

From: Michael van Elst <mlelstv@serpens.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/3459: msdosfs_mountfs fails for bigger sector size than 512 bytes
Date: Sun, 8 Oct 2006 15:56:09 +0200

 Maybe this patch is more generic:
 
 
 Index: msdosfs_vfsops.c
 ===================================================================
 RCS file: /cvsroot/src/sys/fs/msdosfs/msdosfs_vfsops.c,v
 retrieving revision 1.33
 diff -u -r1.33 msdosfs_vfsops.c
 --- msdosfs_vfsops.c	23 Jul 2006 22:06:10 -0000	1.33
 +++ msdosfs_vfsops.c	8 Oct 2006 13:48:03 -0000
 @@ -436,6 +436,14 @@
  	bp  = NULL; /* both used in error_exit */
  	pmp = NULL;
  
 +	/* get geometry data */
 +	error = VOP_IOCTL(devvp, DIOCGPART, &dpart, FREAD, NOCRED, l);
 +	if (error)
 +		goto error_exit;
 +	tmp   = dpart.part->p_fstype;
 +	dtype = dpart.disklab->d_type;
 +	bsize = dpart.disklab->d_secsize;
 +
  	if (argp->flags & MSDOSFSMNT_GEMDOSFS) {
  		/*
  	 	 * We need the disklabel to calculate the size of a FAT entry
 @@ -447,12 +455,6 @@
  		 * that the size of a disk block will always be 512 bytes.
  		 * Let's check it...
  		 */
 -		error = VOP_IOCTL(devvp, DIOCGPART, &dpart, FREAD, NOCRED, l);
 -		if (error)
 -			goto error_exit;
 -		tmp   = dpart.part->p_fstype;
 -		dtype = dpart.disklab->d_type;
 -		bsize = dpart.disklab->d_secsize;
  		if (bsize != 512 || (dtype!=DTYPE_FLOPPY && tmp!=FS_MSDOS)) {
  			error = EINVAL;
  			goto error_exit;
 @@ -463,7 +465,7 @@
  	 * Read the boot sector of the filesystem, and then check the
  	 * boot signature.  If not a dos boot sector then error out.
  	 */
 -	if ((error = bread(devvp, 0, 512, NOCRED, &bp)) != 0)
 +	if ((error = bread(devvp, 0, bsize, NOCRED, &bp)) != 0)
  		goto error_exit;
  	bp->b_flags |= B_AGE;
  	bsp = (union bootsector *)bp->b_data;
 @@ -667,7 +669,7 @@
  	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, max(1024,bsize), NOCRED, &bp)) != 0)
  			goto error_exit;
  		fp = (struct fsinfo *)bp->b_data;
  		if (!memcmp(fp->fsisig1, "RRaA", 4)
 
 -- 
                                 Michael van Elst
 Internet: mlelstv@serpens.de
                                 "A potential Snark may lurk in every tree."