Date: Fri, 24 Dec 1999 01:50:02 -0800 (PST) From: Boris Popov <bp@butya.kz> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/15136: Panic on MSDOS FS mount Message-ID: <199912240950.BAA88522@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/15136; it has been noted by GNATS. From: Boris Popov <bp@butya.kz> To: freebsd-gnats-submit@freebsd.org, netch@lucky.net Cc: Subject: Re: kern/15136: Panic on MSDOS FS mount Date: Fri, 24 Dec 1999 15:41:23 +0600 > On attempt to mount MSDOS (FAT16) file system, kernel falls to panic with > message: > panic: vm_fault: fault on nofault entry, addr=c16de000 This caused by inconsistent data in the boot record. Could please test the following patch and tell me if this helps: diff -u ../msdosfs_vfsops.c ./msdosfs_vfsops.c --- ../msdosfs_vfsops.c Sun Dec 19 12:07:56 1999 +++ ./msdosfs_vfsops.c Fri Dec 24 15:15:08 1999 @@ -364,6 +364,7 @@ struct byte_bpb50 *b50; struct byte_bpb710 *b710; u_int8_t SecPerClust; + u_long clusters; int ronly, error; /* @@ -595,14 +596,13 @@ pmp->pm_firstcluster = pmp->pm_rootdirblk + pmp->pm_rootdirsize; } - pmp->pm_nmbrofclusters = (pmp->pm_HugeSectors - pmp->pm_firstcluster) / - SecPerClust; - pmp->pm_maxcluster = pmp->pm_nmbrofclusters + 1; + pmp->pm_maxcluster = (pmp->pm_HugeSectors - pmp->pm_firstcluster) / + SecPerClust + 1; pmp->pm_fatsize = pmp->pm_FATsecs * pmp->pm_BytesPerSec; #ifndef __FreeBSD__ if (argp->flags & MSDOSFSMNT_GEMDOSFS) { - if ((pmp->pm_nmbrofclusters <= (0xff0 - 2)) + if ((pmp->pm_maxcluster <= (0xff0 - 2)) && ((dtype == DTYPE_FLOPPY) || ((dtype == DTYPE_VNODE) && ((pmp->pm_Heads == 1) || (pmp->pm_Heads == 2)))) ) { @@ -633,6 +633,15 @@ pmp->pm_fatdiv = 1; } } + + clusters = (pmp->pm_fatsize / pmp->pm_fatmult) * pmp->pm_fatdiv; + if (pmp->pm_maxcluster >= clusters) { + printf("Warning: number of clusters (%ld) exceeds FAT " + "capasity (%ld)\n", pmp->pm_maxcluster + 1, clusters); + pmp->pm_maxcluster = clusters - 1; + } + + if (FAT12(pmp)) pmp->pm_fatblocksize = 3 * pmp->pm_BytesPerSec; else @@ -829,7 +838,7 @@ pmp = VFSTOMSDOSFS(mp); sbp->f_bsize = pmp->pm_bpcluster; sbp->f_iosize = pmp->pm_bpcluster; - sbp->f_blocks = pmp->pm_nmbrofclusters; + sbp->f_blocks = pmp->pm_maxcluster + 1; sbp->f_bfree = pmp->pm_freeclustercount; sbp->f_bavail = pmp->pm_freeclustercount; sbp->f_files = pmp->pm_RootDirEnts; /* XXX */ diff -u ../msdosfsmount.h ./msdosfsmount.h --- ../msdosfsmount.h Sat Aug 28 07:48:11 1999 +++ ./msdosfsmount.h Fri Dec 24 12:18:12 1999 @@ -73,7 +73,6 @@ u_long pm_rootdirblk; /* block # (cluster # for FAT32) of root directory number */ u_long pm_rootdirsize; /* size in blocks (not clusters) */ u_long pm_firstcluster; /* block number of first cluster */ - u_long pm_nmbrofclusters; /* # of clusters in filesystem */ u_long pm_maxcluster; /* maximum cluster number */ u_long pm_freeclustercount; /* number of free clusters */ u_long pm_cnshift; /* shift file offset right this amount to get a cluster number */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199912240950.BAA88522>