summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2009-01-05 01:14:40 +0000
committerkrw <krw@openbsd.org>2009-01-05 01:14:40 +0000
commit8bc3fffe29f6a11e76cd34021c18389af0abf518 (patch)
tree58ee17b7888c6ebbb0edcdcd91520f81e0573cbe
parenttry to get better default outputs.master.slaves by not including (diff)
downloadwireguard-openbsd-8bc3fffe29f6a11e76cd34021c18389af0abf518.tar.xz
wireguard-openbsd-8bc3fffe29f6a11e76cd34021c18389af0abf518.zip
The FAT32 fsinxtfree field is advisory in nature and we don't use
it. So leave it untouched. Similiar to but more ruthless than the fixes FreeBSD did, since they do use the value. Basically avoid various off-by-one and off-by-many errors. Fixes problems encountered by jsg@ and deraadt@ where filesystems found on SDHC cards caused UVM faults. Original fixes found by jsg@. ok jsg@.
-rw-r--r--sys/msdosfs/msdosfs_fat.c19
-rw-r--r--sys/msdosfs/msdosfs_vfsops.c5
-rw-r--r--sys/msdosfs/msdosfsmount.h3
3 files changed, 5 insertions, 22 deletions
diff --git a/sys/msdosfs/msdosfs_fat.c b/sys/msdosfs/msdosfs_fat.c
index 325620473ee..9f8d1dab8d3 100644
--- a/sys/msdosfs/msdosfs_fat.c
+++ b/sys/msdosfs/msdosfs_fat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_fat.c,v 1.19 2006/12/16 12:44:05 krw Exp $ */
+/* $OpenBSD: msdosfs_fat.c,v 1.20 2009/01/05 01:14:40 krw Exp $ */
/* $NetBSD: msdosfs_fat.c,v 1.26 1997/10/17 11:24:02 ws Exp $ */
/*-
@@ -348,22 +348,6 @@ updatefats(pmp, bp, fatbn)
* If we have an FSInfo block, update it.
*/
if (pmp->pm_fsinfo) {
- uint32_t cn = pmp->pm_nxtfree;
-
- if (pmp->pm_freeclustercount
- && (pmp->pm_inusemap[cn / N_INUSEBITS]
- & (1 << (cn % N_INUSEBITS)))) {
- /*
- * The cluster indicated in FSInfo isn't free
- * any longer. Got get a new free one.
- */
- for (cn = 0; cn < pmp->pm_maxcluster; cn++)
- if (pmp->pm_inusemap[cn / N_INUSEBITS] != (u_int)-1)
- break;
- pmp->pm_nxtfree = cn
- + ffs(pmp->pm_inusemap[cn / N_INUSEBITS]
- ^ (u_int)-1) - 1;
- }
if (bread(pmp->pm_devvp, pmp->pm_fsinfo, fsi_size(pmp), NOCRED,
&bpn) != 0) {
/*
@@ -375,7 +359,6 @@ updatefats(pmp, bp, fatbn)
struct fsinfo *fp = (struct fsinfo *)bpn->b_data;
putulong(fp->fsinfree, pmp->pm_freeclustercount);
- putulong(fp->fsinxtfree, pmp->pm_nxtfree);
if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT)
bwrite(bpn);
else
diff --git a/sys/msdosfs/msdosfs_vfsops.c b/sys/msdosfs/msdosfs_vfsops.c
index d2dbf43dd5e..1802e8c2a6a 100644
--- a/sys/msdosfs/msdosfs_vfsops.c
+++ b/sys/msdosfs/msdosfs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_vfsops.c,v 1.50 2007/11/26 00:30:44 krw Exp $ */
+/* $OpenBSD: msdosfs_vfsops.c,v 1.51 2009/01/05 01:14:40 krw Exp $ */
/* $NetBSD: msdosfs_vfsops.c,v 1.48 1997/10/18 02:54:57 briggs Exp $ */
/*-
@@ -478,7 +478,8 @@ msdosfs_mountfs(devvp, mp, p, argp)
&& !bcmp(fp->fsisig2, "rrAa", 4)
&& !bcmp(fp->fsisig3, "\0\0\125\252", 4)
&& !bcmp(fp->fsisig4, "\0\0\125\252", 4))
- pmp->pm_nxtfree = getulong(fp->fsinxtfree);
+ /* Valid FSInfo. */
+ ;
else
pmp->pm_fsinfo = 0;
brelse(bp);
diff --git a/sys/msdosfs/msdosfsmount.h b/sys/msdosfs/msdosfsmount.h
index 45f72016fde..8a3a5f40adc 100644
--- a/sys/msdosfs/msdosfsmount.h
+++ b/sys/msdosfs/msdosfsmount.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfsmount.h,v 1.18 2006/12/16 12:44:05 krw Exp $ */
+/* $OpenBSD: msdosfsmount.h,v 1.19 2009/01/05 01:14:40 krw Exp $ */
/* $NetBSD: msdosfsmount.h,v 1.16 1997/10/17 11:24:24 ws Exp $ */
/*-
@@ -78,7 +78,6 @@ struct msdosfsmount {
uint32_t pm_fatsize; /* size of fat in bytes */
uint32_t pm_fatmask; /* mask to use for fat numbers */
uint32_t pm_fsinfo; /* fsinfo block number */
- uint32_t pm_nxtfree; /* next free cluster in fsinfo block */
u_int pm_fatmult; /* these 2 values are used in fat */
u_int pm_fatdiv; /* offset computation */
u_int pm_curfat; /* current fat for FAT32 (0 otherwise) */