CVS commit: [netbsd-5] src/sys/fs/tmpfs

2009-03-24 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Mar 24 20:22:44 UTC 2009

Modified Files:
src/sys/fs/tmpfs [netbsd-5]: tmpfs_vnops.c

Log Message:
Pull up following revision(s) (requested by pooka in ticket #590):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.54
Release dvp in mknod error branch.
Nicolas Joly, PR kern/41006


To generate a diff of this commit:
cvs rdiff -u -r1.51.6.1 -r1.51.6.2 src/sys/fs/tmpfs/tmpfs_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/tmpfs/tmpfs_vnops.c
diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.51.6.1 src/sys/fs/tmpfs/tmpfs_vnops.c:1.51.6.2
--- src/sys/fs/tmpfs/tmpfs_vnops.c:1.51.6.1	Mon Feb 16 03:29:01 2009
+++ src/sys/fs/tmpfs/tmpfs_vnops.c	Tue Mar 24 20:22:44 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: tmpfs_vnops.c,v 1.51.6.1 2009/02/16 03:29:01 snj Exp $	*/
+/*	$NetBSD: tmpfs_vnops.c,v 1.51.6.2 2009/03/24 20:22:44 snj Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.51.6.1 2009/02/16 03:29:01 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.51.6.2 2009/03/24 20:22:44 snj Exp $");
 
 #include 
 #include 
@@ -270,8 +270,10 @@
 	struct vattr *vap = ((struct vop_mknod_args *)v)->a_vap;
 
 	if (vap->va_type != VBLK && vap->va_type != VCHR &&
-	vap->va_type != VFIFO)
+	vap->va_type != VFIFO) {
+		vput(dvp);
 		return EINVAL;
+	}
 
 	return tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL);
 }



CVS commit: [netbsd-5] src/sys/fs/tmpfs

2009-04-08 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Apr  8 23:08:07 UTC 2009

Modified Files:
src/sys/fs/tmpfs [netbsd-5]: tmpfs_vnops.c

Log Message:
Pull up following revision(s) (requested by tron in ticket #680):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.55
Fix yet another recent crashy bug in tmpfs rename: since the source
dirent is no longer cached in lookup and we do the lookup ourselves
in rename, we are most definitely not allowed to assert that it
matches the source vnode passed as an argument.  In case the source
node does not exist or has been replaced, punt with ENOENT.
Also, nuke some misleading prehistoric comments which haven't been
valid in over a year.
Fixes PR kern/41128 by Nicolas Joly


To generate a diff of this commit:
cvs rdiff -u -r1.51.6.2 -r1.51.6.3 src/sys/fs/tmpfs/tmpfs_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/tmpfs/tmpfs_vnops.c
diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.51.6.2 src/sys/fs/tmpfs/tmpfs_vnops.c:1.51.6.3
--- src/sys/fs/tmpfs/tmpfs_vnops.c:1.51.6.2	Tue Mar 24 20:22:44 2009
+++ src/sys/fs/tmpfs/tmpfs_vnops.c	Wed Apr  8 23:08:07 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: tmpfs_vnops.c,v 1.51.6.2 2009/03/24 20:22:44 snj Exp $	*/
+/*	$NetBSD: tmpfs_vnops.c,v 1.51.6.3 2009/04/08 23:08:07 snj Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.51.6.2 2009/03/24 20:22:44 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.51.6.3 2009/04/08 23:08:07 snj Exp $");
 
 #include 
 #include 
@@ -833,12 +833,14 @@
 			goto out_unlocked;
 	}
 
+	/*
+	 * If the node we were renaming has scarpered, just give up.
+	 */
 	de = tmpfs_dir_lookup(fdnode, fcnp);
-	if (de == NULL) {
+	if (de == NULL || de->td_node != fnode) {
 		error = ENOENT;
 		goto out;
 	}
-	KASSERT(de->td_node == fnode);
 
 	/* If source and target are the same file, there is nothing to do. */
 	if (fvp == tvp) {
@@ -846,14 +848,6 @@
 		goto out;
 	}
 
-	/* Avoid manipulating '.' and '..' entries. */
-	if (de == NULL) {
-		KASSERT(fvp->v_type == VDIR);
-		error = EINVAL;
-		goto out;
-	}
-	KASSERT(de->td_node == fnode);
-
 	/* If replacing an existing entry, ensure we can do the operation. */
 	if (tvp != NULL) {
 		KASSERT(tnode != NULL);



CVS commit: [netbsd-5] src/sys/fs/tmpfs

2009-04-11 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sun Apr 12 02:22:24 UTC 2009

Modified Files:
src/sys/fs/tmpfs [netbsd-5]: tmpfs_subr.c

Log Message:
Pull up following revision(s) (requested by markd in ticket #689):
sys/fs/tmpfs/tmpfs_subr.c: revision 1.50
For chown make auth checks consistent with UFS. Fixes PR kern/40933.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.48.6.1 src/sys/fs/tmpfs/tmpfs_subr.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/tmpfs/tmpfs_subr.c
diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.48 src/sys/fs/tmpfs/tmpfs_subr.c:1.48.6.1
--- src/sys/fs/tmpfs/tmpfs_subr.c:1.48	Thu Jun 19 19:03:44 2008
+++ src/sys/fs/tmpfs/tmpfs_subr.c	Sun Apr 12 02:22:24 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: tmpfs_subr.c,v 1.48 2008/06/19 19:03:44 christos Exp $	*/
+/*	$NetBSD: tmpfs_subr.c,v 1.48.6.1 2009/04/12 02:22:24 snj Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.48 2008/06/19 19:03:44 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.48.6.1 2009/04/12 02:22:24 snj Exp $");
 
 #include 
 #include 
@@ -1098,7 +1098,7 @@
 	 * several other file systems.  Shouldn't this be centralized
 	 * somewhere? */
 	if ((kauth_cred_geteuid(cred) != node->tn_uid || uid != node->tn_uid ||
-	(gid != node->tn_gid && !(kauth_cred_getegid(cred) == node->tn_gid ||
+	(gid != node->tn_gid && !(kauth_cred_getegid(cred) == gid ||
 	(kauth_cred_ismember_gid(cred, gid, &ismember) == 0 && ismember &&
 	((error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER,
 	NULL)) != 0))



CVS commit: [netbsd-5] src/sys/fs/tmpfs

2009-04-19 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sun Apr 19 15:26:35 UTC 2009

Modified Files:
src/sys/fs/tmpfs [netbsd-5]: tmpfs_vnops.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #690):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.57
SAVENAME was not set for rename and delete as required
Patch from christos, fixes pr 41183


To generate a diff of this commit:
cvs rdiff -u -r1.51.6.3 -r1.51.6.4 src/sys/fs/tmpfs/tmpfs_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/tmpfs/tmpfs_vnops.c
diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.51.6.3 src/sys/fs/tmpfs/tmpfs_vnops.c:1.51.6.4
--- src/sys/fs/tmpfs/tmpfs_vnops.c:1.51.6.3	Wed Apr  8 23:08:07 2009
+++ src/sys/fs/tmpfs/tmpfs_vnops.c	Sun Apr 19 15:26:35 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: tmpfs_vnops.c,v 1.51.6.3 2009/04/08 23:08:07 snj Exp $	*/
+/*	$NetBSD: tmpfs_vnops.c,v 1.51.6.4 2009/04/19 15:26:35 snj Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.51.6.3 2009/04/08 23:08:07 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.51.6.4 2009/04/19 15:26:35 snj Exp $");
 
 #include 
 #include 
@@ -219,6 +219,7 @@
 error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred);
 if (error != 0)
 	goto out;
+cnp->cn_flags |= SAVENAME;
 			} else
 de = NULL;
 



CVS commit: [netbsd-5] src/sys/fs/tmpfs

2009-04-19 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sun Apr 19 15:27:32 UTC 2009

Modified Files:
src/sys/fs/tmpfs [netbsd-5]: tmpfs_vnops.c

Log Message:
Pull up following revision(s) (requested by ad in ticket #690):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.58
plug some pnbuf leaks.


To generate a diff of this commit:
cvs rdiff -u -r1.51.6.4 -r1.51.6.5 src/sys/fs/tmpfs/tmpfs_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/tmpfs/tmpfs_vnops.c
diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.51.6.4 src/sys/fs/tmpfs/tmpfs_vnops.c:1.51.6.5
--- src/sys/fs/tmpfs/tmpfs_vnops.c:1.51.6.4	Sun Apr 19 15:26:35 2009
+++ src/sys/fs/tmpfs/tmpfs_vnops.c	Sun Apr 19 15:27:32 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: tmpfs_vnops.c,v 1.51.6.4 2009/04/19 15:26:35 snj Exp $	*/
+/*	$NetBSD: tmpfs_vnops.c,v 1.51.6.5 2009/04/19 15:27:32 snj Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.51.6.4 2009/04/19 15:26:35 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.51.6.5 2009/04/19 15:27:32 snj Exp $");
 
 #include 
 #include 
@@ -691,6 +691,7 @@
 		vrele(dvp);
 	else
 		vput(dvp);
+	PNBUF_PUT(cnp->cn_pnbuf);
 
 	return error;
 }
@@ -1076,6 +1077,7 @@
 	/* Release the nodes. */
 	vput(dvp);
 	vput(vp);
+	PNBUF_PUT(cnp->cn_pnbuf);
 
 	return error;
 }



CVS commit: [netbsd-5] src/sys/fs/tmpfs

2009-12-06 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Dec  7 04:30:13 UTC 2009

Modified Files:
src/sys/fs/tmpfs [netbsd-5]: tmpfs_vnops.c

Log Message:
Pull up following revision(s) (requested by rmind in ticket #1072):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.63
tmpfs_rename: handle hard-links correctly.  Fixes PR/41236.


To generate a diff of this commit:
cvs rdiff -u -r1.51.6.5 -r1.51.6.6 src/sys/fs/tmpfs/tmpfs_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/tmpfs/tmpfs_vnops.c
diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.51.6.5 src/sys/fs/tmpfs/tmpfs_vnops.c:1.51.6.6
--- src/sys/fs/tmpfs/tmpfs_vnops.c:1.51.6.5	Sun Apr 19 15:27:32 2009
+++ src/sys/fs/tmpfs/tmpfs_vnops.c	Mon Dec  7 04:30:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: tmpfs_vnops.c,v 1.51.6.5 2009/04/19 15:27:32 snj Exp $	*/
+/*	$NetBSD: tmpfs_vnops.c,v 1.51.6.6 2009/12/07 04:30:13 snj Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.51.6.5 2009/04/19 15:27:32 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.51.6.6 2009/12/07 04:30:13 snj Exp $");
 
 #include 
 #include 
@@ -719,9 +719,7 @@
 
 	/* Lock vp because we will need to run tmpfs_update over it, which
 	 * needs the vnode to be locked. */
-	error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
-	if (error != 0)
-		goto out1;
+	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 
 	/* XXX: Why aren't the following two tests done by the caller? */
 
@@ -768,16 +766,24 @@
 
 out:
 	VOP_UNLOCK(vp, 0);
-out1:
 	PNBUF_PUT(cnp->cn_pnbuf);
-
 	vput(dvp);
 
 	return error;
 }
 
-/* - */
-
+/*
+ * tmpfs_rename: rename routine.
+ *
+ * Arguments: fdvp (from-parent vnode), fvp (from-leaf), tdvp (to-parent)
+ * and tvp (to-leaf), if exists (NULL if not).
+ *
+ * => Caller holds a reference on fdvp and fvp, they are unlocked.
+ *Note: fdvp and fvp can refer to the same object (i.e. when it is root).
+ *
+ * => Both tdvp and tvp are referenced and locked.  It is our responsibility
+ *to release the references and unlock them (or destroy).
+ */
 int
 tmpfs_rename(void *v)
 {
@@ -830,9 +836,7 @@
 
 	/* XXX: this is a potential locking order violation! */
 	if (fdnode != tdnode) {
-		error = vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY);
-		if (error != 0)
-			goto out_unlocked;
+		vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY);
 	}
 
 	/*
@@ -844,10 +848,16 @@
 		goto out;
 	}
 
-	/* If source and target are the same file, there is nothing to do. */
+	/* If source and target is the same vnode, remove the source link. */
 	if (fvp == tvp) {
-		error = 0;
-		goto out;
+		/*
+		 * Detach and free the directory entry.  Drops the link
+		 * count on the node.
+		 */
+		tmpfs_dir_detach(fdvp, de);
+		tmpfs_free_dirent(VFS_TO_TMPFS(fvp->v_mount), de, true);
+		VN_KNOTE(fdvp, NOTE_WRITE);
+		goto out_ok;
 	}
 
 	/* If replacing an existing entry, ensure we can do the operation. */
@@ -959,7 +969,7 @@
 		fnode->tn_status |= TMPFS_NODE_CHANGED;
 		tdnode->tn_status |= TMPFS_NODE_MODIFIED;
 	}
-
+ out_ok:
 	/* Notify listeners of tdvp about the change in the directory (either
 	 * because a new entry was added or because one was removed) and
 	 * listeners of fvp about the rename. */