CVS commit: src/sys/fs/msdosfs

2021-02-10 Thread Ryo ONODERA
Module Name:src
Committed By:   ryoon
Date:   Thu Feb 11 00:15:55 UTC 2021

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
Enable to mount Raspberry Pi Pico's USB mass storage partition

Fix PR kern/55985.
O.k. by thorpej@.

Pull-up to netbsd-8 and netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.135 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.136
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.135	Mon Apr 13 19:23:17 2020
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Thu Feb 11 00:15:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.135 2020/04/13 19:23:17 ad Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.136 2021/02/11 00:15:55 ryoon Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.135 2020/04/13 19:23:17 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.136 2021/02/11 00:15:55 ryoon Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -520,6 +520,13 @@ msdosfs_mountfs(struct vnode *devvp, str
 	b50 = (struct byte_bpb50 *)bsp->bs50.bsBPB;
 	b710 = (struct byte_bpb710 *)bsp->bs710.bsBPB;
 
+#if 0
+	/*
+	 * Some FAT partition, for example Raspberry Pi Pico's
+	 * USB mass storage, does not have exptected BOOTSIGs.
+	 * According to FreeBSD's comment, some PC-9800/9821
+	 * FAT floppy disks have similar problems.
+	 */
 	if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) {
 		if (bsp->bs50.bsBootSectSig0 != BOOTSIG0
 		|| bsp->bs50.bsBootSectSig1 != BOOTSIG1) {
@@ -530,6 +537,7 @@ msdosfs_mountfs(struct vnode *devvp, str
 			goto error_exit;
 		}
 	}
+#endif
 
 	pmp = malloc(sizeof(*pmp), M_MSDOSFSMNT, M_WAITOK|M_ZERO);
 	pmp->pm_mountp = mp;



CVS commit: src/sys/fs/msdosfs

2020-09-06 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Sep  7 01:35:25 UTC 2020

Modified Files:
src/sys/fs/msdosfs: msdosfs_fat.c

Log Message:
avoid an uninit warning with GCC 9.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/fs/msdosfs/msdosfs_fat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_fat.c
diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.34 src/sys/fs/msdosfs/msdosfs_fat.c:1.35
--- src/sys/fs/msdosfs/msdosfs_fat.c:1.34	Mon Sep  3 16:29:34 2018
+++ src/sys/fs/msdosfs/msdosfs_fat.c	Mon Sep  7 01:35:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_fat.c,v 1.34 2018/09/03 16:29:34 riastradh Exp $	*/
+/*	$NetBSD: msdosfs_fat.c,v 1.35 2020/09/07 01:35:25 mrg Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -52,7 +52,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.34 2018/09/03 16:29:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.35 2020/09/07 01:35:25 mrg Exp $");
 
 /*
  * kernel include files.
@@ -895,6 +895,7 @@ freeclusterchain(struct msdosfsmount *pm
 	u_long bn, bo, bsize, byteoffset;
 	u_long readcn, lbn = -1;
 
+	bn = 0; /* XXXgcc */
 	while (cluster >= CLUST_FIRST && cluster <= pmp->pm_maxcluster) {
 		byteoffset = FATOFS(pmp, cluster);
 		fatblock(pmp, byteoffset, , , );



CVS commit: src/sys/fs/msdosfs

2018-07-25 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Jul 25 22:07:59 UTC 2018

Modified Files:
src/sys/fs/msdosfs: msdosfs_fat.c

Log Message:
Avoid undefined behavior semantics in msdosfs_fat.c

Do not change signedness bit with left shift.
While there avoid signed integer overflow.
Address both issues with using unsigned type.

msdosfs_fat.c:512:42, left shift of 1 by 31 places cannot be represented in 
type 'int'
msdosfs_fat.c:521:44, left shift of 1 by 31 places cannot be represented in 
type 'int'
msdosfs_fat.c:744:14, left shift of 1 by 31 places cannot be represented in 
type 'int'
msdosfs_fat.c:744:24, signed integer overflow: -2147483648 - 1 cannot be 
represented in type 'int [20]'
msdosfs_fat.c:840:13, left shift of 1 by 31 places cannot be represented in 
type 'int'
msdosfs_fat.c:840:36, signed integer overflow: -2147483648 - 1 cannot be 
represented in type 'int [20]'

Detected with micro-UBSan in the user mode.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/fs/msdosfs/msdosfs_fat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_fat.c
diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.32 src/sys/fs/msdosfs/msdosfs_fat.c:1.33
--- src/sys/fs/msdosfs/msdosfs_fat.c:1.32	Sat Jan 27 03:54:01 2018
+++ src/sys/fs/msdosfs/msdosfs_fat.c	Wed Jul 25 22:07:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_fat.c,v 1.32 2018/01/27 03:54:01 sevan Exp $	*/
+/*	$NetBSD: msdosfs_fat.c,v 1.33 2018/07/25 22:07:59 kamil Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -52,7 +52,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.32 2018/01/27 03:54:01 sevan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.33 2018/07/25 22:07:59 kamil Exp $");
 
 /*
  * kernel include files.
@@ -409,7 +409,7 @@ updatefats(struct msdosfsmount *pmp, str
 
 		if (pmp->pm_freeclustercount
 		&& (pmp->pm_inusemap[cn / N_INUSEBITS]
-			& (1 << (cn % N_INUSEBITS {
+			& (1U << (cn % N_INUSEBITS {
 			/*
 			 * The cluster indicated in FSInfo isn't free
 			 * any longer.  Got get a new free one.
@@ -509,7 +509,7 @@ static inline void
 usemap_alloc(struct msdosfsmount *pmp, u_long cn)
 {
 
-	pmp->pm_inusemap[cn / N_INUSEBITS] |= 1 << (cn % N_INUSEBITS);
+	pmp->pm_inusemap[cn / N_INUSEBITS] |= 1U << (cn % N_INUSEBITS);
 	pmp->pm_freeclustercount--;
 }
 
@@ -518,7 +518,7 @@ usemap_free(struct msdosfsmount *pmp, u_
 {
 
 	pmp->pm_freeclustercount++;
-	pmp->pm_inusemap[cn / N_INUSEBITS] &= ~(1 << (cn % N_INUSEBITS));
+	pmp->pm_inusemap[cn / N_INUSEBITS] &= ~(1U << (cn % N_INUSEBITS));
 }
 
 int
@@ -741,7 +741,7 @@ chainlength(struct msdosfsmount *pmp, u_
 	idx = start / N_INUSEBITS;
 	start %= N_INUSEBITS;
 	map = pmp->pm_inusemap[idx];
-	map &= ~((1 << start) - 1);
+	map &= ~((1U << start) - 1);
 	if (map) {
 		len = ffs(map) - 1 - start;
 		return (len > count ? count : len);
@@ -837,7 +837,7 @@ clusteralloc(struct msdosfsmount *pmp, u
 	for (cn = newst; cn <= pmp->pm_maxcluster;) {
 		idx = cn / N_INUSEBITS;
 		map = pmp->pm_inusemap[idx];
-		map |= (1 << (cn % N_INUSEBITS)) - 1;
+		map |= (1U << (cn % N_INUSEBITS)) - 1;
 		if (map != (u_int)-1) {
 			cn = idx * N_INUSEBITS + ffs(map^(u_int)-1) - 1;
 			if ((l = chainlength(pmp, cn, count)) >= count)
@@ -854,7 +854,7 @@ clusteralloc(struct msdosfsmount *pmp, u
 	for (cn = 0; cn < newst;) {
 		idx = cn / N_INUSEBITS;
 		map = pmp->pm_inusemap[idx];
-		map |= (1 << (cn % N_INUSEBITS)) - 1;
+		map |= (1U << (cn % N_INUSEBITS)) - 1;
 		if (map != (u_int)-1) {
 			cn = idx * N_INUSEBITS + ffs(map^(u_int)-1) - 1;
 			if ((l = chainlength(pmp, cn, count)) >= count)



CVS commit: src/sys/fs/msdosfs

2018-01-26 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Sat Jan 27 03:54:01 UTC 2018

Modified Files:
src/sys/fs/msdosfs: msdosfs_fat.c

Log Message:
Need strings.h for ffs()
Resolves implict declaration warning of ffs() when building tools via build.sh


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/fs/msdosfs/msdosfs_fat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_fat.c
diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.31 src/sys/fs/msdosfs/msdosfs_fat.c:1.32
--- src/sys/fs/msdosfs/msdosfs_fat.c:1.31	Sat May  7 16:43:02 2016
+++ src/sys/fs/msdosfs/msdosfs_fat.c	Sat Jan 27 03:54:01 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_fat.c,v 1.31 2016/05/07 16:43:02 mlelstv Exp $	*/
+/*	$NetBSD: msdosfs_fat.c,v 1.32 2018/01/27 03:54:01 sevan Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -52,7 +52,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.31 2016/05/07 16:43:02 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.32 2018/01/27 03:54:01 sevan Exp $");
 
 /*
  * kernel include files.
@@ -69,6 +69,7 @@ __KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.
 #include 
 #include 		/* to define vattr structure */
 #else
+#include 
 #include 
 #endif
 



CVS commit: src/sys/fs/msdosfs

2017-11-27 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Nov 27 15:02:05 UTC 2017

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
relax sanity check. It's ok to have more FAT sectors than needed.


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.128 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.129
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.128	Sun Aug 20 11:48:15 2017
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Mon Nov 27 15:02:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.128 2017/08/20 11:48:15 mlelstv Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.129 2017/11/27 15:02:05 mlelstv Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.128 2017/08/20 11:48:15 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.129 2017/11/27 15:02:05 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -724,8 +724,8 @@ msdosfs_mountfs(struct vnode *devvp, str
 	fatbytes = (pmp->pm_maxcluster+1) * pmp->pm_fatmult / pmp->pm_fatdiv;
 	fatblocksecs = howmany(fatbytes, pmp->pm_BytesPerSec);
 
-	if (pmp->pm_FATsecs != fatblocksecs) {
-		DPRINTF("FATsecs %lu != real %lu\n", pmp->pm_FATsecs,
+	if (pmp->pm_FATsecs < fatblocksecs) {
+		DPRINTF("FATsecs %lu < real %lu\n", pmp->pm_FATsecs,
 			fatblocksecs);
 		error = EINVAL;
 		goto error_exit;



CVS commit: src/sys/fs/msdosfs

2017-08-20 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Aug 20 11:48:15 UTC 2017

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
Add more sanity checks for BPB parameters. Handle FAT12 format for media
with sectors >= 32kByte.

Does fix PR 52485.


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.127 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.128
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.127	Mon Apr 17 08:32:00 2017
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Sun Aug 20 11:48:15 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.127 2017/04/17 08:32:00 hannken Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.128 2017/08/20 11:48:15 mlelstv Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.127 2017/04/17 08:32:00 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.128 2017/08/20 11:48:15 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -467,6 +467,7 @@ msdosfs_mountfs(struct vnode *devvp, str
 	int	ronly, error, BlkPerSec;
 	uint64_t psize;
 	unsigned secsize;
+	u_long fatbytes, fatblocksecs;
 
 	/* Flush out any old buffers remaining from a previous use. */
 	if ((error = vinvalbuf(devvp, V_SAVE, l->l_cred, l, 0, 0)) != 0)
@@ -710,12 +711,40 @@ msdosfs_mountfs(struct vnode *devvp, str
 			pmp->pm_fatdiv = 1;
 		}
 	}
-	if (FAT12(pmp))
-		pmp->pm_fatblocksize = 3 * pmp->pm_BytesPerSec;
-	else
+
+	/* validate cluster count against FAT */
+	if ((pmp->pm_maxcluster & pmp->pm_fatmask) != pmp->pm_maxcluster) {
+		DPRINTF("maxcluster %lu outside of mask %#lx\n",
+			pmp->pm_maxcluster, pmp->pm_fatmask);
+		error = EINVAL;
+		goto error_exit;
+	}
+
+	/* validate FAT size */
+	fatbytes = (pmp->pm_maxcluster+1) * pmp->pm_fatmult / pmp->pm_fatdiv;
+	fatblocksecs = howmany(fatbytes, pmp->pm_BytesPerSec);
+
+	if (pmp->pm_FATsecs != fatblocksecs) {
+		DPRINTF("FATsecs %lu != real %lu\n", pmp->pm_FATsecs,
+			fatblocksecs);
+		error = EINVAL;
+		goto error_exit;
+	}
+
+	if (FAT12(pmp)) {
+		/*
+		 * limit block size to what is needed to read a FAT block
+		 * to not exceed MAXBSIZE
+		 */
+		pmp->pm_fatblocksec = min(3, fatblocksecs);
+		pmp->pm_fatblocksize = pmp->pm_fatblocksec
+			* pmp->pm_BytesPerSec;
+	} else {
 		pmp->pm_fatblocksize = MAXBSIZE;
+		pmp->pm_fatblocksec = pmp->pm_fatblocksize
+			/ pmp->pm_BytesPerSec;
+	}
 
-	pmp->pm_fatblocksec = pmp->pm_fatblocksize / pmp->pm_BytesPerSec;
 	pmp->pm_bnshift = ffs(pmp->pm_BytesPerSec) - 1;
 
 	/*



CVS commit: src/sys/fs/msdosfs

2017-03-01 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Mar  1 10:41:28 UTC 2017

Modified Files:
src/sys/fs/msdosfs: msdosfs_denode.c msdosfs_vfsops.c msdosfs_vnops.c

Log Message:
Remove now redundant calls to fstrans_start()/fstrans_done().


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/fs/msdosfs/msdosfs_denode.c
cvs rdiff -u -r1.123 -r1.124 src/sys/fs/msdosfs/msdosfs_vfsops.c
cvs rdiff -u -r1.96 -r1.97 src/sys/fs/msdosfs/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_denode.c
diff -u src/sys/fs/msdosfs/msdosfs_denode.c:1.52 src/sys/fs/msdosfs/msdosfs_denode.c:1.53
--- src/sys/fs/msdosfs/msdosfs_denode.c:1.52	Sat Aug 20 12:37:07 2016
+++ src/sys/fs/msdosfs/msdosfs_denode.c	Wed Mar  1 10:41:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_denode.c,v 1.52 2016/08/20 12:37:07 hannken Exp $	*/
+/*	$NetBSD: msdosfs_denode.c,v 1.53 2017/03/01 10:41:28 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,12 +48,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.52 2016/08/20 12:37:07 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.53 2017/03/01 10:41:28 hannken Exp $");
 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -537,10 +536,8 @@ msdosfs_reclaim(void *v)
 		struct vnode *a_vp;
 	} */ *ap = v;
 	struct vnode *vp = ap->a_vp;
-	struct mount *mp = vp->v_mount;
 	struct denode *dep = VTODE(vp);
 
-	fstrans_start(mp, FSTRANS_LAZY);
 #ifdef MSDOSFS_DEBUG
 	printf("msdosfs_reclaim(): dep %p, file %s, refcnt %ld\n",
 	dep, dep->de_Name, dep->de_refcnt);
@@ -566,7 +563,6 @@ msdosfs_reclaim(void *v)
 	vp->v_data = NULL;
 	mutex_exit(vp->v_interlock);
 	pool_put(_denode_pool, dep);
-	fstrans_done(mp);
 	return (0);
 }
 
@@ -578,7 +574,6 @@ msdosfs_inactive(void *v)
 		bool *a_recycle;
 	} */ *ap = v;
 	struct vnode *vp = ap->a_vp;
-	struct mount *mp = vp->v_mount;
 	struct denode *dep = VTODE(vp);
 	int error = 0;
 
@@ -586,7 +581,6 @@ msdosfs_inactive(void *v)
 	printf("msdosfs_inactive(): dep %p, de_Name[0] %x\n", dep, dep->de_Name[0]);
 #endif
 
-	fstrans_start(mp, FSTRANS_LAZY);
 	/*
 	 * Get rid of denodes related to stale file handles.
 	 */
@@ -623,7 +617,6 @@ out:
 #endif
 	*ap->a_recycle = (dep->de_Name[0] == SLOT_DELETED);
 	VOP_UNLOCK(vp);
-	fstrans_done(mp);
 	return (error);
 }
 

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.123 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.124
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.123	Wed Feb 22 09:50:13 2017
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Wed Mar  1 10:41:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.123 2017/02/22 09:50:13 hannken Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.124 2017/03/01 10:41:28 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.123 2017/02/22 09:50:13 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.124 2017/03/01 10:41:28 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -69,7 +69,6 @@ __KERNEL_RCSID(0, "$NetBSD: msdosfs_vfso
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -1002,7 +1001,6 @@ msdosfs_sync(struct mount *mp, int waitf
 			/* update FATs here */
 		}
 	}
-	fstrans_start(mp, FSTRANS_SHARED);
 	/*
 	 * Write back each (modified) denode.
 	 */
@@ -1031,7 +1029,6 @@ msdosfs_sync(struct mount *mp, int waitf
 	waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0)) != 0)
 		allerror = error;
 	VOP_UNLOCK(pmp->pm_devvp);
-	fstrans_done(mp);
 	return (allerror);
 }
 

Index: src/sys/fs/msdosfs/msdosfs_vnops.c
diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.96 src/sys/fs/msdosfs/msdosfs_vnops.c:1.97
--- src/sys/fs/msdosfs/msdosfs_vnops.c:1.96	Mon Feb  1 16:53:23 2016
+++ src/sys/fs/msdosfs/msdosfs_vnops.c	Wed Mar  1 10:41:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.96 2016/02/01 16:53:23 christos Exp $	*/
+/*	$NetBSD: msdosfs_vnops.c,v 1.97 2017/03/01 10:41:28 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.96 2016/02/01 16:53:23 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.97 2017/03/01 10:41:28 hannken Exp $");
 
 #include 
 #include 
@@ -60,7 +60,6 @@ __KERNEL_RCSID(0, "$NetBSD: msdosfs_vnop
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -120,7 +119,6 @@ msdosfs_create(void *v)
 	printf("msdosfs_create(cnp %p, vap %p\n", cnp, ap->a_vap);
 #endif
 
-	fstrans_start(ap->a_dvp->v_mount, FSTRANS_SHARED);
 	/*
 	 * If this is the root directory and there is no space left we
 	 * can't do anything.  This is because the root directory can not
@@ 

CVS commit: src/sys/fs/msdosfs

2017-02-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Feb 17 08:27:20 UTC 2017

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
Take vnode lock for VOP_FSYNC().


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.119 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.120
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.119	Wed Dec 14 15:48:54 2016
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Fri Feb 17 08:27:20 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.119 2016/12/14 15:48:54 hannken Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.120 2017/02/17 08:27:20 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.119 2016/12/14 15:48:54 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.120 2017/02/17 08:27:20 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -1032,9 +1032,11 @@ msdosfs_sync(struct mount *mp, int waitf
 	/*
 	 * Force stale file system control information to be flushed.
 	 */
+	vn_lock(pmp->pm_devvp, LK_EXCLUSIVE | LK_RETRY);
 	if ((error = VOP_FSYNC(pmp->pm_devvp, cred,
 	waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0)) != 0)
 		allerror = error;
+	VOP_UNLOCK(pmp->pm_devvp);
 	fstrans_done(mp);
 	return (allerror);
 }



CVS commit: src/sys/fs/msdosfs

2017-01-14 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Jan 14 17:17:53 UTC 2017

Modified Files:
src/sys/fs/msdosfs: denode.h

Log Message:
Be explicit about how we're placing part of the on-disk name into
the extension, so it doesn't appear like we are overrunning an array.
Appeases coverity, NFC.

ok riastradh


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/fs/msdosfs/denode.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/denode.h
diff -u src/sys/fs/msdosfs/denode.h:1.24 src/sys/fs/msdosfs/denode.h:1.25
--- src/sys/fs/msdosfs/denode.h:1.24	Tue Jul  8 09:21:52 2014
+++ src/sys/fs/msdosfs/denode.h	Sat Jan 14 17:17:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: denode.h,v 1.24 2014/07/08 09:21:52 hannken Exp $	*/
+/*	$NetBSD: denode.h,v 1.25 2017/01/14 17:17:53 maya Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -212,7 +212,8 @@ struct denode {
 #define DE_INTERNALIZE32(dep, dp)			\
 	 ((dep)->de_StartCluster |= getushort((dp)->deHighClust) << 16)
 #define DE_INTERNALIZE(dep, dp)\
-	(memcpy((dep)->de_Name, (dp)->deName, 11),	\
+	(memcpy((dep)->de_Name, (dp)->deName, 8),	\
+	 memcpy((dep)->de_Name+8, (dp)->deExtension, 3),\
 	 (dep)->de_Attributes = (dp)->deAttributes,	\
 	 (dep)->de_CHun = (dp)->deCHundredth,		\
 	 (dep)->de_CTime = getushort((dp)->deCTime),	\
@@ -229,7 +230,8 @@ struct denode {
 #define DE_EXTERNALIZE16(dp, dep)			\
 	 putushort((dp)->deHighClust, 0)
 #define DE_EXTERNALIZE(dp, dep)\
-	(memcpy((dp)->deName, (dep)->de_Name, 11),	\
+	(memcpy((dp)->deName, (dep)->de_Name, 8),	\
+	 memcpy((dp)->deExtension, (dep)->de_Name+8, 3),\
 	 (dp)->deAttributes = (dep)->de_Attributes,	\
 	 (dp)->deCHundredth = (dep)->de_CHun,		\
 	 putushort((dp)->deCTime, (dep)->de_CTime),	\



CVS commit: src/sys/fs/msdosfs

2016-06-30 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Jun 30 09:34:01 UTC 2016

Modified Files:
src/sys/fs/msdosfs: msdosfs_conv.c

Log Message:
Fix false positives when comparing long file names that have the
same first 13 (or some multiple thereof) characters.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/fs/msdosfs/msdosfs_conv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_conv.c
diff -u src/sys/fs/msdosfs/msdosfs_conv.c:1.16 src/sys/fs/msdosfs/msdosfs_conv.c:1.17
--- src/sys/fs/msdosfs/msdosfs_conv.c:1.16	Sun Mar  6 07:33:25 2016
+++ src/sys/fs/msdosfs/msdosfs_conv.c	Thu Jun 30 09:34:01 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_conv.c,v 1.16 2016/03/06 07:33:25 mlelstv Exp $	*/
+/*	$NetBSD: msdosfs_conv.c,v 1.17 2016/06/30 09:34:01 nonaka Exp $	*/
 
 /*-
  * Copyright (C) 1995, 1997 Wolfgang Solfrank.
@@ -58,7 +58,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.16 2016/03/06 07:33:25 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.17 2016/06/30 09:34:01 nonaka Exp $");
 
 /*
  * System include files.
@@ -621,6 +621,8 @@ winChkName(const u_char *un, int unlen, 
 
 	if (i >= len + 1)
 		return -1;
+	if ((wep->weCnt & WIN_LAST) && (len - i > WIN_CHARS))
+		return -1;
 
 	/*
 	 * Fetch name segment from directory entry



CVS commit: src/sys/fs/msdosfs

2016-05-07 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  7 16:43:02 UTC 2016

Modified Files:
src/sys/fs/msdosfs: msdosfs_fat.c

Log Message:
fix DEBUG build


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/fs/msdosfs/msdosfs_fat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_fat.c
diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.30 src/sys/fs/msdosfs/msdosfs_fat.c:1.31
--- src/sys/fs/msdosfs/msdosfs_fat.c:1.30	Tue May  3 18:17:28 2016
+++ src/sys/fs/msdosfs/msdosfs_fat.c	Sat May  7 16:43:02 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_fat.c,v 1.30 2016/05/03 18:17:28 mlelstv Exp $	*/
+/*	$NetBSD: msdosfs_fat.c,v 1.31 2016/05/07 16:43:02 mlelstv Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -52,7 +52,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.30 2016/05/03 18:17:28 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.31 2016/05/07 16:43:02 mlelstv Exp $");
 
 /*
  * kernel include files.
@@ -279,7 +279,7 @@ pcbmap(struct denode *dep, u_long findcn
 		 */
 		if (cn < CLUST_FIRST || cn > pmp->pm_maxcluster) {
 			DPRINTF(("%s(cn, %lu not in %lu..%lu)\n", __func__,
-cn, CLUST_FIRST, pmp->pm_maxcluster));
+cn, (u_long)CLUST_FIRST, pmp->pm_maxcluster));
 			if (bp)
 brelse(bp, 0);
 			return (EINVAL);



CVS commit: src/sys/fs/msdosfs

2016-05-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue May  3 18:17:29 UTC 2016

Modified Files:
src/sys/fs/msdosfs: msdosfs_fat.c

Log Message:
Validate FAT entries to avoid some panics caused by a corrupted FAT.

Also print FAT write errors when mount is synchronous (-o sync). This
reveals problems caused by a write protected disklabel on sector 1.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/fs/msdosfs/msdosfs_fat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_fat.c
diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.29 src/sys/fs/msdosfs/msdosfs_fat.c:1.30
--- src/sys/fs/msdosfs/msdosfs_fat.c:1.29	Sat Mar 28 19:24:05 2015
+++ src/sys/fs/msdosfs/msdosfs_fat.c	Tue May  3 18:17:28 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_fat.c,v 1.29 2015/03/28 19:24:05 maxv Exp $	*/
+/*	$NetBSD: msdosfs_fat.c,v 1.30 2016/05/03 18:17:28 mlelstv Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -52,7 +52,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.29 2015/03/28 19:24:05 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.30 2016/05/03 18:17:28 mlelstv Exp $");
 
 /*
  * kernel include files.
@@ -273,6 +273,18 @@ pcbmap(struct denode *dep, u_long findcn
 		 */
 		if (cn >= (CLUST_RSRVD & pmp->pm_fatmask))
 			goto hiteof;
+
+		/*
+		 * Also stop when cluster is not in the filesystem
+		 */
+		if (cn < CLUST_FIRST || cn > pmp->pm_maxcluster) {
+			DPRINTF(("%s(cn, %lu not in %lu..%lu)\n", __func__,
+cn, CLUST_FIRST, pmp->pm_maxcluster));
+			if (bp)
+brelse(bp, 0);
+			return (EINVAL);
+		}
+
 		byteoffset = FATOFS(pmp, cn);
 		fatblock(pmp, byteoffset, , , );
 		if (bn != bp_bn) {
@@ -383,7 +395,7 @@ fc_purge(struct denode *dep, u_int frcn)
 void
 updatefats(struct msdosfsmount *pmp, struct buf *bp, u_long fatbn)
 {
-	int i;
+	int i, error;
 	struct buf *bpn;
 
 	DPRINTF(("%s(pmp %p, bp %p, fatbn %lu)\n", __func__, pmp, bp, fatbn));
@@ -448,9 +460,12 @@ updatefats(struct msdosfsmount *pmp, str
 			bpn = getblk(pmp->pm_devvp, de_bn2kb(pmp, fatbn),
 			bp->b_bcount, 0, 0);
 			memcpy(bpn->b_data, bp->b_data, bp->b_bcount);
-			if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT)
-bwrite(bpn);
-			else
+			if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT) {
+error = bwrite(bpn);
+if (error)
+	printf("%s: copy FAT %d (error=%d)\n",
+		 __func__, i, error);
+			} else
 bdwrite(bpn);
 		}
 	}
@@ -458,9 +473,12 @@ updatefats(struct msdosfsmount *pmp, str
 	/*
 	 * Write out the first (or current) FAT last.
 	 */
-	if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT)
-		bwrite(bp);
-	else
+	if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT) {
+		error =  bwrite(bp);
+		if (error)
+			printf("%s: write FAT (error=%d)\n",
+__func__, error);
+	} else
 		bdwrite(bp);
 	/*
 	 * Maybe update fsinfo sector here?



CVS commit: src/sys/fs/msdosfs

2016-03-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Mar  6 07:33:25 UTC 2016

Modified Files:
src/sys/fs/msdosfs: msdosfs_conv.c

Log Message:
Use KASSERT for conditions that cannot be met with current parameters.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/fs/msdosfs/msdosfs_conv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_conv.c
diff -u src/sys/fs/msdosfs/msdosfs_conv.c:1.15 src/sys/fs/msdosfs/msdosfs_conv.c:1.16
--- src/sys/fs/msdosfs/msdosfs_conv.c:1.15	Sat Feb  6 10:40:58 2016
+++ src/sys/fs/msdosfs/msdosfs_conv.c	Sun Mar  6 07:33:25 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_conv.c,v 1.15 2016/02/06 10:40:58 mlelstv Exp $	*/
+/*	$NetBSD: msdosfs_conv.c,v 1.16 2016/03/06 07:33:25 mlelstv Exp $	*/
 
 /*-
  * Copyright (C) 1995, 1997 Wolfgang Solfrank.
@@ -52,8 +52,13 @@
 #include "nbtool_config.h"
 #endif
 
+#ifndef _KERNEL
+#include 
+#define KASSERT(x) assert(x)
+#endif
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.15 2016/02/06 10:40:58 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.16 2016/03/06 07:33:25 mlelstv Exp $");
 
 /*
  * System include files.
@@ -685,8 +690,8 @@ win2unixfn(struct winentry *wep, struct 
 	len = utf8 ? ucs2utf8str(wn, WIN_CHARS, buf, sizeof(buf))
 	: ucs2char8str(wn, WIN_CHARS, buf, sizeof(buf));
 
-	if ((size_t)len > sizeof(dp->d_name) - 1)
-		return -1;
+	KASSERT(len >= 0);
+	KASSERT((size_t)len <= MIN(sizeof(buf), sizeof(dp->d_name)-1));
 
 	/*
 	 * Prepend name segment to directory entry
@@ -702,6 +707,9 @@ win2unixfn(struct winentry *wep, struct 
 	*namlen += len;
 	if (*namlen > sizeof(dp->d_name) - 1)
 		*namlen = sizeof(dp->d_name) - 1;
+
+	KASSERT(*namlen >= len);
+
 	memmove(>d_name[len], >d_name[0], *namlen - len);
 	memcpy(dp->d_name, buf, len);
 



CVS commit: src/sys/fs/msdosfs

2016-02-06 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sat Feb  6 14:11:58 UTC 2016

Modified Files:
src/sys/fs/msdosfs: msdosfs_unicode.c

Log Message:
Toolify.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/fs/msdosfs/msdosfs_unicode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_unicode.c
diff -u src/sys/fs/msdosfs/msdosfs_unicode.c:1.1 src/sys/fs/msdosfs/msdosfs_unicode.c:1.2
--- src/sys/fs/msdosfs/msdosfs_unicode.c:1.1	Sat Feb  6 10:40:58 2016
+++ src/sys/fs/msdosfs/msdosfs_unicode.c	Sat Feb  6 14:11:58 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_unicode.c,v 1.1 2016/02/06 10:40:58 mlelstv Exp $	*/
+/*	$NetBSD: msdosfs_unicode.c,v 1.2 2016/02/06 14:11:58 joerg Exp $	*/
 
 /*
  * Unicode 5.0 case folding derived from
@@ -52,6 +52,10 @@
  * 
  */
 
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
 #include 
 #include 
 



CVS commit: src/sys/fs/msdosfs

2016-02-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Feb  1 10:37:57 UTC 2016

Modified Files:
src/sys/fs/msdosfs: msdosfs_conv.c

Log Message:
Avoid unsigned/signed comparision warning to fix the build.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/fs/msdosfs/msdosfs_conv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_conv.c
diff -u src/sys/fs/msdosfs/msdosfs_conv.c:1.12 src/sys/fs/msdosfs/msdosfs_conv.c:1.13
--- src/sys/fs/msdosfs/msdosfs_conv.c:1.12	Mon Feb  1 02:59:33 2016
+++ src/sys/fs/msdosfs/msdosfs_conv.c	Mon Feb  1 10:37:57 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_conv.c,v 1.12 2016/02/01 02:59:33 christos Exp $	*/
+/*	$NetBSD: msdosfs_conv.c,v 1.13 2016/02/01 10:37:57 martin Exp $	*/
 
 /*-
  * Copyright (C) 1995, 1997 Wolfgang Solfrank.
@@ -62,7 +62,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.12 2016/02/01 02:59:33 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.13 2016/02/01 10:37:57 martin Exp $");
 
 /*
  * System include files.
@@ -1592,7 +1592,7 @@ win2unixfn(struct winentry *wep, struct 
 	 */
 	len = utf8 ? ucs2utf8str(wn, WIN_CHARS, buf, sizeof(buf)) : ucs2char8str(wn, WIN_CHARS, buf, sizeof(buf));
 
-	if (len > sizeof(dp->d_name) - 1)
+	if (len < 0 || (size_t)len > sizeof(dp->d_name) - 1)
 		return -1;
 
 	/*



CVS commit: src/sys/fs/msdosfs

2016-02-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Feb  1 16:53:24 UTC 2016

Modified Files:
src/sys/fs/msdosfs: msdosfs_conv.c msdosfs_vnops.c

Log Message:
- split a long line.
- remove extra test.
- move d_namlen setting to msdosfs_vnops.c to avoid the ifdef.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/fs/msdosfs/msdosfs_conv.c
cvs rdiff -u -r1.95 -r1.96 src/sys/fs/msdosfs/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_conv.c
diff -u src/sys/fs/msdosfs/msdosfs_conv.c:1.13 src/sys/fs/msdosfs/msdosfs_conv.c:1.14
--- src/sys/fs/msdosfs/msdosfs_conv.c:1.13	Mon Feb  1 05:37:57 2016
+++ src/sys/fs/msdosfs/msdosfs_conv.c	Mon Feb  1 11:53:23 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_conv.c,v 1.13 2016/02/01 10:37:57 martin Exp $	*/
+/*	$NetBSD: msdosfs_conv.c,v 1.14 2016/02/01 16:53:23 christos Exp $	*/
 
 /*-
  * Copyright (C) 1995, 1997 Wolfgang Solfrank.
@@ -62,7 +62,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.13 2016/02/01 10:37:57 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.14 2016/02/01 16:53:23 christos Exp $");
 
 /*
  * System include files.
@@ -1590,9 +1590,10 @@ win2unixfn(struct winentry *wep, struct 
 	/*
 	 * Translate ucs-2 to UNIX name
 	 */
-	len = utf8 ? ucs2utf8str(wn, WIN_CHARS, buf, sizeof(buf)) : ucs2char8str(wn, WIN_CHARS, buf, sizeof(buf));
+	len = utf8 ? ucs2utf8str(wn, WIN_CHARS, buf, sizeof(buf))
+	: ucs2char8str(wn, WIN_CHARS, buf, sizeof(buf));
 
-	if (len < 0 || (size_t)len > sizeof(dp->d_name) - 1)
+	if ((size_t)len > sizeof(dp->d_name) - 1)
 		return -1;
 
 	/*
@@ -1612,10 +1613,6 @@ win2unixfn(struct winentry *wep, struct 
 	memmove(>d_name[len], >d_name[0], *namlen - len);
 	memcpy(dp->d_name, buf, len);
 
-#ifdef __NetBSD__
-	dp->d_namlen = *namlen;
-#endif
-
 	return chksum;
 }
 

Index: src/sys/fs/msdosfs/msdosfs_vnops.c
diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.95 src/sys/fs/msdosfs/msdosfs_vnops.c:1.96
--- src/sys/fs/msdosfs/msdosfs_vnops.c:1.95	Sun Jan 31 21:59:33 2016
+++ src/sys/fs/msdosfs/msdosfs_vnops.c	Mon Feb  1 11:53:23 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.95 2016/02/01 02:59:33 christos Exp $	*/
+/*	$NetBSD: msdosfs_vnops.c,v 1.96 2016/02/01 16:53:23 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.95 2016/02/01 02:59:33 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.96 2016/02/01 16:53:23 christos Exp $");
 
 #include 
 #include 
@@ -1544,6 +1544,8 @@ msdosfs_readdir(void *v)
 chksum = win2unixfn((struct winentry *)dentp,
 dirbuf, chksum, ,
 pmp->pm_flags & MSDOSFSMNT_UTF8);
+if (chksum != -1)
+	dirbuf->d_namlen = namlen;
 continue;
 			}
 



CVS commit: src/sys/fs/msdosfs

2016-01-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Feb  1 02:59:33 UTC 2016

Modified Files:
src/sys/fs/msdosfs: direntry.h msdosfs_conv.c msdosfs_vnops.c

Log Message:
We can't depend on dp->d_namlen existing for the parts that are used in
makefs(8).


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/fs/msdosfs/direntry.h
cvs rdiff -u -r1.11 -r1.12 src/sys/fs/msdosfs/msdosfs_conv.c
cvs rdiff -u -r1.94 -r1.95 src/sys/fs/msdosfs/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/direntry.h
diff -u src/sys/fs/msdosfs/direntry.h:1.10 src/sys/fs/msdosfs/direntry.h:1.11
--- src/sys/fs/msdosfs/direntry.h:1.10	Sat Jan 30 04:59:27 2016
+++ src/sys/fs/msdosfs/direntry.h	Sun Jan 31 21:59:33 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: direntry.h,v 1.10 2016/01/30 09:59:27 mlelstv Exp $	*/
+/*	$NetBSD: direntry.h,v 1.11 2016/02/01 02:59:33 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -140,7 +140,7 @@ int	unix2winfn(const unsigned char *un, 
 int	winChkName(const unsigned char *un, int unlen, struct winentry *wep,
 	int chksum, int utf8);
 int	win2unixfn(struct winentry *wep, struct dirent *dp, int chksum,	
-	int utf8);
+	uint16_t *namlen, int utf8);
 uint8_t winChksum(uint8_t *name);
 int	winSlotCnt(const unsigned char *un, int unlen, int utf8);
 #endif /* _KERNEL || MAKEFS */

Index: src/sys/fs/msdosfs/msdosfs_conv.c
diff -u src/sys/fs/msdosfs/msdosfs_conv.c:1.11 src/sys/fs/msdosfs/msdosfs_conv.c:1.12
--- src/sys/fs/msdosfs/msdosfs_conv.c:1.11	Sat Jan 30 04:59:27 2016
+++ src/sys/fs/msdosfs/msdosfs_conv.c	Sun Jan 31 21:59:33 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_conv.c,v 1.11 2016/01/30 09:59:27 mlelstv Exp $	*/
+/*	$NetBSD: msdosfs_conv.c,v 1.12 2016/02/01 02:59:33 christos Exp $	*/
 
 /*-
  * Copyright (C) 1995, 1997 Wolfgang Solfrank.
@@ -62,7 +62,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.11 2016/01/30 09:59:27 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.12 2016/02/01 02:59:33 christos Exp $");
 
 /*
  * System include files.
@@ -1549,7 +1549,8 @@ winChkName(const u_char *un, int unlen, 
  * Returns the checksum or -1 if impossible
  */
 int
-win2unixfn(struct winentry *wep, struct dirent *dp, int chksum, int utf8)
+win2unixfn(struct winentry *wep, struct dirent *dp, int chksum,
+uint16_t *namlen, int utf8)
 {
 	u_int16_t wn[WIN_CHARS], *p;
 	u_int8_t buf[WIN_CHARS*3];
@@ -1564,7 +1565,7 @@ win2unixfn(struct winentry *wep, struct 
 	 */
 	if (wep->weCnt & WIN_LAST) {
 		chksum = wep->weChksum;
-		dp->d_namlen = 0;
+		*namlen = 0;
 	} else if (chksum != wep->weChksum)
 		chksum = -1;
 	if (chksum == -1)
@@ -1591,6 +1592,9 @@ win2unixfn(struct winentry *wep, struct 
 	 */
 	len = utf8 ? ucs2utf8str(wn, WIN_CHARS, buf, sizeof(buf)) : ucs2char8str(wn, WIN_CHARS, buf, sizeof(buf));
 
+	if (len > sizeof(dp->d_name) - 1)
+		return -1;
+
 	/*
 	 * Prepend name segment to directory entry
 	 *
@@ -1602,12 +1606,16 @@ win2unixfn(struct winentry *wep, struct 
 	 * are silently discarded. This could also end in multiple
 	 * files using the same (truncated) name.
 	 */
-	dp->d_namlen += len;
-	if (dp->d_namlen > sizeof(dp->d_name)-1)
-		dp->d_namlen = sizeof(dp->d_name)-1;
-	memmove(>d_name[len], >d_name[0], dp->d_namlen - len);
+	*namlen += len;
+	if (*namlen > sizeof(dp->d_name) - 1)
+		*namlen = sizeof(dp->d_name) - 1;
+	memmove(>d_name[len], >d_name[0], *namlen - len);
 	memcpy(dp->d_name, buf, len);
 
+#ifdef __NetBSD__
+	dp->d_namlen = *namlen;
+#endif
+
 	return chksum;
 }
 

Index: src/sys/fs/msdosfs/msdosfs_vnops.c
diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.94 src/sys/fs/msdosfs/msdosfs_vnops.c:1.95
--- src/sys/fs/msdosfs/msdosfs_vnops.c:1.94	Sat Jan 30 04:59:27 2016
+++ src/sys/fs/msdosfs/msdosfs_vnops.c	Sun Jan 31 21:59:33 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.94 2016/01/30 09:59:27 mlelstv Exp $	*/
+/*	$NetBSD: msdosfs_vnops.c,v 1.95 2016/02/01 02:59:33 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.94 2016/01/30 09:59:27 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.95 2016/02/01 02:59:33 christos Exp $");
 
 #include 
 #include 
@@ -1394,6 +1394,7 @@ msdosfs_readdir(void *v)
 	int ncookies = 0, nc = 0;
 	off_t offset, uio_off;
 	int chksum = -1;
+	uint16_t namlen;
 
 #ifdef MSDOSFS_DEBUG
 	printf("msdosfs_readdir(): vp %p, uio %p, cred %p, eofflagp %p\n",
@@ -1541,7 +1542,8 @@ msdosfs_readdir(void *v)
 if (pmp->pm_flags & MSDOSFSMNT_SHORTNAME)
 	continue;
 chksum = win2unixfn((struct winentry *)dentp,
-dirbuf, chksum, pmp->pm_flags & MSDOSFSMNT_UTF8);
+dirbuf, chksum, ,
+pmp->pm_flags & MSDOSFSMNT_UTF8);
 continue;
 			}
 
@@ -1584,6 +1586,7 @@ 

CVS commit: src/sys/fs/msdosfs

2016-01-22 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Jan 22 22:53:36 UTC 2016

Modified Files:
src/sys/fs/msdosfs: bpb.h direntry.h

Log Message:
u_int{8,16,32}_t -> uint{8,16,32}_t, also u_int -> unsigned and
u_char -> unsigned char.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/fs/msdosfs/bpb.h \
src/sys/fs/msdosfs/direntry.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/bpb.h
diff -u src/sys/fs/msdosfs/bpb.h:1.7 src/sys/fs/msdosfs/bpb.h:1.8
--- src/sys/fs/msdosfs/bpb.h:1.7	Sun Nov  4 17:57:59 2012
+++ src/sys/fs/msdosfs/bpb.h	Fri Jan 22 22:53:36 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpb.h,v 1.7 2012/11/04 17:57:59 jakllsch Exp $	*/
+/*	$NetBSD: bpb.h,v 1.8 2016/01/22 22:53:36 dholland Exp $	*/
 
 /*
  * Written by Paul Popelka (pa...@uts.amdahl.com)
@@ -23,17 +23,17 @@
  * BIOS Parameter Block (BPB) for DOS 3.3
  */
 struct bpb33 {
-	u_int16_t	bpbBytesPerSec;	/* bytes per sector */
-	u_int8_t	bpbSecPerClust;	/* sectors per cluster */
-	u_int16_t	bpbResSectors;	/* number of reserved sectors */
-	u_int8_t	bpbFATs;	/* number of FATs */
-	u_int16_t	bpbRootDirEnts;	/* number of root directory entries */
-	u_int16_t	bpbSectors;	/* total number of sectors */
-	u_int8_t	bpbMedia;	/* media descriptor */
-	u_int16_t	bpbFATsecs;	/* number of sectors per FAT */
-	u_int16_t	bpbSecPerTrack;	/* sectors per track */
-	u_int16_t	bpbHeads;	/* number of heads */
-	u_int16_t	bpbHiddenSecs;	/* number of hidden sectors */
+	uint16_t	bpbBytesPerSec;	/* bytes per sector */
+	uint8_t		bpbSecPerClust;	/* sectors per cluster */
+	uint16_t	bpbResSectors;	/* number of reserved sectors */
+	uint8_t		bpbFATs;	/* number of FATs */
+	uint16_t	bpbRootDirEnts;	/* number of root directory entries */
+	uint16_t	bpbSectors;	/* total number of sectors */
+	uint8_t		bpbMedia;	/* media descriptor */
+	uint16_t	bpbFATsecs;	/* number of sectors per FAT */
+	uint16_t	bpbSecPerTrack;	/* sectors per track */
+	uint16_t	bpbHeads;	/* number of heads */
+	uint16_t	bpbHiddenSecs;	/* number of hidden sectors */
 };
 
 /*
@@ -41,46 +41,46 @@ struct bpb33 {
  * and bpbHugeSectors is not in the 3.3 bpb.
  */
 struct bpb50 {
-	u_int16_t	bpbBytesPerSec;	/* bytes per sector */
-	u_int8_t	bpbSecPerClust;	/* sectors per cluster */
-	u_int16_t	bpbResSectors;	/* number of reserved sectors */
-	u_int8_t	bpbFATs;	/* number of FATs */
-	u_int16_t	bpbRootDirEnts;	/* number of root directory entries */
-	u_int16_t	bpbSectors;	/* total number of sectors */
-	u_int8_t	bpbMedia;	/* media descriptor */
-	u_int16_t	bpbFATsecs;	/* number of sectors per FAT */
-	u_int16_t	bpbSecPerTrack;	/* sectors per track */
-	u_int16_t	bpbHeads;	/* number of heads */
-	u_int32_t	bpbHiddenSecs;	/* # of hidden sectors */
-	u_int32_t	bpbHugeSectors;	/* # of sectors if bpbSectors == 0 */
+	uint16_t	bpbBytesPerSec;	/* bytes per sector */
+	uint8_t		bpbSecPerClust;	/* sectors per cluster */
+	uint16_t	bpbResSectors;	/* number of reserved sectors */
+	uint8_t		bpbFATs;	/* number of FATs */
+	uint16_t	bpbRootDirEnts;	/* number of root directory entries */
+	uint16_t	bpbSectors;	/* total number of sectors */
+	uint8_t		bpbMedia;	/* media descriptor */
+	uint16_t	bpbFATsecs;	/* number of sectors per FAT */
+	uint16_t	bpbSecPerTrack;	/* sectors per track */
+	uint16_t	bpbHeads;	/* number of heads */
+	uint32_t	bpbHiddenSecs;	/* # of hidden sectors */
+	uint32_t	bpbHugeSectors;	/* # of sectors if bpbSectors == 0 */
 };
 
 /*
  * BPB for DOS 7.10 (FAT32).  This one has a few extensions to bpb50.
  */
 struct bpb710 {
-	u_int16_t	bpbBytesPerSec;	/* bytes per sector */
-	u_int8_t	bpbSecPerClust;	/* sectors per cluster */
-	u_int16_t	bpbResSectors;	/* number of reserved sectors */
-	u_int8_t	bpbFATs;	/* number of FATs */
-	u_int16_t	bpbRootDirEnts;	/* number of root directory entries */
-	u_int16_t	bpbSectors;	/* total number of sectors */
-	u_int8_t	bpbMedia;	/* media descriptor */
-	u_int16_t	bpbFATsecs;	/* number of sectors per FAT */
-	u_int16_t	bpbSecPerTrack;	/* sectors per track */
-	u_int16_t	bpbHeads;	/* number of heads */
-	u_int32_t	bpbHiddenSecs;	/* # of hidden sectors */
-	u_int32_t	bpbHugeSectors;	/* # of sectors if bpbSectors == 0 */
-	u_int32_t	bpbBigFATsecs;	/* like bpbFATsecs for FAT32 */
-	u_int16_t	bpbExtFlags;	/* extended flags: */
+	uint16_t	bpbBytesPerSec;	/* bytes per sector */
+	uint8_t		bpbSecPerClust;	/* sectors per cluster */
+	uint16_t	bpbResSectors;	/* number of reserved sectors */
+	uint8_t		bpbFATs;	/* number of FATs */
+	uint16_t	bpbRootDirEnts;	/* number of root directory entries */
+	uint16_t	bpbSectors;	/* total number of sectors */
+	uint8_t		bpbMedia;	/* media descriptor */
+	uint16_t	bpbFATsecs;	/* number of sectors per FAT */
+	uint16_t	bpbSecPerTrack;	/* sectors per track */
+	uint16_t	bpbHeads;	/* number of heads */
+	uint32_t	bpbHiddenSecs;	/* # of hidden sectors */
+	uint32_t	bpbHugeSectors;	/* # of sectors 

CVS commit: src/sys/fs/msdosfs

2016-01-22 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Jan 22 22:48:18 UTC 2016

Modified Files:
src/sys/fs/msdosfs: bootsect.h

Log Message:
u_int8_t -> uint8_t


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/fs/msdosfs/bootsect.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/bootsect.h
diff -u src/sys/fs/msdosfs/bootsect.h:1.5 src/sys/fs/msdosfs/bootsect.h:1.6
--- src/sys/fs/msdosfs/bootsect.h:1.5	Sun Nov  4 17:57:59 2012
+++ src/sys/fs/msdosfs/bootsect.h	Fri Jan 22 22:48:18 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootsect.h,v 1.5 2012/11/04 17:57:59 jakllsch Exp $	*/
+/*	$NetBSD: bootsect.h,v 1.6 2016/01/22 22:48:18 dholland Exp $	*/
 
 /*
  * Written by Paul Popelka (pa...@uts.amdahl.com)
@@ -24,13 +24,13 @@
  * first sector of a partitioned hard disk.
  */
 struct bootsector33 {
-	u_int8_t	bsJump[3];		/* jump inst E9 or EBxx90 */
+	uint8_t		bsJump[3];		/* jump inst E9 or EBxx90 */
 	int8_t		bsOemName[8];		/* OEM name and version */
 	int8_t		bsBPB[19];		/* BIOS parameter block */
 	int8_t		bsDriveNumber;		/* drive number (0x80) */
 	int8_t		bsBootCode[479];	/* pad so struct is 512b */
-	u_int8_t	bsBootSectSig0;
-	u_int8_t	bsBootSectSig1;
+	uint8_t		bsBootSectSig0;
+	uint8_t		bsBootSectSig1;
 #define	BOOTSIG0	0x55
 #define	BOOTSIG1	0xaa
 };
@@ -46,25 +46,25 @@ struct extboot {
 };
 
 struct bootsector50 {
-	u_int8_t	bsJump[3];		/* jump inst E9 or EBxx90 */
+	uint8_t		bsJump[3];		/* jump inst E9 or EBxx90 */
 	int8_t		bsOemName[8];		/* OEM name and version */
 	int8_t		bsBPB[25];		/* BIOS parameter block */
 	int8_t		bsExt[26];		/* Bootsector Extension */
 	int8_t		bsBootCode[448];	/* pad so structure is 512b */
-	u_int8_t	bsBootSectSig0;
-	u_int8_t	bsBootSectSig1;
+	uint8_t		bsBootSectSig0;
+	uint8_t		bsBootSectSig1;
 #define	BOOTSIG0	0x55
 #define	BOOTSIG1	0xaa
 };
 
 struct bootsector710 {
-	u_int8_t	bsJump[3];		/* jump inst E9 or EBxx90 */
+	uint8_t		bsJump[3];		/* jump inst E9 or EBxx90 */
 	int8_t		bsOEMName[8];		/* OEM name and version */
 	int8_t		bsBPB[53];		/* BIOS parameter block */
 	int8_t		bsExt[26];		/* Bootsector Extension */
 	int8_t		bsBootCode[420];	/* pad so structure is 512b */
-	u_int8_t	bsBootSectSig0;
-	u_int8_t	bsBootSectSig1;
+	uint8_t		bsBootSectSig0;
+	uint8_t		bsBootSectSig1;
 #define	BOOTSIG0	0x55
 #define	BOOTSIG1	0xaa
 };
@@ -76,7 +76,7 @@ struct bootsector710 {
  */
 #if 0
 struct bootsec_atari {
-	u_int8_t	bsBranch[2];		/* branch inst if auto-boot	*/
+	uint8_t		bsBranch[2];		/* branch inst if auto-boot	*/
 	int8_t		bsFiller[6];		/* anything or nothing		*/
 	int8_t		bsSerial[3];		/* serial no. for mediachange	*/
 	int8_t		bsBPB[19];		/* BIOS parameter block		*/



CVS commit: src/sys/fs/msdosfs

2015-01-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 23 02:39:48 UTC 2015

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
add some more paranoid checks about secsize and struct use.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.115 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.116
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.115	Fri Jul 18 13:24:34 2014
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Thu Jan 22 21:39:48 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.115 2014/07/18 17:24:34 maxv Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.116 2015/01/23 02:39:48 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.115 2014/07/18 17:24:34 maxv Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.116 2015/01/23 02:39:48 christos Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -510,6 +510,11 @@ msdosfs_mountfs(struct vnode *devvp, str
 	 * Read the boot sector of the filesystem, and then check the
 	 * boot signature.  If not a dos boot sector then error out.
 	 */
+	if (secsize  sizeof(*b50)) {
+		DPRINTF((50 bootsec %u\n, secsize));
+		error = EINVAL;
+		goto error_exit;
+	}
 	if ((error = bread(devvp, 0, secsize, NOCRED, 0, bp)) != 0)
 		goto error_exit;
 	bsp = (union bootsector *)bp-b_data;
@@ -551,6 +556,11 @@ msdosfs_mountfs(struct vnode *devvp, str
 		pmp-pm_HiddenSects = getulong(b50-bpbHiddenSecs);
 		pmp-pm_HugeSectors = getulong(b50-bpbHugeSectors);
 	} else {
+		if (secsize  sizeof(*b33)) {
+			DPRINTF((33 bootsec %u\n, secsize));
+			error = EINVAL;
+			goto error_exit;
+		}
 		pmp-pm_HiddenSects = getushort(b33-bpbHiddenSecs);
 		pmp-pm_HugeSectors = pmp-pm_Sectors;
 	}
@@ -579,6 +589,11 @@ msdosfs_mountfs(struct vnode *devvp, str
 	}
 
 	if (pmp-pm_RootDirEnts == 0) {
+		if (secsize  sizeof(*b710)) {
+			DPRINTF((710 bootsec %u\n, secsize));
+			error = EINVAL;
+			goto error_exit;
+		}
 		unsigned short FSVers = getushort(b710-bpbFSVers);
 		unsigned short ExtFlags = getushort(b710-bpbExtFlags);
 		/*
@@ -650,6 +665,11 @@ msdosfs_mountfs(struct vnode *devvp, str
 
 	pmp-pm_fatblk = pmp-pm_ResSectors;
 	if (FAT32(pmp)) {
+		if (secsize  sizeof(*b710)) {
+			DPRINTF((710 bootsec %u\n, secsize));
+			error = EINVAL;
+			goto error_exit;
+		}
 		pmp-pm_rootdirblk = getulong(b710-bpbRootClust);
 		pmp-pm_firstcluster = pmp-pm_fatblk
 			+ (pmp-pm_FATs * pmp-pm_FATsecs);



CVS commit: src/sys/fs/msdosfs

2015-01-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 23 03:33:58 UTC 2015

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
catch up with DPRINTF change


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.116 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.117
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.116	Thu Jan 22 21:39:48 2015
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Thu Jan 22 22:33:58 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.116 2015/01/23 02:39:48 christos Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.117 2015/01/23 03:33:58 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.116 2015/01/23 02:39:48 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.117 2015/01/23 03:33:58 christos Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -511,7 +511,7 @@ msdosfs_mountfs(struct vnode *devvp, str
 	 * boot signature.  If not a dos boot sector then error out.
 	 */
 	if (secsize  sizeof(*b50)) {
-		DPRINTF((50 bootsec %u\n, secsize));
+		DPRINTF(50 bootsec %u\n, secsize);
 		error = EINVAL;
 		goto error_exit;
 	}
@@ -557,7 +557,7 @@ msdosfs_mountfs(struct vnode *devvp, str
 		pmp-pm_HugeSectors = getulong(b50-bpbHugeSectors);
 	} else {
 		if (secsize  sizeof(*b33)) {
-			DPRINTF((33 bootsec %u\n, secsize));
+			DPRINTF(33 bootsec %u\n, secsize);
 			error = EINVAL;
 			goto error_exit;
 		}
@@ -590,7 +590,7 @@ msdosfs_mountfs(struct vnode *devvp, str
 
 	if (pmp-pm_RootDirEnts == 0) {
 		if (secsize  sizeof(*b710)) {
-			DPRINTF((710 bootsec %u\n, secsize));
+			DPRINTF(710 bootsec %u\n, secsize);
 			error = EINVAL;
 			goto error_exit;
 		}
@@ -666,7 +666,7 @@ msdosfs_mountfs(struct vnode *devvp, str
 	pmp-pm_fatblk = pmp-pm_ResSectors;
 	if (FAT32(pmp)) {
 		if (secsize  sizeof(*b710)) {
-			DPRINTF((710 bootsec %u\n, secsize));
+			DPRINTF(710 bootsec %u\n, secsize);
 			error = EINVAL;
 			goto error_exit;
 		}



CVS commit: src/sys/fs/msdosfs

2014-07-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Jul 18 17:24:34 UTC 2014

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
Make DPRINTF more understandable, and replace my previous #ifdef DIAGNOSTIC...


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.114 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.115
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.114	Wed Jul 16 20:09:00 2014
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Fri Jul 18 17:24:34 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.114 2014/07/16 20:09:00 maxv Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.115 2014/07/18 17:24:34 maxv Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.114 2014/07/16 20:09:00 maxv Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.115 2014/07/18 17:24:34 maxv Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -88,9 +88,9 @@ __KERNEL_RCSID(0, $NetBSD: msdosfs_vfso
 MODULE(MODULE_CLASS_VFS, msdos, NULL);
 
 #ifdef MSDOSFS_DEBUG
-#define DPRINTF(a) uprintf a
+#define DPRINTF(fmt, ...) uprintf(%s():  fmt \n, __func__, ##__VA_ARGS__)
 #else
-#define DPRINTF(a)
+#define DPRINTF(fmt, ...)
 #endif
 
 #define GEMDOSFS_BSIZE	512
@@ -337,7 +337,7 @@ msdosfs_mount(struct mount *mp, const ch
 			/* not yet implemented */
 			error = EOPNOTSUPP;
 		if (error) {
-			DPRINTF((vflush %d\n, error));
+			DPRINTF(vflush %d, error);
 			return (error);
 		}
 		if ((pmp-pm_flags  MSDOSFSMNT_RONLY) 
@@ -357,14 +357,14 @@ msdosfs_mount(struct mount *mp, const ch
 			KAUTH_SYSTEM_MOUNT, KAUTH_REQ_SYSTEM_MOUNT_DEVICE,
 			mp, devvp, KAUTH_ARG(VREAD | VWRITE));
 			VOP_UNLOCK(devvp);
-			DPRINTF((KAUTH_REQ_SYSTEM_MOUNT_DEVICE %d\n, error));
+			DPRINTF(KAUTH_REQ_SYSTEM_MOUNT_DEVICE %d, error);
 			if (error)
 return (error);
 
 			pmp-pm_flags = ~MSDOSFSMNT_RONLY;
 		}
 		if (args-fspec == NULL) {
-			DPRINTF((missing fspec\n));
+			DPRINTF(missing fspec);
 			return EINVAL;
 		}
 	}
@@ -375,17 +375,17 @@ msdosfs_mount(struct mount *mp, const ch
 	error = namei_simple_user(args-fspec,
 NSM_FOLLOW_NOEMULROOT, devvp);
 	if (error != 0) {
-		DPRINTF((namei %d\n, error));
+		DPRINTF(namei %d, error);
 		return (error);
 	}
 
 	if (devvp-v_type != VBLK) {
-		DPRINTF((not block\n));
+		DPRINTF(not block);
 		vrele(devvp);
 		return (ENOTBLK);
 	}
 	if (bdevsw_lookup(devvp-v_rdev) == NULL) {
-		DPRINTF((no block switch\n));
+		DPRINTF(no block switch);
 		vrele(devvp);
 		return (ENXIO);
 	}
@@ -401,7 +401,7 @@ msdosfs_mount(struct mount *mp, const ch
 	KAUTH_REQ_SYSTEM_MOUNT_DEVICE, mp, devvp, KAUTH_ARG(accessmode));
 	VOP_UNLOCK(devvp);
 	if (error) {
-		DPRINTF((KAUTH_REQ_SYSTEM_MOUNT_DEVICE %d\n, error));
+		DPRINTF(KAUTH_REQ_SYSTEM_MOUNT_DEVICE %d, error);
 		vrele(devvp);
 		return (error);
 	}
@@ -416,12 +416,12 @@ msdosfs_mount(struct mount *mp, const ch
 		error = VOP_OPEN(devvp, xflags, FSCRED);
 		VOP_UNLOCK(devvp);
 		if (error) {
-			DPRINTF((VOP_OPEN %d\n, error));
+			DPRINTF(VOP_OPEN %d, error);
 			goto fail;
 		}
 		error = msdosfs_mountfs(devvp, mp, l, args);
 		if (error) {
-			DPRINTF((msdosfs_mountfs %d\n, error));
+			DPRINTF(msdosfs_mountfs %d, error);
 			vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
 			(void) VOP_CLOSE(devvp, xflags, NOCRED);
 			VOP_UNLOCK(devvp);
@@ -433,14 +433,13 @@ msdosfs_mount(struct mount *mp, const ch
 	} else {
 		vrele(devvp);
 		if (devvp != pmp-pm_devvp) {
-			DPRINTF((devvp %p pmp %p\n, 
-			devvp, pmp-pm_devvp));
+			DPRINTF(devvp %p pmp %p, devvp, pmp-pm_devvp);
 			return (EINVAL);	/* needs translation */
 		}
 	}
 	if ((error = update_mp(mp, args)) != 0) {
 		msdosfs_unmount(mp, MNT_FORCE);
-		DPRINTF((update_mp %d\n, error));
+		DPRINTF(update_mp %d, error);
 		return error;
 	}
 
@@ -494,17 +493,14 @@ msdosfs_mountfs(struct vnode *devvp, str
 		error = 0;
 	}
 	if (secsize  DEV_BSIZE) {
-#ifdef DIAGNOSTIC /* XXX: to be converted to DPRINTF */
-		printf(%s(): Invalid block secsize (%d  DEV_BSIZE)\n, __func__,
-		secsize);
-#endif
+		DPRINTF(Invalid block secsize (%d  DEV_BSIZE), secsize);
 		error = EINVAL;
 		goto error_exit;
 	}
 
 	if (argp-flags  MSDOSFSMNT_GEMDOSFS) {
 		if (secsize != GEMDOSFS_BSIZE) {
-			DPRINTF((Invalid block secsize %d for GEMDOS\n, secsize));
+			DPRINTF(Invalid block secsize %d for GEMDOS, secsize);
 			error = EINVAL;
 			goto error_exit;
 		}
@@ -524,9 +520,9 @@ msdosfs_mountfs(struct vnode *devvp, str
 	if (!(argp-flags  MSDOSFSMNT_GEMDOSFS)) {
 		if (bsp-bs50.bsBootSectSig0 != BOOTSIG0
 		|| bsp-bs50.bsBootSectSig1 != BOOTSIG1) {
-			DPRINTF((bootsig0 %d bootsig1 %d\n, 
+			DPRINTF(bootsig0 %d bootsig1 

CVS commit: src/sys/fs/msdosfs

2014-07-16 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Jul 16 20:09:00 UTC 2014

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
Limit the minimum size of a disk sector to 512 bytes, to prevent memory
overflow on extremely low secsize. This normally conforms to the old standard
(for which there doesn't seem to be a clear spec). Since 2011, IDEMA's Advanced
Format standardizes it to 4k, so this change won't cause any trouble on
new devices.

Put the printf under DIAGNOSTIC temporarily to see if someone complains.

after a quick discussion on tech-kern


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.113 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.114
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.113	Tue Jul 15 11:43:54 2014
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Wed Jul 16 20:09:00 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.113 2014/07/15 11:43:54 christos Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.114 2014/07/16 20:09:00 maxv Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.113 2014/07/15 11:43:54 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.114 2014/07/16 20:09:00 maxv Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -493,6 +493,14 @@ msdosfs_mountfs(struct vnode *devvp, str
 		psize = 0;
 		error = 0;
 	}
+	if (secsize  DEV_BSIZE) {
+#ifdef DIAGNOSTIC /* XXX: to be converted to DPRINTF */
+		printf(%s(): Invalid block secsize (%d  DEV_BSIZE)\n, __func__,
+		secsize);
+#endif
+		error = EINVAL;
+		goto error_exit;
+	}
 
 	if (argp-flags  MSDOSFSMNT_GEMDOSFS) {
 		if (secsize != GEMDOSFS_BSIZE) {



CVS commit: src/sys/fs/msdosfs

2014-07-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jul 15 11:43:54 UTC 2014

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
Correct the bread size of struct fsinfo from Gerald Lee at DELL dot com


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.112 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.113
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.112	Wed Jul  9 05:00:18 2014
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Tue Jul 15 07:43:54 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.112 2014/07/09 09:00:18 maxv Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.113 2014/07/15 11:43:54 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.112 2014/07/09 09:00:18 maxv Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.113 2014/07/15 11:43:54 christos Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -741,6 +741,7 @@ msdosfs_mountfs(struct vnode *devvp, str
 	 */
 	if (pmp-pm_fsinfo) {
 		struct fsinfo *fp;
+		const int rdsz = roundup(sizeof(*fp), pmp-pm_BytesPerSec);
 
 		/*
 		 * XXX	If the fsinfo block is stored on media with
@@ -748,7 +749,7 @@ msdosfs_mountfs(struct vnode *devvp, str
 		 *	padded at the end or in the middle?
 		 */
 		if ((error = bread(devvp, de_bn2kb(pmp, pmp-pm_fsinfo),
-		pmp-pm_BytesPerSec, NOCRED, 0, bp)) != 0)
+		rdsz, NOCRED, 0, bp)) != 0)
 			goto error_exit;
 		fp = (struct fsinfo *)bp-b_data;
 		if (!memcmp(fp-fsisig1, RRaA, 4)



CVS commit: src/sys/fs/msdosfs

2014-07-09 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Jul  9 09:00:18 UTC 2014

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
Minor changes:
 - malloc()+memset() - malloc(|M_ZERO)
 - rename 'vers' to 'FSVers'
 - declare 'ExtFlags' instead of calling getushort() two times


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.111 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.112
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.111	Wed Jul  9 08:43:54 2014
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Wed Jul  9 09:00:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.111 2014/07/09 08:43:54 maxv Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.112 2014/07/09 09:00:18 maxv Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.111 2014/07/09 08:43:54 maxv Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.112 2014/07/09 09:00:18 maxv Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -524,8 +524,7 @@ msdosfs_mountfs(struct vnode *devvp, str
 		}
 	}
 
-	pmp = malloc(sizeof *pmp, M_MSDOSFSMNT, M_WAITOK);
-	memset(pmp, 0, sizeof *pmp);
+	pmp = malloc(sizeof(*pmp), M_MSDOSFSMNT, M_WAITOK|M_ZERO);
 	pmp-pm_mountp = mp;
 
 	/*
@@ -576,15 +575,16 @@ msdosfs_mountfs(struct vnode *devvp, str
 	}
 
 	if (pmp-pm_RootDirEnts == 0) {
-		unsigned short vers = getushort(b710-bpbFSVers);
+		unsigned short FSVers = getushort(b710-bpbFSVers);
+		unsigned short ExtFlags = getushort(b710-bpbExtFlags);
 		/*
 		 * Some say that bsBootSectSig[23] must be zero, but
 		 * Windows does not require this and some digital cameras
 		 * do not set these to zero.  Therefore, do not insist.
 		 */
-		if (pmp-pm_Sectors || pmp-pm_FATsecs || vers) {
-			DPRINTF((sectors %d fatsecs %lu vers %d\n,
-			pmp-pm_Sectors, pmp-pm_FATsecs, vers));
+		if (pmp-pm_Sectors || pmp-pm_FATsecs || FSVers) {
+			DPRINTF((Sectors %d FATsecs %lu FSVers %d\n,
+			pmp-pm_Sectors, pmp-pm_FATsecs, FSVers));
 			error = EINVAL;
 			goto error_exit;
 		}
@@ -593,20 +593,18 @@ msdosfs_mountfs(struct vnode *devvp, str
 		pmp-pm_fatdiv = 1;
 		pmp-pm_FATsecs = getulong(b710-bpbBigFATsecs);
 
-		/* mirrorring is enabled if the FATMIRROR bit is not set */
-		if ((getushort(b710-bpbExtFlags)  FATMIRROR) == 0)
+		/* Mirroring is enabled if the FATMIRROR bit is not set. */
+		if ((ExtFlags  FATMIRROR) == 0)
 			pmp-pm_flags |= MSDOSFS_FATMIRROR;
 		else
-			pmp-pm_curfat = getushort(b710-bpbExtFlags)  FATNUM;
+			pmp-pm_curfat = ExtFlags  FATNUM;
 	} else
 		pmp-pm_flags |= MSDOSFS_FATMIRROR;
 
 	if (argp-flags  MSDOSFSMNT_GEMDOSFS) {
 		if (FAT32(pmp)) {
+			/* GEMDOS doesn't know FAT32. */
 			DPRINTF((FAT32 for GEMDOS\n));
-			/*
-			 * GEMDOS doesn't know FAT32.
-			 */
 			error = EINVAL;
 			goto error_exit;
 		}



CVS commit: src/sys/fs/msdosfs

2014-07-08 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jul  8 09:21:52 UTC 2014

Modified Files:
src/sys/fs/msdosfs: denode.h msdosfs_denode.c msdosfs_lookup.c
msdosfs_vfsops.c msdosfs_vnops.c msdosfsmount.h

Log Message:
Change msdosfs from hashlist to vcache:
- Use (dir_cluster, dir_offset, dir_generation) as key, where
  dir_generation is non-zero and unique for unlinked but open nodes.
- Change deget() to return a vnode as it is unsafe to return a
  referenced but unlocked denode.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/fs/msdosfs/denode.h
cvs rdiff -u -r1.49 -r1.50 src/sys/fs/msdosfs/msdosfs_denode.c
cvs rdiff -u -r1.32 -r1.33 src/sys/fs/msdosfs/msdosfs_lookup.c
cvs rdiff -u -r1.108 -r1.109 src/sys/fs/msdosfs/msdosfs_vfsops.c
cvs rdiff -u -r1.89 -r1.90 src/sys/fs/msdosfs/msdosfs_vnops.c
cvs rdiff -u -r1.19 -r1.20 src/sys/fs/msdosfs/msdosfsmount.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/denode.h
diff -u src/sys/fs/msdosfs/denode.h:1.23 src/sys/fs/msdosfs/denode.h:1.24
--- src/sys/fs/msdosfs/denode.h:1.23	Sat Jan 26 19:45:02 2013
+++ src/sys/fs/msdosfs/denode.h	Tue Jul  8 09:21:52 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: denode.h,v 1.23 2013/01/26 19:45:02 christos Exp $	*/
+/*	$NetBSD: denode.h,v 1.24 2014/07/08 09:21:52 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -153,15 +153,21 @@ struct fatcache {
  * This is the in memory variant of a dos directory entry.  It is usually
  * contained within a vnode.
  */
+struct denode_key {
+	u_long dk_dirclust;	/* cluster of the directory file containing this entry */
+	u_long dk_diroffset;	/* offset of this entry in the directory cluster */
+	void *dk_dirgen;	/* non zero and unique for unlinked nodes */
+};
 struct denode {
 	struct genfs_node de_gnode;
-	LIST_ENTRY(denode) de_hash;
 	struct vnode *de_vnode;	/* addr of vnode we are part of */
 	struct vnode *de_devvp;	/* vnode of blk dev we live on */
 	u_long de_flag;		/* flag bits */
 	dev_t de_dev;		/* device where direntry lives */
-	u_long de_dirclust;	/* cluster of the directory file containing this entry */
-	u_long de_diroffset;	/* offset of this entry in the directory cluster */
+	struct denode_key de_key;
+#define de_dirclust de_key.dk_dirclust
+#define de_diroffset de_key.dk_diroffset
+#define de_dirgen de_key.dk_dirgen
 	u_long de_fndoffset;	/* offset of found dir entry */
 	int de_fndcnt;		/* number of slots before de_fndoffset */
 	long de_refcnt;		/* reference count */
@@ -303,7 +309,11 @@ int msdosfs_update(struct vnode *, const
 int createde(struct denode *, struct denode *,
 		struct denode **, struct componentname *);
 int deextend(struct denode *, u_long, struct kauth_cred *);
+#ifdef MAKEFS
 int deget(struct msdosfsmount *, u_long, u_long, struct denode **);
+#else
+int deget(struct msdosfsmount *, u_long, u_long, struct vnode **);
+#endif
 int detrunc(struct denode *, u_long, int, struct kauth_cred *);
 int deupdat(struct denode *, int);
 int doscheckpath(struct denode *, struct denode *);
@@ -311,7 +321,6 @@ int dosdirempty(struct denode *);
 int readde(struct denode *, struct buf **, struct direntry **);
 int readep(struct msdosfsmount *, u_long, u_long,
 		struct buf **, struct direntry **);
-void reinsert(struct denode *);
 int removede(struct denode *, struct denode *);
 int uniqdosname(struct denode *, struct componentname *, u_char *);
 int findwin95(struct denode *);

Index: src/sys/fs/msdosfs/msdosfs_denode.c
diff -u src/sys/fs/msdosfs/msdosfs_denode.c:1.49 src/sys/fs/msdosfs/msdosfs_denode.c:1.50
--- src/sys/fs/msdosfs/msdosfs_denode.c:1.49	Fri May 30 08:42:35 2014
+++ src/sys/fs/msdosfs/msdosfs_denode.c	Tue Jul  8 09:21:52 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_denode.c,v 1.49 2014/05/30 08:42:35 hannken Exp $	*/
+/*	$NetBSD: msdosfs_denode.c,v 1.50 2014/07/08 09:21:52 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.49 2014/05/30 08:42:35 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.50 2014/07/08 09:21:52 hannken Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -72,14 +72,6 @@ __KERNEL_RCSID(0, $NetBSD: msdosfs_deno
 #include fs/msdosfs/denode.h
 #include fs/msdosfs/fat.h
 
-LIST_HEAD(ihashhead, denode) *dehashtbl;
-u_long dehash;			/* size of hash table - 1 */
-#define	DEHASH(dev, dcl, doff) \
-(((dev) + (dcl) + (doff) / sizeof(struct direntry))  dehash)
-
-kmutex_t msdosfs_ihash_lock;
-kmutex_t msdosfs_hashlock;
-
 struct pool msdosfs_denode_pool;
 
 extern int prtactive;
@@ -138,10 +130,6 @@ static const struct genfs_ops msdosfs_ge
 	.gop_markupdate = msdosfs_gop_markupdate,
 };
 
-static struct denode *msdosfs_hashget(dev_t, u_long, u_long, int);
-static void msdosfs_hashins(struct denode *);
-static void 

CVS commit: src/sys/fs/msdosfs

2014-07-08 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Jul  8 19:34:47 UTC 2014

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
- Perform sanity checks not just for GEMDOSFS, but for all FAT devices. This
  also fixes a division-by-zero bug that could crash the system.
- Define GEMDOSFS_BSIZE instead of a hard-coded 512 value, and remove 'bsize'.
- Rename 'tmp' to 'BlkPerSec'.

From me, FreeBSD, OpenBSD and the FAT specification.

ok christos@


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.109 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.110
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.109	Tue Jul  8 09:21:52 2014
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Tue Jul  8 19:34:47 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.109 2014/07/08 09:21:52 hannken Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.110 2014/07/08 19:34:47 maxv Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.109 2014/07/08 09:21:52 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.110 2014/07/08 19:34:47 maxv Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -93,6 +93,8 @@ MODULE(MODULE_CLASS_VFS, msdos, NULL);
 #define DPRINTF(a)
 #endif
 
+#define GEMDOSFS_BSIZE	512
+
 #define MSDOSFS_NAMEMAX(pmp) \
 	(pmp)-pm_flags  MSDOSFSMNT_LONGNAME ? WIN_MAXLEN : 12
 
@@ -466,8 +468,7 @@ msdosfs_mountfs(struct vnode *devvp, str
 	struct byte_bpb50 *b50;
 	struct byte_bpb710 *b710;
 	uint8_t SecPerClust;
-	int	ronly, error, tmp;
-	int	bsize;
+	int	ronly, error, BlkPerSec;
 	uint64_t psize;
 	unsigned secsize;
 
@@ -496,14 +497,12 @@ msdosfs_mountfs(struct vnode *devvp, str
 	}
 
 	if (argp-flags  MSDOSFSMNT_GEMDOSFS) {
-		bsize = secsize;
-		if (bsize != 512) {
-			DPRINTF((Invalid block bsize %d for GEMDOS\n, bsize));
+		if (secsize != GEMDOSFS_BSIZE) {
+			DPRINTF((Invalid block secsize %d for GEMDOS\n, secsize));
 			error = EINVAL;
 			goto error_exit;
 		}
-	} else
-		bsize = 0;
+	}
 
 	/*
 	 * Read the boot sector of the filesystem, and then check the
@@ -547,19 +546,6 @@ msdosfs_mountfs(struct vnode *devvp, str
 	pmp-pm_Heads = getushort(b50-bpbHeads);
 	pmp-pm_Media = b50-bpbMedia;
 
-	if (!(argp-flags  MSDOSFSMNT_GEMDOSFS)) {
-		/* XXX - We should probably check more values here */
-		if (!pmp-pm_BytesPerSec || !SecPerClust
-			|| pmp-pm_SecPerTrack  63) {
-			DPRINTF((bytespersec %d secperclust %d 
-			secpertrack %d\n, 
-			pmp-pm_BytesPerSec, SecPerClust,
-			pmp-pm_SecPerTrack));
-			error = EINVAL;
-			goto error_exit;
-		}
-	}
-
 	if (pmp-pm_Sectors == 0) {
 		pmp-pm_HiddenSects = getulong(b50-bpbHiddenSecs);
 		pmp-pm_HugeSectors = getulong(b50-bpbHugeSectors);
@@ -568,6 +554,29 @@ msdosfs_mountfs(struct vnode *devvp, str
 		pmp-pm_HugeSectors = pmp-pm_Sectors;
 	}
 
+	/*
+	 * Sanity checks, from the FAT specification:
+	 * - sectors per cluster: = 1, power of 2
+	 * - logical sector size: = 1, power of 2
+	 * - cluster size:= max FS block size
+	 * - number of sectors:   = 1
+	 */
+	if ((SecPerClust == 0) || !powerof2(SecPerClust) ||
+	(pmp-pm_BytesPerSec == 0) || !powerof2(pmp-pm_BytesPerSec) ||
+	(SecPerClust * pmp-pm_BytesPerSec  MAXBSIZE) ||
+	(pmp-pm_HugeSectors == 0)) {
+		DPRINTF((consistency checks\n));
+		error = EINVAL;
+		goto error_exit;
+	}
+
+	if (!(argp-flags  MSDOSFSMNT_GEMDOSFS) 
+	(pmp-pm_SecPerTrack  63)) {
+		DPRINTF((SecPerTrack %d\n, pmp-pm_SecPerTrack));
+		error = EINVAL;
+		goto error_exit;
+	}
+
 	if (pmp-pm_RootDirEnts == 0) {
 		unsigned short vers = getushort(b710-bpbFSVers);
 		/*
@@ -606,17 +615,12 @@ msdosfs_mountfs(struct vnode *devvp, str
 
 		/*
 		 * Check a few values (could do some more):
-		 * - logical sector size: power of 2, = block size
-		 * - sectors per cluster: power of 2, = 1
-		 * - number of sectors:   = 1, = size of partition
+		 * - logical sector size: = block size
+		 * - number of sectors:   = size of partition
 		 */
-		if ( (SecPerClust == 0)
-		  || (SecPerClust  (SecPerClust - 1))
-		  || (pmp-pm_BytesPerSec  bsize)
-		  || (pmp-pm_BytesPerSec  (pmp-pm_BytesPerSec - 1))
-		  || (pmp-pm_HugeSectors == 0)
-		  || (pmp-pm_HugeSectors * (pmp-pm_BytesPerSec / bsize)
-		   psize)) {
+		if ((pmp-pm_BytesPerSec  GEMDOSFS_BSIZE) ||
+		(pmp-pm_HugeSectors *
+		 (pmp-pm_BytesPerSec / GEMDOSFS_BSIZE)  psize)) {
 			DPRINTF((consistency checks for GEMDOS\n));
 			error = EINVAL;
 			goto error_exit;
@@ -627,14 +631,14 @@ msdosfs_mountfs(struct vnode *devvp, str
 		 * always be the same as the number of bytes per disk block
 		 * Let's pretend it is.
 		 */
-		tmp = pmp-pm_BytesPerSec / 

CVS commit: src/sys/fs/msdosfs

2014-05-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri May 30 08:42:35 UTC 2014

Modified Files:
src/sys/fs/msdosfs: msdosfs_denode.c

Log Message:
msdosfs_reclaim(): add missing fstrans and protect change
of v_data with v_interlock as msdosfs_sync() now needs it.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/fs/msdosfs/msdosfs_denode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_denode.c
diff -u src/sys/fs/msdosfs/msdosfs_denode.c:1.48 src/sys/fs/msdosfs/msdosfs_denode.c:1.49
--- src/sys/fs/msdosfs/msdosfs_denode.c:1.48	Thu Dec 20 08:03:42 2012
+++ src/sys/fs/msdosfs/msdosfs_denode.c	Fri May 30 08:42:35 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_denode.c,v 1.48 2012/12/20 08:03:42 hannken Exp $	*/
+/*	$NetBSD: msdosfs_denode.c,v 1.49 2014/05/30 08:42:35 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.48 2012/12/20 08:03:42 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.49 2014/05/30 08:42:35 hannken Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -671,8 +671,10 @@ msdosfs_reclaim(void *v)
 		struct vnode *a_vp;
 	} */ *ap = v;
 	struct vnode *vp = ap-a_vp;
+	struct mount *mp = vp-v_mount;
 	struct denode *dep = VTODE(vp);
 
+	fstrans_start(mp, FSTRANS_LAZY);
 #ifdef MSDOSFS_DEBUG
 	printf(msdosfs_reclaim(): dep %p, file %s, refcnt %ld\n,
 	dep, dep-de_Name, dep-de_refcnt);
@@ -694,9 +696,15 @@ msdosfs_reclaim(void *v)
 #if 0 /* XXX */
 	dep-de_flag = 0;
 #endif
+	/*
+	 * To interlock with msdosfs_sync().
+	 */
 	genfs_node_destroy(vp);
-	pool_put(msdosfs_denode_pool, dep);
+	mutex_enter(vp-v_interlock);
 	vp-v_data = NULL;
+	mutex_exit(vp-v_interlock);
+	pool_put(msdosfs_denode_pool, dep);
+	fstrans_done(mp);
 	return (0);
 }
 



CVS commit: src/sys/fs/msdosfs

2014-03-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Mar 17 09:35:59 UTC 2014

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
Change msdosfs_sync() to use vfs_vnode_iterator.


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.104 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.105
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.104	Tue Feb 25 18:30:10 2014
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Mon Mar 17 09:35:59 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.104 2014/02/25 18:30:10 pooka Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.105 2014/03/17 09:35:59 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.104 2014/02/25 18:30:10 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.105 2014/03/17 09:35:59 hannken Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -946,7 +946,8 @@ msdosfs_statvfs(struct mount *mp, struct
 int
 msdosfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred)
 {
-	struct vnode *vp, *mvp;
+	struct vnode *vp;
+	struct vnode_iterator *marker;
 	struct denode *dep;
 	struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
 	int error, allerror = 0;
@@ -962,46 +963,32 @@ msdosfs_sync(struct mount *mp, int waitf
 			/* update FATs here */
 		}
 	}
-	/* Allocate a marker vnode. */
-	mvp = vnalloc(mp);
 	fstrans_start(mp, FSTRANS_SHARED);
 	/*
 	 * Write back each (modified) denode.
 	 */
-	mutex_enter(mntvnode_lock);
-loop:
-	for (vp = TAILQ_FIRST(mp-mnt_vnodelist); vp; vp = vunmark(mvp)) {
-		vmark(mvp, vp);
-		if (vp-v_mount != mp || vismarker(vp))
+	vfs_vnode_iterator_init(mp, marker);
+	while (vfs_vnode_iterator_next(marker, vp)) {
+		error = vn_lock(vp, LK_EXCLUSIVE);
+		if (error) {
+			vrele(vp);
 			continue;
-		mutex_enter(vp-v_interlock);
+		}
 		dep = VTODE(vp);
 		if (waitfor == MNT_LAZY || vp-v_type == VNON ||
 		dep == NULL || (((dep-de_flag 
 		(DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED)) == 0) 
 		 (LIST_EMPTY(vp-v_dirtyblkhd) 
 		  UVM_OBJ_IS_CLEAN(vp-v_uobj {
-			mutex_exit(vp-v_interlock);
-			continue;
-		}
-		mutex_exit(mntvnode_lock);
-		error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT);
-		if (error) {
-			mutex_enter(mntvnode_lock);
-			if (error == ENOENT) {
-(void)vunmark(mvp);
-goto loop;
-			}
+			vput(vp);
 			continue;
 		}
 		if ((error = VOP_FSYNC(vp, cred,
 		waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0)) != 0)
 			allerror = error;
 		vput(vp);
-		mutex_enter(mntvnode_lock);
 	}
-	mutex_exit(mntvnode_lock);
-	vnfree(mvp);
+	vfs_vnode_iterator_destroy(marker);
 
 	/*
 	 * Force stale file system control information to be flushed.



CVS commit: src/sys/fs/msdosfs

2013-12-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Dec 24 16:51:24 UTC 2013

Modified Files:
src/sys/fs/msdosfs: msdosfs_lookup.c

Log Message:
don't treat adjacent members as a larger array
Coverity CID 977367


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/fs/msdosfs/msdosfs_lookup.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_lookup.c
diff -u src/sys/fs/msdosfs/msdosfs_lookup.c:1.29 src/sys/fs/msdosfs/msdosfs_lookup.c:1.30
--- src/sys/fs/msdosfs/msdosfs_lookup.c:1.29	Sat Jan 26 16:51:51 2013
+++ src/sys/fs/msdosfs/msdosfs_lookup.c	Tue Dec 24 16:51:24 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_lookup.c,v 1.29 2013/01/26 16:51:51 christos Exp $	*/
+/*	$NetBSD: msdosfs_lookup.c,v 1.30 2013/12/24 16:51:24 mlelstv Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -52,7 +52,7 @@
 #endif
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_lookup.c,v 1.29 2013/01/26 16:51:51 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_lookup.c,v 1.30 2013/12/24 16:51:24 mlelstv Exp $);
 
 #include sys/param.h
 
@@ -300,8 +300,10 @@ msdosfs_lookup(void *v)
  * Check for a checksum or name match
  */
 chksum_ok = (chksum == winChksum(dep-deName));
-if (!chksum_ok
- (!olddos || memcmp(dosfilename, dep-deName, 11))) {
+if (!chksum_ok  (
+	!olddos ||
+	memcmp(dosfilename[0],dep-deName,8) ||
+	memcmp(dosfilename[8],dep-deExtension,3))) {
 	chksum = -1;
 	continue;
 }



CVS commit: src/sys/fs/msdosfs

2013-11-02 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Nov  2 10:30:18 UTC 2013

Modified Files:
src/sys/fs/msdosfs: msdosfs_vnops.c

Log Message:
Stop using v_mount of an unreferenced vnode -- save the mount while
the vnode has a reference.


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/fs/msdosfs/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vnops.c
diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.86 src/sys/fs/msdosfs/msdosfs_vnops.c:1.87
--- src/sys/fs/msdosfs/msdosfs_vnops.c:1.86	Mon Mar 18 19:35:37 2013
+++ src/sys/fs/msdosfs/msdosfs_vnops.c	Sat Nov  2 10:30:18 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.86 2013/03/18 19:35:37 plunky Exp $	*/
+/*	$NetBSD: msdosfs_vnops.c,v 1.87 2013/11/02 10:30:18 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.86 2013/03/18 19:35:37 plunky Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.87 2013/11/02 10:30:18 hannken Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -829,6 +829,7 @@ msdosfs_rename(void *v)
 	struct vnode *tdvp = ap-a_tdvp;
 	struct vnode *fvp = ap-a_fvp;
 	struct vnode *fdvp = ap-a_fdvp;
+	struct mount *mp = fdvp-v_mount;
 	struct componentname *tcnp = ap-a_tcnp;
 	struct componentname *fcnp = ap-a_fcnp;
 	struct denode *ip, *xp, *dp, *zp;
@@ -906,7 +907,7 @@ abortit:
 	}
 	VN_KNOTE(fdvp, NOTE_WRITE);		/* XXXLUKEM/XXX: right place? */
 
-	fstrans_start(fdvp-v_mount, FSTRANS_SHARED);
+	fstrans_start(mp, FSTRANS_SHARED);
 	/*
 	 * When the target exists, both the directory
 	 * and target vnodes are returned locked.
@@ -993,7 +994,7 @@ abortit:
 	 * file/directory.
 	 */
 	if ((error = uniqdosname(VTODE(tdvp), tcnp, toname)) != 0) {
-		fstrans_done(fdvp-v_mount);
+		fstrans_done(mp);
 		goto abortit;
 	}
 
@@ -1009,7 +1010,7 @@ abortit:
 		VOP_UNLOCK(fdvp);
 		vrele(ap-a_fvp);
 		vrele(tdvp);
-		fstrans_done(fdvp-v_mount);
+		fstrans_done(mp);
 		return (error);
 	}
 	if (fvp == NULL) {
@@ -1021,7 +1022,7 @@ abortit:
 		vput(fdvp);
 		vrele(ap-a_fvp);
 		vrele(tdvp);
-		fstrans_done(fdvp-v_mount);
+		fstrans_done(mp);
 		return 0;
 	}
 	VOP_UNLOCK(fdvp);
@@ -1129,7 +1130,7 @@ bad:
 	ip-de_flag = ~DE_RENAME;
 	vrele(fdvp);
 	vrele(fvp);
-	fstrans_done(fdvp-v_mount);
+	fstrans_done(mp);
 	return (error);
 
 	/* XXX: uuuh */
@@ -1291,6 +1292,7 @@ msdosfs_rmdir(void *v)
 	} */ *ap = v;
 	struct vnode *vp = ap-a_vp;
 	struct vnode *dvp = ap-a_dvp;
+	struct mount *mp = dvp-v_mount;
 	struct componentname *cnp = ap-a_cnp;
 	struct denode *ip, *dp;
 	int error;
@@ -1305,7 +1307,7 @@ msdosfs_rmdir(void *v)
 		vput(vp);
 		return (EINVAL);
 	}
-	fstrans_start(ap-a_dvp-v_mount, FSTRANS_SHARED);
+	fstrans_start(mp, FSTRANS_SHARED);
 	/*
 	 * Verify the directory is empty (and valid).
 	 * (Rmdir .. won't be valid since
@@ -1347,7 +1349,7 @@ out:
 	if (dvp)
 		vput(dvp);
 	vput(vp);
-	fstrans_done(ap-a_dvp-v_mount);
+	fstrans_done(mp);
 	return (error);
 }
 



CVS commit: src/sys/fs/msdosfs

2013-10-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Oct 20 00:01:55 UTC 2013

Modified Files:
src/sys/fs/msdosfs: direntry.h

Log Message:
provide a function to access the name and extension as a single array as
opposed depend on array index overflow.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/fs/msdosfs/direntry.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/direntry.h
diff -u src/sys/fs/msdosfs/direntry.h:1.6 src/sys/fs/msdosfs/direntry.h:1.7
--- src/sys/fs/msdosfs/direntry.h:1.6	Fri Jan 25 19:21:49 2013
+++ src/sys/fs/msdosfs/direntry.h	Sat Oct 19 20:01:55 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: direntry.h,v 1.6 2013/01/26 00:21:49 christos Exp $	*/
+/*	$NetBSD: direntry.h,v 1.7 2013/10/20 00:01:55 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -78,6 +78,12 @@ struct direntry {
 	u_int8_t	deFileSize[4];	/* size of file in bytes */
 };
 
+static __inline uint8_t
+msdos_dirchar(const struct direntry *de, size_t i) {
+	return i  sizeof(de-deName) ? de-deName[i] :
+	de-deExtension[i - sizeof(de-deName)];
+}
+
 /*
  * Structure of a Win95 long name directory entry
  */



CVS commit: src/sys/fs/msdosfs

2013-04-15 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Mon Apr 15 14:11:00 UTC 2013

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
Don't attempt to mount file system with clusters larger than MAXBSIZE.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.100 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.101
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.100	Sun Nov  4 17:57:59 2012
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Mon Apr 15 14:10:59 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.100 2012/11/04 17:57:59 jakllsch Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.101 2013/04/15 14:10:59 jakllsch Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.100 2012/11/04 17:57:59 jakllsch Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.101 2013/04/15 14:10:59 jakllsch Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -727,6 +727,18 @@ msdosfs_mountfs(struct vnode *devvp, str
 	}
 
 	/*
+	 * Cluster size must be within limit of MAXBSIZE.
+	 * Many FAT filesystems will not have clusters larger than
+	 * 32KiB due to limits in Windows versions before Vista.
+	 */
+	if (pmp-pm_bpcluster  MAXBSIZE) {
+		DPRINTF((bpcluster %lu  MAXBSIZE %d\n,
+		pmp-pm_bpcluster, MAXBSIZE));
+		error = EINVAL;
+		goto error_exit;
+	}
+
+	/*
 	 * Release the bootsector buffer.
 	 */
 	brelse(bp, BC_AGE);



CVS commit: src/sys/fs/msdosfs

2013-01-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 27 20:15:58 UTC 2013

Modified Files:
src/sys/fs/msdosfs: msdosfs_fat.c

Log Message:
tidy up debugging printfs; no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/fs/msdosfs/msdosfs_fat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_fat.c
diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.25 src/sys/fs/msdosfs/msdosfs_fat.c:1.26
--- src/sys/fs/msdosfs/msdosfs_fat.c:1.25	Sat Jan 26 11:51:51 2013
+++ src/sys/fs/msdosfs/msdosfs_fat.c	Sun Jan 27 15:15:58 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_fat.c,v 1.25 2013/01/26 16:51:51 christos Exp $	*/
+/*	$NetBSD: msdosfs_fat.c,v 1.26 2013/01/27 20:15:58 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -52,7 +52,7 @@
 #endif
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.25 2013/01/26 16:51:51 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.26 2013/01/27 20:15:58 christos Exp $);
 
 /*
  * kernel include files.
@@ -97,6 +97,11 @@ int fc_wherefrom, fc_whereto, fc_lastclu
 int pm_fatblocksize;
 
 #ifdef MSDOSFS_DEBUG
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+#ifdef MSDOSFS_DEBUG
 void print_fat_stats(void);
 
 void
@@ -199,6 +204,7 @@ pcbmap(struct denode *dep, u_long findcn
 		return (0);
 
 	cn = dep-de_StartCluster;
+	DPRINTF((%s(start cluster=%lu)\n, __func__, cn));
 	/*
 	 * The file that makes up the root directory is contiguous,
 	 * permanently allocated, of fixed size, and is not made up of
@@ -210,6 +216,8 @@ pcbmap(struct denode *dep, u_long findcn
 			if (de_cn2off(pmp, findcn) = dep-de_FileSize) {
 if (cnp)
 	*cnp = de_bn2cn(pmp, pmp-pm_rootdirsize);
+DPRINTF((%s(root, %lu ETOOBIG)\n, __func__,
+de_cn2off(pmp, findcn)));
 return (E2BIG);
 			}
 			if (bnp)
@@ -219,10 +227,14 @@ pcbmap(struct denode *dep, u_long findcn
 			if (sp)
 *sp = min(pmp-pm_bpcluster,
 dep-de_FileSize - de_cn2off(pmp, findcn));
+			DPRINTF((%s(root, bn=%lu, cn=%u)\n, __func__,
+			pmp-pm_rootdirblk + de_cn2bn(pmp, findcn),
+			MSDOSFSROOT));
 			return (0);
 		} else {		/* just an empty file */
 			if (cnp)
 *cnp = 0;
+			DPRINTF((%s(root, empty ETOOBIG)\n, __func__));
 			return (E2BIG);
 		}
 	}
@@ -240,6 +252,8 @@ pcbmap(struct denode *dep, u_long findcn
 	 */
 	i = 0;
 	fc_lookup(dep, findcn, i, cn);
+	DPRINTF((%s(bpcluster=%lu i=%lu cn=%lu\n, __func__, pmp-pm_bpcluster,
+	i, cn));
 	if ((bn = findcn - i) = LMMAX) {
 		fc_largedistance++;
 		fc_wherefrom = i;
@@ -265,6 +279,7 @@ pcbmap(struct denode *dep, u_long findcn
 			error = bread(pmp-pm_devvp, de_bn2kb(pmp, bn), bsize,
 			NOCRED, 0, bp);
 			if (error) {
+DPRINTF((%s(bread, %d)\n, __func__, error));
 return (error);
 			}
 			bp_bn = bn;
@@ -273,6 +288,8 @@ pcbmap(struct denode *dep, u_long findcn
 		if (bo = bsize) {
 			if (bp)
 brelse(bp, 0);
+			DPRINTF((%s(block, %lu = %lu)\n, __func__, bo,
+			bsize));
 			return (EIO);
 		}
 		KASSERT(bp != NULL);
@@ -292,6 +309,8 @@ pcbmap(struct denode *dep, u_long findcn
 			*bnp = cntobn(pmp, cn);
 		if (cnp)
 			*cnp = cn;
+		DPRINTF((%s(bn=%lu, cn=%lu)\n, __func__, cntobn(pmp, cn),
+		cn));
 		fc_setcache(dep, FC_LASTMAP, i, cn);
 		return (0);
 	}
@@ -303,6 +322,7 @@ hiteof:;
 		brelse(bp, 0);
 	/* update last file cluster entry in the FAT cache */
 	fc_setcache(dep, FC_LASTFC, i - 1, prevcn);
+	DPRINTF((%s(eof, %lu)\n, __func__, i));
 	return (E2BIG);
 }
 
@@ -362,10 +382,7 @@ updatefats(struct msdosfsmount *pmp, str
 	int i;
 	struct buf *bpn;
 
-#ifdef MSDOSFS_DEBUG
-	printf(updatefats(pmp %p, bp %p, fatbn %lu)\n,
-	pmp, bp, fatbn);
-#endif
+	DPRINTF((%s(pmp %p, bp %p, fatbn %lu)\n, __func__, pmp, bp, fatbn));
 
 	/*
 	 * If we have an FSInfo block, update it.
@@ -530,17 +547,16 @@ fatentry(int function, struct msdosfsmou
 	u_long bn, bo, bsize, byteoffset;
 	struct buf *bp;
 
-#ifdef	MSDOSFS_DEBUG
-	printf(fatentry(func %d, pmp %p, clust %lu, oldcon %p, newcon %lx)\n,
-	 function, pmp, cn, oldcontents, newcontents);
-#endif
+	DPRINTF((%s(func %d, pmp %p, clust %lu, oldcon %p, newcon  %lx)\n,
+	__func__, function, pmp, cn, oldcontents, newcontents));
 
 #ifdef DIAGNOSTIC
 	/*
 	 * Be sure they asked us to do something.
 	 */
 	if ((function  (FAT_SET | FAT_GET)) == 0) {
-		printf(fatentry(): function code doesn't specify get or set\n);
+		DPRINTF((%s(): function code doesn't specify get or set\n,
+		__func__));
 		return (EINVAL);
 	}
 
@@ -549,7 +565,8 @@ fatentry(int function, struct msdosfsmou
 	 * where to put it, give them an error.
 	 */
 	if ((function  FAT_GET)  oldcontents == NULL) {
-		printf(fatentry(): get function with no place to put result\n);
+		DPRINTF((%s(): get function with no place to put result\n,
+			__func__));
 		return (EINVAL);
 	}
 

CVS commit: src/sys/fs/msdosfs

2013-01-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 27 22:04:19 UTC 2013

Modified Files:
src/sys/fs/msdosfs: msdosfs_fat.c

Log Message:
don't need sys/mount.h in userland.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/fs/msdosfs/msdosfs_fat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_fat.c
diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.26 src/sys/fs/msdosfs/msdosfs_fat.c:1.27
--- src/sys/fs/msdosfs/msdosfs_fat.c:1.26	Sun Jan 27 15:15:58 2013
+++ src/sys/fs/msdosfs/msdosfs_fat.c	Sun Jan 27 17:04:19 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_fat.c,v 1.26 2013/01/27 20:15:58 christos Exp $	*/
+/*	$NetBSD: msdosfs_fat.c,v 1.27 2013/01/27 22:04:19 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -52,15 +52,15 @@
 #endif
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.26 2013/01/27 20:15:58 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.27 2013/01/27 22:04:19 christos Exp $);
 
 /*
  * kernel include files.
  */
 #include sys/param.h
 #include sys/file.h
-#include sys/mount.h		/* to define statvfs structure */
 #ifdef _KERNEL
+#include sys/mount.h		/* to define statvfs structure */
 #include sys/errno.h
 #include sys/systm.h
 #include sys/kauth.h



CVS commit: src/sys/fs/msdosfs

2013-01-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jan 28 00:17:18 UTC 2013

Modified Files:
src/sys/fs/msdosfs: msdosfs_fat.c

Log Message:
A little more debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/fs/msdosfs/msdosfs_fat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_fat.c
diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.27 src/sys/fs/msdosfs/msdosfs_fat.c:1.28
--- src/sys/fs/msdosfs/msdosfs_fat.c:1.27	Sun Jan 27 17:04:19 2013
+++ src/sys/fs/msdosfs/msdosfs_fat.c	Sun Jan 27 19:17:18 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_fat.c,v 1.27 2013/01/27 22:04:19 christos Exp $	*/
+/*	$NetBSD: msdosfs_fat.c,v 1.28 2013/01/28 00:17:18 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -52,7 +52,7 @@
 #endif
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.27 2013/01/27 22:04:19 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.28 2013/01/28 00:17:18 christos Exp $);
 
 /*
  * kernel include files.
@@ -147,6 +147,8 @@ fatblock(struct msdosfsmount *pmp, u_lon
 	* pmp-pm_BytesPerSec;
 	bn += pmp-pm_fatblk + pmp-pm_curfat * pmp-pm_FATsecs;
 
+	DPRINTF((%s(ofs=%lu bn=%lu, size=%lu, bo=%lu)\n, __func__, ofs, bn,
+	size, ofs % pmp-pm_fatblocksize));
 	if (bnp)
 		*bnp = bn;
 	if (sizep)
@@ -154,7 +156,7 @@ fatblock(struct msdosfsmount *pmp, u_lon
 	if (bop)
 		*bop = ofs % pmp-pm_fatblocksize;
 
-	pm_fatblocksize =  pmp-pm_fatblocksize;
+	pm_fatblocksize = pmp-pm_fatblocksize;
 }
 
 /*
@@ -299,6 +301,8 @@ pcbmap(struct denode *dep, u_long findcn
 			cn = getushort((char *)bp-b_data + bo);
 		if (FAT12(pmp)  (prevcn  1))
 			cn = 4;
+		DPRINTF((%s(cn=%lu masked=%lu)\n, __func__, cn,
+		cn  pmp-pm_fatmask));
 		cn = pmp-pm_fatmask;
 	}
 



CVS commit: src/sys/fs/msdosfs

2013-01-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 26 16:51:51 UTC 2013

Modified Files:
src/sys/fs/msdosfs: denode.h msdosfs_conv.c msdosfs_fat.c
msdosfs_lookup.c msdosfsmount.h

Log Message:
more cross-compile friendly.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/fs/msdosfs/denode.h
cvs rdiff -u -r1.8 -r1.9 src/sys/fs/msdosfs/msdosfs_conv.c
cvs rdiff -u -r1.24 -r1.25 src/sys/fs/msdosfs/msdosfs_fat.c
cvs rdiff -u -r1.28 -r1.29 src/sys/fs/msdosfs/msdosfs_lookup.c
cvs rdiff -u -r1.18 -r1.19 src/sys/fs/msdosfs/msdosfsmount.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/denode.h
diff -u src/sys/fs/msdosfs/denode.h:1.21 src/sys/fs/msdosfs/denode.h:1.22
--- src/sys/fs/msdosfs/denode.h:1.21	Fri Jan 25 19:21:49 2013
+++ src/sys/fs/msdosfs/denode.h	Sat Jan 26 11:51:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: denode.h,v 1.21 2013/01/26 00:21:49 christos Exp $	*/
+/*	$NetBSD: denode.h,v 1.22 2013/01/26 16:51:51 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -49,7 +49,15 @@
 #ifndef _MSDOSFS_DENODE_H_
 #define _MSDOSFS_DENODE_H_
 
+#ifdef _KERNEL
 #include miscfs/genfs/genfs_node.h
+#else
+struct genfs_node {
+};
+struct vnode;
+struct msdosfsmount;
+struct buf;
+#endif
 
 /*
  * This is the pc filesystem specific portion of the vnode structure.
@@ -289,13 +297,14 @@ int	msdosfs_pathconf	(void *);
  */
 struct componentname;
 struct direntry;
+struct kauth_cred;
 int msdosfs_update(struct vnode *, const struct timespec *,
 	const struct timespec *, int);
 int createde(struct denode *, struct denode *,
 		struct denode **, struct componentname *);
-int deextend(struct denode *, u_long, kauth_cred_t);
+int deextend(struct denode *, u_long, struct kauth_cred *);
 int deget(struct msdosfsmount *, u_long, u_long, struct denode **);
-int detrunc(struct denode *, u_long, int, kauth_cred_t);
+int detrunc(struct denode *, u_long, int, struct kauth_cred *);
 int deupdat(struct denode *, int);
 int doscheckpath(struct denode *, struct denode *);
 int dosdirempty(struct denode *);
@@ -306,7 +315,7 @@ void reinsert(struct denode *);
 int removede(struct denode *, struct denode *);
 int uniqdosname(struct denode *, struct componentname *, u_char *);
 int findwin95(struct denode *);
-int msdosfs_gop_alloc(struct vnode *, off_t, off_t, int, kauth_cred_t);
+int msdosfs_gop_alloc(struct vnode *, off_t, off_t, int, struct kauth_cred *);
 void msdosfs_gop_markupdate(struct vnode *, int);
 void msdosfs_detimes(struct denode *, const struct timespec *,
 const struct timespec *, const struct timespec *, int);

Index: src/sys/fs/msdosfs/msdosfs_conv.c
diff -u src/sys/fs/msdosfs/msdosfs_conv.c:1.8 src/sys/fs/msdosfs/msdosfs_conv.c:1.9
--- src/sys/fs/msdosfs/msdosfs_conv.c:1.8	Fri Jan 25 19:21:49 2013
+++ src/sys/fs/msdosfs/msdosfs_conv.c	Sat Jan 26 11:51:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_conv.c,v 1.8 2013/01/26 00:21:49 christos Exp $	*/
+/*	$NetBSD: msdosfs_conv.c,v 1.9 2013/01/26 16:51:51 christos Exp $	*/
 
 /*-
  * Copyright (C) 1995, 1997 Wolfgang Solfrank.
@@ -52,19 +52,22 @@
 #endif
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_conv.c,v 1.8 2013/01/26 00:21:49 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_conv.c,v 1.9 2013/01/26 16:51:51 christos Exp $);
 
 /*
  * System include files.
  */
 #include sys/param.h
-#include sys/systm.h
 #include sys/time.h
-#include sys/kernel.h
+#ifdef _KERNEL
 #include sys/dirent.h
+#include sys/systm.h
+#include sys/kernel.h
 #include sys/vnode.h
-#ifndef _KERNEL
+#else
 #include stdio.h
+#include dirent.h
+#include sys/queue.h
 #endif
 
 /*
@@ -722,7 +725,9 @@ win2unixfn(struct winentry *wep, struct 
 		/*
 		 * This works even though d_namlen is one byte!
 		 */
+#ifdef __NetBSD__
 		dp-d_namlen = (wep-weCntWIN_CNT) * WIN_CHARS;
+#endif
 	} else if (chksum != wep-weChksum)
 		chksum = -1;
 	if (chksum == -1)
@@ -740,8 +745,10 @@ win2unixfn(struct winentry *wep, struct 
 	for (cp = wep-wePart1, i = sizeof(wep-wePart1)/2; --i = 0;) {
 		switch (*np++ = *cp++) {
 		case 0:
+#ifdef __NetBSD__
 			dp-d_namlen -= sizeof(wep-wePart2)/2
 			+ sizeof(wep-wePart3)/2 + i + 1;
+#endif
 			return chksum;
 		case '/':
 			np[-1] = 0;
@@ -762,7 +769,9 @@ win2unixfn(struct winentry *wep, struct 
 	for (cp = wep-wePart2, i = sizeof(wep-wePart2)/2; --i = 0;) {
 		switch (*np++ = *cp++) {
 		case 0:
+#ifdef __NetBSD__
 			dp-d_namlen -= sizeof(wep-wePart3)/2 + i + 1;
+#endif
 			return chksum;
 		case '/':
 			np[-1] = 0;
@@ -783,7 +792,9 @@ win2unixfn(struct winentry *wep, struct 
 	for (cp = wep-wePart3, i = sizeof(wep-wePart3)/2; --i = 0;) {
 		switch (*np++ = *cp++) {
 		case 0:
+#ifdef __NetBSD__
 			dp-d_namlen -= i + 1;
+#endif
 			return chksum;
 		case '/':
 			np[-1] = 0;

Index: src/sys/fs/msdosfs/msdosfs_fat.c
diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.24 

CVS commit: src/sys/fs/msdosfs

2013-01-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 26 00:21:49 UTC 2013

Modified Files:
src/sys/fs/msdosfs: denode.h direntry.h fat.h msdosfs_conv.c
msdosfs_fat.c msdosfs_lookup.c msdosfsmount.h

Log Message:
expose more stuff if MAKEFS is defined for the headers, and arrange for
the source file to be compilable from userland.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/fs/msdosfs/denode.h
cvs rdiff -u -r1.5 -r1.6 src/sys/fs/msdosfs/direntry.h
cvs rdiff -u -r1.7 -r1.8 src/sys/fs/msdosfs/fat.h \
src/sys/fs/msdosfs/msdosfs_conv.c
cvs rdiff -u -r1.23 -r1.24 src/sys/fs/msdosfs/msdosfs_fat.c
cvs rdiff -u -r1.27 -r1.28 src/sys/fs/msdosfs/msdosfs_lookup.c
cvs rdiff -u -r1.17 -r1.18 src/sys/fs/msdosfs/msdosfsmount.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/denode.h
diff -u src/sys/fs/msdosfs/denode.h:1.20 src/sys/fs/msdosfs/denode.h:1.21
--- src/sys/fs/msdosfs/denode.h:1.20	Sun Nov  4 12:57:59 2012
+++ src/sys/fs/msdosfs/denode.h	Fri Jan 25 19:21:49 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: denode.h,v 1.20 2012/11/04 17:57:59 jakllsch Exp $	*/
+/*	$NetBSD: denode.h,v 1.21 2013/01/26 00:21:49 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -231,7 +231,7 @@ struct denode {
 #define	de_forw		de_chain[0]
 #define	de_back		de_chain[1]
 
-#ifdef _KERNEL
+#if defined(_KERNEL) || defined(MAKEFS)
 
 #define	VTODE(vp)	((struct denode *)(vp)-v_data)
 #define	DETOV(de)	((de)-de_vnode)
@@ -287,6 +287,8 @@ int	msdosfs_pathconf	(void *);
 /*
  * Internal service routine prototypes.
  */
+struct componentname;
+struct direntry;
 int msdosfs_update(struct vnode *, const struct timespec *,
 	const struct timespec *, int);
 int createde(struct denode *, struct denode *,
@@ -312,5 +314,5 @@ int msdosfs_fh_enter(struct msdosfsmount
 int msdosfs_fh_remove(struct msdosfsmount *, uint32_t, uint32_t);
 int msdosfs_fh_lookup(struct msdosfsmount *, uint32_t, uint32_t, uint32_t *);
 void msdosfs_fh_destroy(struct msdosfsmount *);
-#endif	/* _KERNEL */
+#endif	/* _KERNEL || MAKEFS */
 #endif /* _MSDOSFS_DENODE_H_ */

Index: src/sys/fs/msdosfs/direntry.h
diff -u src/sys/fs/msdosfs/direntry.h:1.5 src/sys/fs/msdosfs/direntry.h:1.6
--- src/sys/fs/msdosfs/direntry.h:1.5	Sat Dec  3 12:34:43 2005
+++ src/sys/fs/msdosfs/direntry.h	Fri Jan 25 19:21:49 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: direntry.h,v 1.5 2005/12/03 17:34:43 christos Exp $	*/
+/*	$NetBSD: direntry.h,v 1.6 2013/01/26 00:21:49 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -120,7 +120,8 @@ struct winentry {
 #define DD_YEAR_MASK		0xFE00	/* year - 1980 */
 #define DD_YEAR_SHIFT		9
 
-#ifdef _KERNEL
+#if defined(_KERNEL) || defined(MAKEFS)
+struct dirent;
 void	unix2dostime(const struct timespec *tsp, int gmtoff, u_int16_t *ddp,
 	u_int16_t *dtp, u_int8_t *dhp);
 void	dos2unixtime(u_int dd, u_int dt, u_int dh, int gmtoff,
@@ -135,5 +136,5 @@ int	winChkName(const u_char *un, int unl
 int	win2unixfn(struct winentry *wep, struct dirent *dp, int chksum);
 u_int8_t winChksum(u_int8_t *name);
 int	winSlotCnt(const u_char *un, int unlen);
-#endif	/* _KERNEL */
+#endif /* _KERNEL || MAKEFS */
 #endif /* _MSDOSFS_DIRENTRY_H_ */

Index: src/sys/fs/msdosfs/fat.h
diff -u src/sys/fs/msdosfs/fat.h:1.7 src/sys/fs/msdosfs/fat.h:1.8
--- src/sys/fs/msdosfs/fat.h:1.7	Sun Nov  4 12:57:59 2012
+++ src/sys/fs/msdosfs/fat.h	Fri Jan 25 19:21:49 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: fat.h,v 1.7 2012/11/04 17:57:59 jakllsch Exp $	*/
+/*	$NetBSD: fat.h,v 1.8 2013/01/26 00:21:49 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1997 Wolfgang Solfrank.
@@ -92,7 +92,7 @@
 #define	MSDOSFSEOF(cn, fatmask)	\
 	(((cn)  CLUST_EOFS) == (CLUST_EOFS  (fatmask)))
 
-#ifdef _KERNEL
+#if defined(_KERNEL) || defined(MAKEFS)
 /*
  * These are the values for the function argument to the function
  * fatentry().
@@ -115,5 +115,5 @@ void fc_purge(struct denode *, u_int);
 void fc_lookup(struct denode *, u_long, u_long *, u_long *);
 int fillinusemap(struct msdosfsmount *);
 int freeclusterchain(struct msdosfsmount *, u_long);
-#endif	/* _KERNEL */
+#endif /* _KERNEL || MAKEFS */
 #endif /* _MSDOSFS_FAT_H_ */
Index: src/sys/fs/msdosfs/msdosfs_conv.c
diff -u src/sys/fs/msdosfs/msdosfs_conv.c:1.7 src/sys/fs/msdosfs/msdosfs_conv.c:1.8
--- src/sys/fs/msdosfs/msdosfs_conv.c:1.7	Sun Mar 15 13:15:57 2009
+++ src/sys/fs/msdosfs/msdosfs_conv.c	Fri Jan 25 19:21:49 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_conv.c,v 1.7 2009/03/15 17:15:57 cegger Exp $	*/
+/*	$NetBSD: msdosfs_conv.c,v 1.8 2013/01/26 00:21:49 christos Exp $	*/
 
 /*-
  * Copyright (C) 1995, 1997 Wolfgang Solfrank.
@@ -47,8 +47,12 @@
  * October 1992
  */
 
+#if HAVE_NBTOOL_CONFIG_H
+#include nbtool_config.h
+#endif
+
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_conv.c,v 1.7 2009/03/15 17:15:57 cegger Exp $);

CVS commit: src/sys/fs/msdosfs

2012-12-28 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Dec 28 08:04:00 UTC 2012

Modified Files:
src/sys/fs/msdosfs: msdosfs_vnops.c

Log Message:
Move the initialization of n to after the error branch.

From Taylor R Campbell riastr...@netbsd.org


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/fs/msdosfs/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vnops.c
diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.84 src/sys/fs/msdosfs/msdosfs_vnops.c:1.85
--- src/sys/fs/msdosfs/msdosfs_vnops.c:1.84	Thu Dec 20 08:03:42 2012
+++ src/sys/fs/msdosfs/msdosfs_vnops.c	Fri Dec 28 08:03:59 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.84 2012/12/20 08:03:42 hannken Exp $	*/
+/*	$NetBSD: msdosfs_vnops.c,v 1.85 2012/12/28 08:03:59 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.84 2012/12/20 08:03:42 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.85 2012/12/28 08:03:59 hannken Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -525,10 +525,10 @@ msdosfs_read(void *v)
 		 */
 		error = bread(pmp-pm_devvp, de_bn2kb(pmp, lbn), blsize,
 		NOCRED, 0, bp);
-		n = MIN(n, pmp-pm_bpcluster - bp-b_resid);
 		if (error) {
 			goto bad;
 		}
+		n = MIN(n, pmp-pm_bpcluster - bp-b_resid);
 		error = uiomove((char *)bp-b_data + on, (int) n, uio);
 		brelse(bp, 0);
 	} while (error == 0  uio-uio_resid  0  n != 0);



CVS commit: src/sys/fs/msdosfs

2012-12-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Dec 20 11:44:39 UTC 2012

Modified Files:
src/sys/fs/msdosfs: msdosfs_fat.c

Log Message:
Revert rev. 1.20 now that bread() has been fixed.

PR kern/46282 (6.0_BETA crash: msdosfs_bmap - pcbmap - bread - bio_doread)


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/fs/msdosfs/msdosfs_fat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_fat.c
diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.22 src/sys/fs/msdosfs/msdosfs_fat.c:1.23
--- src/sys/fs/msdosfs/msdosfs_fat.c:1.22	Thu Dec 20 08:03:42 2012
+++ src/sys/fs/msdosfs/msdosfs_fat.c	Thu Dec 20 11:44:39 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_fat.c,v 1.22 2012/12/20 08:03:42 hannken Exp $	*/
+/*	$NetBSD: msdosfs_fat.c,v 1.23 2012/12/20 11:44:39 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.22 2012/12/20 08:03:42 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.23 2012/12/20 11:44:39 hannken Exp $);
 
 /*
  * kernel include files.
@@ -254,26 +254,10 @@ pcbmap(struct denode *dep, u_long findcn
 		if (bn != bp_bn) {
 			if (bp)
 brelse(bp, 0);
-			bp = getblk(pmp-pm_devvp, de_bn2kb(pmp, bn), bsize,
-			0, 0);
-			if (bp == NULL) {
-/*
- * getblk() above returns NULL only iff we are
- * pagedaemon.  See the implementation of getblk
- * for detail.
- */
-return ENOMEM;
-			}
-			if (!ISSET(bp-b_oflags, (BO_DONE | BO_DELWRI))) {
-SET(bp-b_flags, B_READ);
-BIO_SETPRIO(bp, BPRIO_TIMECRITICAL);
-VOP_STRATEGY(pmp-pm_devvp, bp);
-curlwp-l_ru.ru_inblock++;
-error = biowait(bp);
-if (error) {
-	brelse(bp, 0);
-	return error;
-}
+			error = bread(pmp-pm_devvp, de_bn2kb(pmp, bn), bsize,
+			NOCRED, 0, bp);
+			if (error) {
+return (error);
 			}
 			bp_bn = bn;
 		}



CVS commit: src/sys/fs/msdosfs

2012-11-04 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Nov  4 17:16:37 UTC 2012

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
((u_long)-1) will not always be 0x, which is what we actually
want to test against to determine if the FSInfo block's next free
cluster suggestion is valid


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.97 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.98
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.97	Wed Oct  3 23:32:43 2012
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Sun Nov  4 17:16:37 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.97 2012/10/03 23:32:43 jakllsch Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.98 2012/11/04 17:16:37 jakllsch Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.97 2012/10/03 23:32:43 jakllsch Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.98 2012/11/04 17:16:37 jakllsch Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -763,7 +763,7 @@ msdosfs_mountfs(struct vnode *devvp, str
 	 * XXX
 	 */
 	if (pmp-pm_fsinfo) {
-		if (pmp-pm_nxtfree == (u_long)-1)
+		if (pmp-pm_nxtfree == 0xUL)
 			pmp-pm_fsinfo = 0;
 	}
 



CVS commit: src/sys/fs/msdosfs

2012-11-04 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Nov  4 17:18:56 UTC 2012

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
Check that the FSInfo block's next free cluster suggestion is actually
a cluster within the bounds of the volume too.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.98 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.99
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.98	Sun Nov  4 17:16:37 2012
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Sun Nov  4 17:18:56 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.98 2012/11/04 17:16:37 jakllsch Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.99 2012/11/04 17:18:56 jakllsch Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.98 2012/11/04 17:16:37 jakllsch Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.99 2012/11/04 17:18:56 jakllsch Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -763,7 +763,8 @@ msdosfs_mountfs(struct vnode *devvp, str
 	 * XXX
 	 */
 	if (pmp-pm_fsinfo) {
-		if (pmp-pm_nxtfree == 0xUL)
+		if ((pmp-pm_nxtfree == 0xUL) ||
+		(pmp-pm_nxtfree  pmp-pm_maxcluster))
 			pmp-pm_fsinfo = 0;
 	}
 



CVS commit: src/sys/fs/msdosfs

2012-11-04 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Nov  4 17:33:46 UTC 2012

Modified Files:
src/sys/fs/msdosfs: fat.h

Log Message:
Correct constant in comment to match the expression it is derived from.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/fs/msdosfs/fat.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/fat.h
diff -u src/sys/fs/msdosfs/fat.h:1.4 src/sys/fs/msdosfs/fat.h:1.5
--- src/sys/fs/msdosfs/fat.h:1.4	Sat Dec  3 17:34:43 2005
+++ src/sys/fs/msdosfs/fat.h	Sun Nov  4 17:33:46 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: fat.h,v 1.4 2005/12/03 17:34:43 christos Exp $	*/
+/*	$NetBSD: fat.h,v 1.5 2012/11/04 17:33:46 jakllsch Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1997 Wolfgang Solfrank.
@@ -70,7 +70,7 @@
  * MSDOSFS:
  * Return true if filesystem uses 12 bit fats. Microsoft Programmer's
  * Reference says if the maximum cluster number in a filesystem is greater
- * than 4078 ((CLUST_RSRVS - CLUST_FIRST)  FAT12_MASK) then we've got a
+ * than 4084 ((CLUST_RSRVS - CLUST_FIRST)  FAT12_MASK) then we've got a
  * 16 bit fat filesystem. While mounting, the result of this test is stored
  * in pm_fatentrysize.
  * GEMDOS-flavour (atari):



CVS commit: src/sys/fs/msdosfs

2012-11-04 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Nov  4 17:35:27 UTC 2012

Modified Files:
src/sys/fs/msdosfs: fat.h

Log Message:
And correct a typo that wasn't corrected in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/fs/msdosfs/fat.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/fat.h
diff -u src/sys/fs/msdosfs/fat.h:1.5 src/sys/fs/msdosfs/fat.h:1.6
--- src/sys/fs/msdosfs/fat.h:1.5	Sun Nov  4 17:33:46 2012
+++ src/sys/fs/msdosfs/fat.h	Sun Nov  4 17:35:27 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: fat.h,v 1.5 2012/11/04 17:33:46 jakllsch Exp $	*/
+/*	$NetBSD: fat.h,v 1.6 2012/11/04 17:35:27 jakllsch Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1997 Wolfgang Solfrank.
@@ -70,7 +70,7 @@
  * MSDOSFS:
  * Return true if filesystem uses 12 bit fats. Microsoft Programmer's
  * Reference says if the maximum cluster number in a filesystem is greater
- * than 4084 ((CLUST_RSRVS - CLUST_FIRST)  FAT12_MASK) then we've got a
+ * than 4084 ((CLUST_RSRVD - CLUST_FIRST)  FAT12_MASK) then we've got a
  * 16 bit fat filesystem. While mounting, the result of this test is stored
  * in pm_fatentrysize.
  * GEMDOS-flavour (atari):



CVS commit: src/sys/fs/msdosfs

2012-11-04 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Nov  4 17:57:59 UTC 2012

Modified Files:
src/sys/fs/msdosfs: bootsect.h bpb.h denode.h fat.h msdosfs_denode.c
msdosfs_fat.c msdosfs_vfsops.c msdosfsmount.h

Log Message:
Stylistic changes in comments/strings:
FAT and fat are different things, use the appropriate case.
GEMDOS is all caps.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/fs/msdosfs/bootsect.h
cvs rdiff -u -r1.6 -r1.7 src/sys/fs/msdosfs/bpb.h src/sys/fs/msdosfs/fat.h
cvs rdiff -u -r1.19 -r1.20 src/sys/fs/msdosfs/denode.h
cvs rdiff -u -r1.46 -r1.47 src/sys/fs/msdosfs/msdosfs_denode.c
cvs rdiff -u -r1.20 -r1.21 src/sys/fs/msdosfs/msdosfs_fat.c
cvs rdiff -u -r1.99 -r1.100 src/sys/fs/msdosfs/msdosfs_vfsops.c
cvs rdiff -u -r1.16 -r1.17 src/sys/fs/msdosfs/msdosfsmount.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/bootsect.h
diff -u src/sys/fs/msdosfs/bootsect.h:1.4 src/sys/fs/msdosfs/bootsect.h:1.5
--- src/sys/fs/msdosfs/bootsect.h:1.4	Mon Aug 14 14:06:26 2006
+++ src/sys/fs/msdosfs/bootsect.h	Sun Nov  4 17:57:59 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootsect.h,v 1.4 2006/08/14 14:06:26 gdt Exp $	*/
+/*	$NetBSD: bootsect.h,v 1.5 2012/11/04 17:57:59 jakllsch Exp $	*/
 
 /*
  * Written by Paul Popelka (pa...@uts.amdahl.com)
@@ -70,7 +70,7 @@ struct bootsector710 {
 };
 #ifdef	atari
 /*
- * The boot sector on a gemdos fs is a little bit different from the msdos fs
+ * The boot sector on a GEMDOS FS is a little bit different from the MSDOS FS
  * format. Currently there is no need to declare a separate structure, the
  * bootsector33 struct will do.
  */

Index: src/sys/fs/msdosfs/bpb.h
diff -u src/sys/fs/msdosfs/bpb.h:1.6 src/sys/fs/msdosfs/bpb.h:1.7
--- src/sys/fs/msdosfs/bpb.h:1.6	Sat Jan 27 07:18:10 2007
+++ src/sys/fs/msdosfs/bpb.h	Sun Nov  4 17:57:59 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpb.h,v 1.6 2007/01/27 07:18:10 cbiere Exp $	*/
+/*	$NetBSD: bpb.h,v 1.7 2012/11/04 17:57:59 jakllsch Exp $	*/
 
 /*
  * Written by Paul Popelka (pa...@uts.amdahl.com)
@@ -85,7 +85,7 @@ struct bpb710 {
 
 #ifdef	atari
 /*
- * BPB for gemdos filesystems. Atari leaves the obsolete stuff undefined.
+ * BPB for GEMDOS filesystems. Atari leaves the obsolete stuff undefined.
  * Currently there is no need for a separate BPB structure.
  */
 #if 0
@@ -96,7 +96,7 @@ struct bpb_a {
 	u_int8_t	bpbFATs;	/* number of FATs		*/
 	u_int16_t	bpbRootDirEnts;	/* number of root directory entries */
 	u_int16_t	bpbSectors;	/* total number of sectors	*/
-	u_int8_t	bpbUseless1;	/* meaningless on gemdos fs	*/
+	u_int8_t	bpbUseless1;	/* meaningless on GEMDOS FS	*/
 	u_int16_t	bpbFATsecs;	/* number of sectors per FAT	*/
 	u_int16_t	bpbUseless2;	/* meaningless for harddisk fs	*/
 	u_int16_t	bpbUseless3;	/* meaningless for harddisk fs	*/
Index: src/sys/fs/msdosfs/fat.h
diff -u src/sys/fs/msdosfs/fat.h:1.6 src/sys/fs/msdosfs/fat.h:1.7
--- src/sys/fs/msdosfs/fat.h:1.6	Sun Nov  4 17:35:27 2012
+++ src/sys/fs/msdosfs/fat.h	Sun Nov  4 17:57:59 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: fat.h,v 1.6 2012/11/04 17:35:27 jakllsch Exp $	*/
+/*	$NetBSD: fat.h,v 1.7 2012/11/04 17:57:59 jakllsch Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1997 Wolfgang Solfrank.
@@ -68,13 +68,13 @@
 
 /*
  * MSDOSFS:
- * Return true if filesystem uses 12 bit fats. Microsoft Programmer's
+ * Return true if filesystem uses 12 bit FATs. Microsoft Programmer's
  * Reference says if the maximum cluster number in a filesystem is greater
  * than 4084 ((CLUST_RSRVD - CLUST_FIRST)  FAT12_MASK) then we've got a
- * 16 bit fat filesystem. While mounting, the result of this test is stored
+ * 16 bit FAT filesystem. While mounting, the result of this test is stored
  * in pm_fatentrysize.
  * GEMDOS-flavour (atari):
- * If the filesystem is on floppy we've got a 12 bit fat filesystem, otherwise
+ * If the filesystem is on floppy we've got a 12 bit FAT filesystem, otherwise
  * 16 bit. We check the d_type field in the disklabel struct while mounting
  * and store the result in the pm_fatentrysize. Note that this kind of
  * detection gets flakey when mounting a vnd-device.
@@ -97,8 +97,8 @@
  * These are the values for the function argument to the function
  * fatentry().
  */
-#define	FAT_GET		0x0001	/* get a fat entry */
-#define	FAT_SET		0x0002	/* set a fat entry */
+#define	FAT_GET		0x0001	/* get a FAT entry */
+#define	FAT_SET		0x0002	/* set a FAT entry */
 #define	FAT_GET_AND_SET	(FAT_GET | FAT_SET)
 
 /*

Index: src/sys/fs/msdosfs/denode.h
diff -u src/sys/fs/msdosfs/denode.h:1.19 src/sys/fs/msdosfs/denode.h:1.20
--- src/sys/fs/msdosfs/denode.h:1.19	Mon Apr  4 19:16:58 2011
+++ src/sys/fs/msdosfs/denode.h	Sun Nov  4 17:57:59 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: denode.h,v 1.19 2011/04/04 19:16:58 hannken Exp $	*/
+/*	$NetBSD: denode.h,v 1.20 2012/11/04 17:57:59 jakllsch Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang 

CVS commit: src/sys/fs/msdosfs

2012-10-03 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Wed Oct  3 23:32:43 UTC 2012

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
We don't actually want to round the number of elements in the bitmap
down.  Fixes a self-inflicted buffer overrun.

(This was detected by chance that the top of the bitmap coincided with
a page boundary.)


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.96 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.97
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.96	Sat Jul  7 16:18:50 2012
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Wed Oct  3 23:32:43 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.96 2012/07/07 16:18:50 tsutsui Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.97 2012/10/03 23:32:43 jakllsch Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.96 2012/07/07 16:18:50 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.97 2012/10/03 23:32:43 jakllsch Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -771,7 +771,7 @@ msdosfs_mountfs(struct vnode *devvp, str
 	 * Allocate memory for the bitmap of allocated clusters, and then
 	 * fill it in.
 	 */
-	pmp-pm_inusemap = malloc(((pmp-pm_maxcluster + N_INUSEBITS - 1)
+	pmp-pm_inusemap = malloc(((pmp-pm_maxcluster + N_INUSEBITS)
    / N_INUSEBITS)
   * sizeof(*pmp-pm_inusemap),
   M_MSDOSFSFAT, M_WAITOK);



CVS commit: src/sys/fs/msdosfs

2012-07-07 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Jul  7 16:18:50 UTC 2012

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
Revert rev 1.95 since getdisksize() no longer returns secsize=0.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.95 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.96
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.95	Sat Jun 30 11:01:41 2012
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Sat Jul  7 16:18:50 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.95 2012/06/30 11:01:41 tsutsui Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.96 2012/07/07 16:18:50 tsutsui Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.95 2012/06/30 11:01:41 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.96 2012/07/07 16:18:50 tsutsui Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -493,7 +493,7 @@ msdosfs_mountfs(struct vnode *devvp, str
 		goto error_exit;
 
 	error = getdisksize(devvp, psize, secsize);
-	if (error || secsize == 0) {
+	if (error) {
 		if (argp-flags  MSDOSFSMNT_GEMDOSFS)
 			goto error_exit;
 



CVS commit: src/sys/fs/msdosfs

2012-06-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Jun 30 11:01:42 UTC 2012

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
Add a sanity check if secsize returned from getdisksize() isn't bogus.
This prevent possible panic panic: buf mem pool index 23 later in
vfs_bio.c:buf_mempoolidx().
(I'm not sure if it's okay for getdisksize() to assume that
 partinfo taken from DIOCGPART is properly initialized
 on all disk(9) devices or not)

See also:
http://mail-index.NetBSD.org/source-changes/2012/06/30/msg035298.html


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.94 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.95
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.94	Tue Mar 13 18:40:37 2012
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Sat Jun 30 11:01:41 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.94 2012/03/13 18:40:37 elad Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.95 2012/06/30 11:01:41 tsutsui Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.94 2012/03/13 18:40:37 elad Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.95 2012/06/30 11:01:41 tsutsui Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -493,7 +493,7 @@ msdosfs_mountfs(struct vnode *devvp, str
 		goto error_exit;
 
 	error = getdisksize(devvp, psize, secsize);
-	if (error) {
+	if (error || secsize == 0) {
 		if (argp-flags  MSDOSFSMNT_GEMDOSFS)
 			goto error_exit;
 



CVS commit: src/sys/fs/msdosfs

2012-04-09 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Apr  9 11:10:07 UTC 2012

Modified Files:
src/sys/fs/msdosfs: msdosfs_fat.c

Log Message:
pcbmap(): We cannot use bread() here as for the pagedaemon getblk()
  may fail leading to a panic in bread().
  Replace bread() with getblk() / VOP_STRATEGY() and return
  an error if getblk() fails.

Fixes PR#46282: 6.0_BETA crash: msdosfs_bmap - pcbmap - bread - bio_doread

This is an interim solution for easy pullup.  The final solution
is be to change bread() to not return a buffer on error.  As
we have to change all callers of bread() this will not qualify
for a pullup.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/fs/msdosfs/msdosfs_fat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_fat.c
diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.19 src/sys/fs/msdosfs/msdosfs_fat.c:1.20
--- src/sys/fs/msdosfs/msdosfs_fat.c:1.19	Tue Jan 26 20:25:52 2010
+++ src/sys/fs/msdosfs/msdosfs_fat.c	Mon Apr  9 11:10:06 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_fat.c,v 1.19 2010/01/26 20:25:52 joerg Exp $	*/
+/*	$NetBSD: msdosfs_fat.c,v 1.20 2012/04/09 11:10:06 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.19 2010/01/26 20:25:52 joerg Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.20 2012/04/09 11:10:06 hannken Exp $);
 
 /*
  * kernel include files.
@@ -254,11 +254,26 @@ pcbmap(struct denode *dep, u_long findcn
 		if (bn != bp_bn) {
 			if (bp)
 brelse(bp, 0);
-			error = bread(pmp-pm_devvp, de_bn2kb(pmp, bn), bsize,
-			NOCRED, 0, bp);
-			if (error) {
-brelse(bp, 0);
-return (error);
+			bp = getblk(pmp-pm_devvp, de_bn2kb(pmp, bn), bsize,
+			0, 0);
+			if (bp == NULL) {
+/*
+ * getblk() above returns NULL only iff we are
+ * pagedaemon.  See the implementation of getblk
+ * for detail.
+ */
+return ENOMEM;
+			}
+			if (!ISSET(bp-b_oflags, (BO_DONE | BO_DELWRI))) {
+SET(bp-b_flags, B_READ);
+BIO_SETPRIO(bp, BPRIO_TIMECRITICAL);
+VOP_STRATEGY(pmp-pm_devvp, bp);
+curlwp-l_ru.ru_inblock++;
+error = biowait(bp);
+if (error) {
+	brelse(bp, 0);
+	return error;
+}
 			}
 			bp_bn = bn;
 		}



CVS commit: src/sys/fs/msdosfs

2012-04-03 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Tue Apr  3 14:58:55 UTC 2012

Modified Files:
src/sys/fs/msdosfs: msdosfs_vnops.c

Log Message:
Add missing braces in previous commit.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/fs/msdosfs/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vnops.c
diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.81 src/sys/fs/msdosfs/msdosfs_vnops.c:1.82
--- src/sys/fs/msdosfs/msdosfs_vnops.c:1.81	Mon Apr  2 07:30:22 2012
+++ src/sys/fs/msdosfs/msdosfs_vnops.c	Tue Apr  3 14:58:55 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.81 2012/04/02 07:30:22 njoly Exp $	*/
+/*	$NetBSD: msdosfs_vnops.c,v 1.82 2012/04/03 14:58:55 njoly Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.81 2012/04/02 07:30:22 njoly Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.82 2012/04/03 14:58:55 njoly Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -306,9 +306,10 @@ msdosfs_getattr(void *v)
 		vap-va_ctime = vap-va_mtime;
 	}
 	vap-va_flags = 0;
-	if ((dep-de_Attributes  ATTR_ARCHIVE) == 0)
+	if ((dep-de_Attributes  ATTR_ARCHIVE) == 0) {
 		vap-va_flags |= SF_ARCHIVED;
 		vap-va_mode  |= S_ARCH1;
+	}
 	vap-va_gen = 0;
 	vap-va_blocksize = pmp-pm_bpcluster;
 	vap-va_bytes =



CVS commit: src/sys/fs/msdosfs

2012-04-02 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Mon Apr  2 07:30:22 UTC 2012

Modified Files:
src/sys/fs/msdosfs: msdosfs_vnops.c

Log Message:
Report the SF_ARCHIVED file flag if set.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/fs/msdosfs/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vnops.c
diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.80 src/sys/fs/msdosfs/msdosfs_vnops.c:1.81
--- src/sys/fs/msdosfs/msdosfs_vnops.c:1.80	Tue Mar 13 18:40:38 2012
+++ src/sys/fs/msdosfs/msdosfs_vnops.c	Mon Apr  2 07:30:22 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.80 2012/03/13 18:40:38 elad Exp $	*/
+/*	$NetBSD: msdosfs_vnops.c,v 1.81 2012/04/02 07:30:22 njoly Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.80 2012/03/13 18:40:38 elad Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.81 2012/04/02 07:30:22 njoly Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -307,6 +307,7 @@ msdosfs_getattr(void *v)
 	}
 	vap-va_flags = 0;
 	if ((dep-de_Attributes  ATTR_ARCHIVE) == 0)
+		vap-va_flags |= SF_ARCHIVED;
 		vap-va_mode  |= S_ARCH1;
 	vap-va_gen = 0;
 	vap-va_blocksize = pmp-pm_bpcluster;



CVS commit: src/sys/fs/msdosfs

2012-02-02 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Feb  3 04:29:17 UTC 2012

Modified Files:
src/sys/fs/msdosfs: msdosfsmount.h

Log Message:
Only use MALLOC_DECLARE if it exists. Helps with the dirty _KERNEL
tricks fstat is using.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/fs/msdosfs/msdosfsmount.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfsmount.h
diff -u src/sys/fs/msdosfs/msdosfsmount.h:1.15 src/sys/fs/msdosfs/msdosfsmount.h:1.16
--- src/sys/fs/msdosfs/msdosfsmount.h:1.15	Sat Jun 28 01:34:05 2008
+++ src/sys/fs/msdosfs/msdosfsmount.h	Fri Feb  3 04:29:17 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfsmount.h,v 1.15 2008/06/28 01:34:05 rumble Exp $	*/
+/*	$NetBSD: msdosfsmount.h,v 1.16 2012/02/03 04:29:17 joerg Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -92,8 +92,10 @@ struct msdosfs_args {
 
 #ifdef _KERNEL
 #include sys/mallocvar.h
+#ifdef MALLOC_DECLARE
 MALLOC_DECLARE(M_MSDOSFSMNT);
 MALLOC_DECLARE(M_MSDOSFSTMP);
+#endif
 
 /*
  * Layout of the mount control block for a msdos file system.



CVS commit: src/sys/fs/msdosfs

2011-11-21 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Nov 21 10:46:57 UTC 2011

Modified Files:
src/sys/fs/msdosfs: msdosfs_vnops.c

Log Message:
Add missing fstrans_done().

Should fix PR #45635 (KASSERT fli-fli_trans_cnt == 0 failed)


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/fs/msdosfs/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vnops.c
diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.78 src/sys/fs/msdosfs/msdosfs_vnops.c:1.79
--- src/sys/fs/msdosfs/msdosfs_vnops.c:1.78	Wed Jul 20 11:52:00 2011
+++ src/sys/fs/msdosfs/msdosfs_vnops.c	Mon Nov 21 10:46:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.78 2011/07/20 11:52:00 hannken Exp $	*/
+/*	$NetBSD: msdosfs_vnops.c,v 1.79 2011/11/21 10:46:56 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.78 2011/07/20 11:52:00 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.79 2011/11/21 10:46:56 hannken Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -499,8 +499,10 @@ msdosfs_read(void *v)
 		lbn = de_cluster(pmp, uio-uio_offset);
 		on = uio-uio_offset  pmp-pm_crbomask;
 		n = MIN(pmp-pm_bpcluster - on, uio-uio_resid);
-		if (uio-uio_offset = dep-de_FileSize)
+		if (uio-uio_offset = dep-de_FileSize) {
+			fstrans_done(vp-v_mount);
 			return (0);
+		}
 		/* file size (and hence diff) may be up to 4GB */
 		diff = dep-de_FileSize - uio-uio_offset;
 		if (diff  n)



CVS commit: src/sys/fs/msdosfs

2011-03-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Mar 22 20:33:51 UTC 2011

Modified Files:
src/sys/fs/msdosfs: msdosfs_denode.c

Log Message:
When truncating a file purge the fat cache after setting the new size
and after all io but before actually updating the cluster chain.

Both uvm_vnp_zerorange() and vtruncbuf() call get/putpages - bmap - pcbmap
and here the fat cache gets updated with information no longer valid after
truncation.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/fs/msdosfs/msdosfs_denode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_denode.c
diff -u src/sys/fs/msdosfs/msdosfs_denode.c:1.41 src/sys/fs/msdosfs/msdosfs_denode.c:1.42
--- src/sys/fs/msdosfs/msdosfs_denode.c:1.41	Sun Mar 20 12:21:28 2011
+++ src/sys/fs/msdosfs/msdosfs_denode.c	Tue Mar 22 20:33:51 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_denode.c,v 1.41 2011/03/20 12:21:28 hannken Exp $	*/
+/*	$NetBSD: msdosfs_denode.c,v 1.42 2011/03/22 20:33:51 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.41 2011/03/20 12:21:28 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.42 2011/03/22 20:33:51 hannken Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -461,8 +461,6 @@
 		}
 	}
 
-	fc_purge(dep, lastblock + 1);
-
 	/*
 	 * If the new length is not a multiple of the cluster size then we
 	 * must zero the tail end of the new last cluster in case it
@@ -506,6 +504,8 @@
 	   allerror, eofentry);
 #endif
 
+	fc_purge(dep, lastblock + 1);
+
 	/*
 	 * If we need to break the cluster chain for the file then do it
 	 * now.



CVS commit: src/sys/fs/msdosfs

2011-03-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Mar 20 12:21:28 UTC 2011

Modified Files:
src/sys/fs/msdosfs: msdosfs_denode.c msdosfs_vnops.c

Log Message:
When extending a file, either by truncating or by writing past EOF make
sure the unallocated remainder of the last page gets zeroed.

Detected by fsx.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/fs/msdosfs/msdosfs_denode.c
cvs rdiff -u -r1.73 -r1.74 src/sys/fs/msdosfs/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_denode.c
diff -u src/sys/fs/msdosfs/msdosfs_denode.c:1.40 src/sys/fs/msdosfs/msdosfs_denode.c:1.41
--- src/sys/fs/msdosfs/msdosfs_denode.c:1.40	Wed Jul 21 17:52:10 2010
+++ src/sys/fs/msdosfs/msdosfs_denode.c	Sun Mar 20 12:21:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_denode.c,v 1.40 2010/07/21 17:52:10 hannken Exp $	*/
+/*	$NetBSD: msdosfs_denode.c,v 1.41 2011/03/20 12:21:28 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.40 2010/07/21 17:52:10 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.41 2011/03/20 12:21:28 hannken Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -583,7 +583,7 @@
 	uvm_vnp_setwritesize(DETOV(dep), (voff_t)dep-de_FileSize);
 	dep-de_flag |= DE_UPDATE|DE_MODIFIED;
 	uvm_vnp_zerorange(DETOV(dep), (off_t)osize,
-	(size_t)(dep-de_FileSize - osize));
+	(size_t)(round_page(dep-de_FileSize) - osize));
 	uvm_vnp_setsize(DETOV(dep), (voff_t)dep-de_FileSize);
 	return (deupdat(dep, 1));
 }

Index: src/sys/fs/msdosfs/msdosfs_vnops.c
diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.73 src/sys/fs/msdosfs/msdosfs_vnops.c:1.74
--- src/sys/fs/msdosfs/msdosfs_vnops.c:1.73	Sat Mar 19 20:05:21 2011
+++ src/sys/fs/msdosfs/msdosfs_vnops.c	Sun Mar 20 12:21:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.73 2011/03/19 20:05:21 hannken Exp $	*/
+/*	$NetBSD: msdosfs_vnops.c,v 1.74 2011/03/20 12:21:28 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.73 2011/03/19 20:05:21 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.74 2011/03/20 12:21:28 hannken Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -554,6 +554,7 @@
 	u_long count;
 	vsize_t bytelen;
 	off_t oldoff;
+	size_t rem;
 	struct uio *uio = ap-a_uio;
 	struct vnode *vp = ap-a_vp;
 	struct denode *dep = VTODE(vp);
@@ -623,6 +624,10 @@
 		dep-de_FileSize = uio-uio_offset + resid;
 		/* hint uvm to not read in extended part */
 		uvm_vnp_setwritesize(vp, dep-de_FileSize);
+		/* zero out the remainder of the last page */
+		rem = round_page(dep-de_FileSize) - dep-de_FileSize;
+		if (rem  0)
+			uvm_vnp_zerorange(vp, (off_t)dep-de_FileSize, rem);
 		extended = 1;
 	}
 



CVS commit: src/sys/fs/msdosfs

2011-03-03 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar  3 08:10:45 UTC 2011

Modified Files:
src/sys/fs/msdosfs: msdosfs_vnops.c

Log Message:
In rename, use char[12]�for new names instead of [11].  At least
one routine called from here (unix2dosfn) expects and uses all of
a [12].

This may fix the stack size exceeded problem which has been
triggering in gson's test runs.  (i'm not entirely sure why it
doesn't trigger in anyone else's env)


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/fs/msdosfs/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vnops.c
diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.71 src/sys/fs/msdosfs/msdosfs_vnops.c:1.72
--- src/sys/fs/msdosfs/msdosfs_vnops.c:1.71	Sun Jan  2 05:09:30 2011
+++ src/sys/fs/msdosfs/msdosfs_vnops.c	Thu Mar  3 08:10:45 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.71 2011/01/02 05:09:30 dholland Exp $	*/
+/*	$NetBSD: msdosfs_vnops.c,v 1.72 2011/03/03 08:10:45 pooka Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.71 2011/01/02 05:09:30 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.72 2011/03/03 08:10:45 pooka Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -819,7 +819,7 @@
 	struct componentname *tcnp = ap-a_tcnp;
 	struct componentname *fcnp = ap-a_fcnp;
 	struct denode *ip, *xp, *dp, *zp;
-	u_char toname[11], oldname[11];
+	u_char toname[12], oldname[12];
 	u_long from_diroffset, to_diroffset;
 	u_char to_count;
 	int doingdirectory = 0, newparent = 0;



CVS commit: src/sys/fs/msdosfs

2010-12-14 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Dec 14 17:17:03 UTC 2010

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
msdosfs_sync: check for dead vnode (denode == NULL) before testing denode flags.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.87 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.88
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.87	Wed Jul 21 17:52:10 2010
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Tue Dec 14 17:17:02 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.87 2010/07/21 17:52:10 hannken Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.88 2010/12/14 17:17:02 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.87 2010/07/21 17:52:10 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.88 2010/12/14 17:17:02 hannken Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -977,7 +977,7 @@
 		mutex_enter(vp-v_interlock);
 		dep = VTODE(vp);
 		if (waitfor == MNT_LAZY || vp-v_type == VNON ||
-		(((dep-de_flag 
+		dep == NULL || (((dep-de_flag 
 		(DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED)) == 0) 
 		 (LIST_EMPTY(vp-v_dirtyblkhd) 
 		  UVM_OBJ_IS_CLEAN(vp-v_uobj {



CVS commit: src/sys/fs/msdosfs

2010-07-30 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Jul 30 16:40:43 UTC 2010

Modified Files:
src/sys/fs/msdosfs: msdosfs_lookup.c

Log Message:
Return EINVAL for rename and delete operations to the
root directory instead of the erroneous EROFS.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/fs/msdosfs/msdosfs_lookup.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_lookup.c
diff -u src/sys/fs/msdosfs/msdosfs_lookup.c:1.21 src/sys/fs/msdosfs/msdosfs_lookup.c:1.22
--- src/sys/fs/msdosfs/msdosfs_lookup.c:1.21	Thu Jun 24 13:03:09 2010
+++ src/sys/fs/msdosfs/msdosfs_lookup.c	Fri Jul 30 16:40:43 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_lookup.c,v 1.21 2010/06/24 13:03:09 hannken Exp $	*/
+/*	$NetBSD: msdosfs_lookup.c,v 1.22 2010/07/30 16:40:43 mlelstv Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_lookup.c,v 1.21 2010/06/24 13:03:09 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_lookup.c,v 1.22 2010/07/30 16:40:43 mlelstv Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -461,7 +461,7 @@
 		 * Don't allow deleting the root.
 		 */
 		if (blkoff == MSDOSFSROOT_OFS)
-			return EROFS;			/* really? XXX */
+			return EINVAL;
 
 		/*
 		 * Write access to directory required to delete files.
@@ -497,7 +497,7 @@
 			return (EROFS);
 
 		if (blkoff == MSDOSFSROOT_OFS)
-			return EROFS;/* really? XXX */
+			return EINVAL;
 
 		error = VOP_ACCESS(vdp, VWRITE, cnp-cn_cred);
 		if (error)



CVS commit: src/sys/fs/msdosfs

2010-07-22 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Thu Jul 22 18:08:12 UTC 2010

Modified Files:
src/sys/fs/msdosfs: msdosfs_vnops.c

Log Message:
Remove bad cast, fix compilation with MSDOSFS_DEBUG.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/fs/msdosfs/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vnops.c
diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.67 src/sys/fs/msdosfs/msdosfs_vnops.c:1.68
--- src/sys/fs/msdosfs/msdosfs_vnops.c:1.67	Thu Jun 24 13:03:09 2010
+++ src/sys/fs/msdosfs/msdosfs_vnops.c	Thu Jul 22 18:08:11 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.67 2010/06/24 13:03:09 hannken Exp $	*/
+/*	$NetBSD: msdosfs_vnops.c,v 1.68 2010/07/22 18:08:11 njoly Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.67 2010/06/24 13:03:09 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.68 2010/07/22 18:08:11 njoly Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -358,7 +358,7 @@
 		vap-va_type, vap-va_nlink, vap-va_fsid,
 		(unsigned long long)vap-va_fileid);
 		printf(va_blocksize %lx, va_rdev %PRIx64, va_bytes %PRIx64, va_gen %lx\n,
-		vap-va_blocksize, vap-va_rdev, (long long)vap-va_bytes, vap-va_gen);
+		vap-va_blocksize, vap-va_rdev, vap-va_bytes, vap-va_gen);
 #endif
 		return (EINVAL);
 	}



CVS commit: src/sys/fs/msdosfs

2010-05-25 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue May 25 10:15:34 UTC 2010

Modified Files:
src/sys/fs/msdosfs: msdosfs_vnops.c

Log Message:
Don't double unlock fvp if source file disappears during rename.
Problem found by njoly's awesome stresstester.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/fs/msdosfs/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vnops.c
diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.65 src/sys/fs/msdosfs/msdosfs_vnops.c:1.66
--- src/sys/fs/msdosfs/msdosfs_vnops.c:1.65	Fri Apr 23 15:38:46 2010
+++ src/sys/fs/msdosfs/msdosfs_vnops.c	Tue May 25 10:15:34 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.65 2010/04/23 15:38:46 pooka Exp $	*/
+/*	$NetBSD: msdosfs_vnops.c,v 1.66 2010/05/25 10:15:34 pooka Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.65 2010/04/23 15:38:46 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.66 2010/05/25 10:15:34 pooka Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -1059,7 +1059,6 @@
 		if (doingdirectory)
 			panic(rename: lost dir entry);
 		vrele(ap-a_fvp);
-		VOP_UNLOCK(fvp, 0);
 		xp = NULL;
 	} else {
 		vrele(fvp);



CVS commit: src/sys/fs/msdosfs

2010-04-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Apr 13 10:11:08 UTC 2010

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
If getdisksize() fails (happens e.g. on fss block devices), don't
give up if we don't really need the information provided by it.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.83 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.84
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.83	Sun Apr 11 10:26:25 2010
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Tue Apr 13 10:11:08 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.83 2010/04/11 10:26:25 mlelstv Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.84 2010/04/13 10:11:08 pooka Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.83 2010/04/11 10:26:25 mlelstv Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.84 2010/04/13 10:11:08 pooka Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -489,8 +489,12 @@
 		goto error_exit;
 
 	error = getdisksize(devvp, psize, secsize);
-	if (error)
-		goto error_exit;
+	if (error) {
+		if (argp-flags  MSDOSFSMNT_GEMDOSFS)
+			goto error_exit;
+		secsize = DEV_BSIZE;
+		psize = 0;
+	}
 
 	if (argp-flags  MSDOSFSMNT_GEMDOSFS) {
 		bsize = secsize;



CVS commit: src/sys/fs/msdosfs

2010-04-08 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Apr  8 15:03:34 UTC 2010

Modified Files:
src/sys/fs/msdosfs: denode.h msdosfs_vnops.c

Log Message:
Use genfs instead of homegrown stuff where possible.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/fs/msdosfs/denode.h
cvs rdiff -u -r1.61 -r1.62 src/sys/fs/msdosfs/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/denode.h
diff -u src/sys/fs/msdosfs/denode.h:1.16 src/sys/fs/msdosfs/denode.h:1.17
--- src/sys/fs/msdosfs/denode.h:1.16	Mon Nov 26 19:01:46 2007
+++ src/sys/fs/msdosfs/denode.h	Thu Apr  8 15:03:33 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: denode.h,v 1.16 2007/11/26 19:01:46 pooka Exp $	*/
+/*	$NetBSD: denode.h,v 1.17 2010/04/08 15:03:33 pooka Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -260,7 +260,6 @@
 int	msdosfs_lookup		(void *);
 int	msdosfs_create		(void *);
 int	msdosfs_mknod		(void *);
-int	msdosfs_open		(void *);
 int	msdosfs_close		(void *);
 int	msdosfs_access		(void *);
 int	msdosfs_getattr		(void *);
@@ -281,7 +280,6 @@
 int	msdosfs_rmdir		(void *);
 int	msdosfs_symlink		(void *);
 int	msdosfs_readdir		(void *);
-int	msdosfs_readlink	(void *);
 #define	msdosfs_abortop		genfs_abortop
 int	msdosfs_inactive	(void *);
 int	msdosfs_reclaim		(void *);

Index: src/sys/fs/msdosfs/msdosfs_vnops.c
diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.61 src/sys/fs/msdosfs/msdosfs_vnops.c:1.62
--- src/sys/fs/msdosfs/msdosfs_vnops.c:1.61	Fri Jul  3 21:17:40 2009
+++ src/sys/fs/msdosfs/msdosfs_vnops.c	Thu Apr  8 15:03:33 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.61 2009/07/03 21:17:40 elad Exp $	*/
+/*	$NetBSD: msdosfs_vnops.c,v 1.62 2010/04/08 15:03:33 pooka Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.61 2009/07/03 21:17:40 elad Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.62 2010/04/08 15:03:33 pooka Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -186,20 +186,6 @@
 }
 
 int
-msdosfs_open(void *v)
-{
-#if 0
-	struct vop_open_args /* {
-		struct vnode *a_vp;
-		int a_mode;
-		kauth_cred_t a_cred;
-	} */ *ap;
-#endif
-
-	return (0);
-}
-
-int
 msdosfs_close(void *v)
 {
 	struct vop_close_args /* {
@@ -1685,23 +1671,6 @@
 }
 
 /*
- * DOS filesystems don't know what symlinks are.
- */
-int
-msdosfs_readlink(void *v)
-{
-#if 0
-	struct vop_readlink_args /* {
-		struct vnode *a_vp;
-		struct uio *a_uio;
-		kauth_cred_t a_cred;
-	} */ *ap;
-#endif
-
-	return (EINVAL);
-}
-
-/*
  * vp  - address of vnode file the file
  * bn  - which cluster we are interested in mapping to a filesystem block number.
  * vpp - returns the vnode for the block special file holding the filesystem
@@ -1946,7 +1915,7 @@
 	{ vop_lookup_desc, msdosfs_lookup },		/* lookup */
 	{ vop_create_desc, msdosfs_create },		/* create */
 	{ vop_mknod_desc, msdosfs_mknod },		/* mknod */
-	{ vop_open_desc, msdosfs_open },		/* open */
+	{ vop_open_desc, genfs_nullop },		/* open */
 	{ vop_close_desc, msdosfs_close },		/* close */
 	{ vop_access_desc, msdosfs_access },		/* access */
 	{ vop_getattr_desc, msdosfs_getattr },		/* getattr */
@@ -1968,7 +1937,7 @@
 	{ vop_rmdir_desc, msdosfs_rmdir },		/* rmdir */
 	{ vop_symlink_desc, msdosfs_symlink },		/* symlink */
 	{ vop_readdir_desc, msdosfs_readdir },		/* readdir */
-	{ vop_readlink_desc, msdosfs_readlink },	/* readlink */
+	{ vop_readlink_desc, genfs_einval },		/* readlink */
 	{ vop_abortop_desc, msdosfs_abortop },		/* abortop */
 	{ vop_inactive_desc, msdosfs_inactive },	/* inactive */
 	{ vop_reclaim_desc, msdosfs_reclaim },		/* reclaim */



CVS commit: src/sys/fs/msdosfs

2010-04-08 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Apr  8 16:04:35 UTC 2010

Modified Files:
src/sys/fs/msdosfs: denode.h msdosfs_vnops.c

Log Message:
In genfs where available.

The only functional change is mknod now returning EOPNOTSUPP instead
of EINVAL.  I make this sacrifice willingly and with a clean conscience.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/fs/msdosfs/denode.h
cvs rdiff -u -r1.62 -r1.63 src/sys/fs/msdosfs/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/denode.h
diff -u src/sys/fs/msdosfs/denode.h:1.17 src/sys/fs/msdosfs/denode.h:1.18
--- src/sys/fs/msdosfs/denode.h:1.17	Thu Apr  8 15:03:33 2010
+++ src/sys/fs/msdosfs/denode.h	Thu Apr  8 16:04:35 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: denode.h,v 1.17 2010/04/08 15:03:33 pooka Exp $	*/
+/*	$NetBSD: denode.h,v 1.18 2010/04/08 16:04:35 pooka Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -259,7 +259,6 @@
  */
 int	msdosfs_lookup		(void *);
 int	msdosfs_create		(void *);
-int	msdosfs_mknod		(void *);
 int	msdosfs_close		(void *);
 int	msdosfs_access		(void *);
 int	msdosfs_getattr		(void *);
@@ -274,11 +273,9 @@
 int	msdosfs_fsync		(void *);
 #define	msdosfs_seek		genfs_seek
 int	msdosfs_remove		(void *);
-int	msdosfs_link		(void *);
 int	msdosfs_rename		(void *);
 int	msdosfs_mkdir		(void *);
 int	msdosfs_rmdir		(void *);
-int	msdosfs_symlink		(void *);
 int	msdosfs_readdir		(void *);
 #define	msdosfs_abortop		genfs_abortop
 int	msdosfs_inactive	(void *);

Index: src/sys/fs/msdosfs/msdosfs_vnops.c
diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.62 src/sys/fs/msdosfs/msdosfs_vnops.c:1.63
--- src/sys/fs/msdosfs/msdosfs_vnops.c:1.62	Thu Apr  8 15:03:33 2010
+++ src/sys/fs/msdosfs/msdosfs_vnops.c	Thu Apr  8 16:04:35 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.62 2010/04/08 15:03:33 pooka Exp $	*/
+/*	$NetBSD: msdosfs_vnops.c,v 1.63 2010/04/08 16:04:35 pooka Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.62 2010/04/08 15:03:33 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.63 2010/04/08 16:04:35 pooka Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -171,21 +171,6 @@
 }
 
 int
-msdosfs_mknod(void *v)
-{
-	struct vop_mknod_args /* {
-		struct vnode *a_dvp;
-		struct vnode **a_vpp;
-		struct componentname *a_cnp;
-		struct vattr *a_vap;
-	} */ *ap = v;
-
-	PNBUF_PUT(ap-a_cnp-cn_pnbuf);
-	vput(ap-a_dvp);
-	return (EINVAL);
-}
-
-int
 msdosfs_close(void *v)
 {
 	struct vop_close_args /* {
@@ -751,25 +736,6 @@
 }
 
 /*
- * DOS filesystems don't know what links are. But since we already called
- * msdosfs_lookup() with create and lockparent, the parent is locked so we
- * have to free it before we return the error.
- */
-int
-msdosfs_link(void *v)
-{
-	struct vop_link_args /* {
-		struct vnode *a_dvp;
-		struct vnode *a_vp;
-		struct componentname *a_cnp;
-	} */ *ap = v;
-
-	VOP_ABORTOP(ap-a_dvp, ap-a_cnp);
-	vput(ap-a_dvp);
-	return (EOPNOTSUPP);
-}
-
-/*
  * Renames on files require moving the denode to a new hash queue since the
  * denode's location is used to compute which hash queue to put the file
  * in. Unless it is a rename in place.  For example mv a b.
@@ -1384,25 +1350,6 @@
 	return (error);
 }
 
-/*
- * DOS filesystems don't know what symlinks are.
- */
-int
-msdosfs_symlink(void *v)
-{
-	struct vop_symlink_args /* {
-		struct vnode *a_dvp;
-		struct vnode **a_vpp;
-		struct componentname *a_cnp;
-		struct vattr *a_vap;
-		char *a_target;
-	} */ *ap = v;
-
-	VOP_ABORTOP(ap-a_dvp, ap-a_cnp);
-	vput(ap-a_dvp);
-	return (EOPNOTSUPP);
-}
-
 int
 msdosfs_readdir(void *v)
 {
@@ -1914,7 +1861,7 @@
 	{ vop_default_desc, vn_default_error },
 	{ vop_lookup_desc, msdosfs_lookup },		/* lookup */
 	{ vop_create_desc, msdosfs_create },		/* create */
-	{ vop_mknod_desc, msdosfs_mknod },		/* mknod */
+	{ vop_mknod_desc, genfs_eopnotsupp },		/* mknod */
 	{ vop_open_desc, genfs_nullop },		/* open */
 	{ vop_close_desc, msdosfs_close },		/* close */
 	{ vop_access_desc, msdosfs_access },		/* access */
@@ -1931,11 +1878,11 @@
 	{ vop_fsync_desc, msdosfs_fsync },		/* fsync */
 	{ vop_seek_desc, msdosfs_seek },		/* seek */
 	{ vop_remove_desc, msdosfs_remove },		/* remove */
-	{ vop_link_desc, msdosfs_link },		/* link */
+	{ vop_link_desc, genfs_eopnotsupp },		/* link */
 	{ vop_rename_desc, msdosfs_rename },		/* rename */
 	{ vop_mkdir_desc, msdosfs_mkdir },		/* mkdir */
 	{ vop_rmdir_desc, msdosfs_rmdir },		/* rmdir */
-	{ vop_symlink_desc, msdosfs_symlink },		/* symlink */
+	{ vop_symlink_desc, genfs_eopnotsupp },	/* symlink */
 	{ vop_readdir_desc, msdosfs_readdir },		/* readdir */
 	{ vop_readlink_desc, genfs_einval },		/* readlink */
 	{ vop_abortop_desc, msdosfs_abortop },		/* abortop */



CVS commit: src/sys/fs/msdosfs

2010-04-07 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Apr  7 15:19:09 UTC 2010

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
* Don't care about VOP_CLOSE() error in unmount.  In the extremely
  unlike event it did fail, the kernel would double lutz to doom
  (in failure devvp now remains unmountable until reboot.  fans
  of complicated  untested error branches may attempt to gunk this
  up.  i'm not one of them).
* cosmetic surgery: cut extra ;


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.79 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.80
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.79	Sun Jan 31 10:30:40 2010
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Wed Apr  7 15:19:09 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.79 2010/01/31 10:30:40 mlelstv Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.80 2010/04/07 15:19:09 pooka Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.79 2010/01/31 10:30:40 mlelstv Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.80 2010/04/07 15:19:09 pooka Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -811,7 +811,7 @@
 
 	return (0);
 
-error_exit:;
+error_exit:
 	if (bp)
 		brelse(bp, BC_AGE);
 	if (pmp) {
@@ -871,14 +871,14 @@
 	}
 #endif
 	vn_lock(pmp-pm_devvp, LK_EXCLUSIVE | LK_RETRY);
-	error = VOP_CLOSE(pmp-pm_devvp,
+	(void) VOP_CLOSE(pmp-pm_devvp,
 	pmp-pm_flags  MSDOSFSMNT_RONLY ? FREAD : FREAD|FWRITE, NOCRED);
 	vput(pmp-pm_devvp);
 	free(pmp-pm_inusemap, M_MSDOSFSFAT);
 	free(pmp, M_MSDOSFSMNT);
 	mp-mnt_data = NULL;
 	mp-mnt_flag = ~MNT_LOCAL;
-	return (error);
+	return (0);
 }
 
 int



CVS commit: src/sys/fs/msdosfs

2010-01-31 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jan 31 10:30:41 UTC 2010

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
Replace individual queries for partition information with
new helper function.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.78 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.79
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.78	Tue Jan 26 21:29:48 2010
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Sun Jan 31 10:30:40 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.78 2010/01/26 21:29:48 mlelstv Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.79 2010/01/31 10:30:40 mlelstv Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.78 2010/01/26 21:29:48 mlelstv Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.79 2010/01/31 10:30:40 mlelstv Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -464,15 +464,15 @@
 	struct msdosfsmount *pmp;
 	struct buf *bp;
 	dev_t dev = devvp-v_rdev;
-	struct partinfo dpart;
 	union bootsector *bsp;
 	struct byte_bpb33 *b33;
 	struct byte_bpb50 *b50;
 	struct byte_bpb710 *b710;
-	u_int8_t SecPerClust;
+	uint8_t SecPerClust;
 	int	ronly, error, tmp;
-	int	bsize, secsize;
-	u_int64_t psize;
+	int	bsize;
+	uint64_t psize;
+	unsigned secsize;
 
 	/* Flush out any old buffers remaining from a previous use. */
 	if ((error = vinvalbuf(devvp, V_SAVE, l-l_cred, l, 0, 0)) != 0)
@@ -483,40 +483,10 @@
 	bp  = NULL; /* both used in error_exit */
 	pmp = NULL;
 
-	/*
- 	 * We need the disklabel to calculate the size of a FAT entry
-	 * later on.
- 	 *
- 	 * There might still be parts of the msdos fs driver which assume
-	 * that the size of a disk block will always be 512 bytes.
-	 * Let's root them out...
-	 */
-	error = VOP_IOCTL(devvp, DIOCGPART, dpart, FREAD, NOCRED);
-	if (error == 0) {
-		secsize = dpart.disklab-d_secsize;
-		psize = dpart.part-p_size;
-	} else {
-		struct dkwedge_info dkw;
-		struct disk *pdk;
-		error = VOP_IOCTL(devvp, DIOCGWEDGEINFO, dkw, FREAD, NOCRED);
-		secsize = 512;	/* XXX */
-		psize = -1;
-		if (error) {
-			if (error != ENOTTY) {
-DPRINTF((Error getting partition info %d\n,
-error));
-goto error_exit;
-			}
-		} else {
-			pdk = disk_find(dkw.dkw_parent);
-			if (pdk == NULL) {
-error = ENODEV;
-goto error_exit;
-			}
-			secsize = DEV_BSIZE  pdk-dk_blkshift;
-			psize = dkw.dkw_size;
-		}
-	}
+	error = getdisksize(devvp, psize, secsize);
+	if (error)
+		goto error_exit;
+
 	if (argp-flags  MSDOSFSMNT_GEMDOSFS) {
 		bsize = secsize;
 		if (bsize != 512) {



CVS commit: src/sys/fs/msdosfs

2010-01-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Jan 25 15:30:44 UTC 2010

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
Fetch sector size also from wedges.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.76 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.77
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.76	Mon Jun 29 05:08:17 2009
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Mon Jan 25 15:30:44 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.76 2009/06/29 05:08:17 dholland Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.77 2010/01/25 15:30:44 mlelstv Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.76 2009/06/29 05:08:17 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.77 2010/01/25 15:30:44 mlelstv Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -501,6 +501,7 @@
 		psize = dpart.part-p_size;
 	} else {
 		struct dkwedge_info dkw;
+		struct disk *pdk;
 		error = VOP_IOCTL(devvp, DIOCGWEDGEINFO, dkw, FREAD, NOCRED);
 		secsize = 512;	/* XXX */
 		dtype = DTYPE_FLOPPY; /* XXX */
@@ -513,6 +514,12 @@
 goto error_exit;
 			}
 		} else {
+			pdk = disk_find(dkw.dkw_parent);
+			if (pdk == NULL) {
+error = ENODEV;
+goto error_exit;
+			}
+			secsize = DEV_BSIZE  pdk-dk_blkshift;
 			fstype = strcmp(dkw.dkw_ptype, DKW_PTYPE_FAT) == 0 ?
 			FS_MSDOS : -1;
 			psize = dkw.dkw_size;