CVS commit: src/sys/ufs/lfs

2014-05-17 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat May 17 07:08:35 UTC 2014

Modified Files:
src/sys/ufs/lfs: lfs_rename.c lfs_vnops.c ulfs_inode.h

Log Message:
Remove the DIROP macros. They are evil, especially the CREATE ones.

This results in some duplicate logic in the creation vnops (symlink,
mknod, create, mkdir) but we will probably be able to factor it out in
a more sensible way later.

Now the creation vnops call getnewvnode explicitly instead of under
multiple layers of obscure gunk. Then we explicitly do lfs_set_dirop,
and afterwards lfs_unset_dirop.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/ufs/lfs/lfs_rename.c
cvs rdiff -u -r1.263 -r1.264 src/sys/ufs/lfs/lfs_vnops.c
cvs rdiff -u -r1.11 -r1.12 src/sys/ufs/lfs/ulfs_inode.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/ufs/lfs/lfs_rename.c
diff -u src/sys/ufs/lfs/lfs_rename.c:1.6 src/sys/ufs/lfs/lfs_rename.c:1.7
--- src/sys/ufs/lfs/lfs_rename.c:1.6	Thu Feb  6 10:57:12 2014
+++ src/sys/ufs/lfs/lfs_rename.c	Sat May 17 07:08:35 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_rename.c,v 1.6 2014/02/06 10:57:12 hannken Exp $	*/
+/*	$NetBSD: lfs_rename.c,v 1.7 2014/05/17 07:08:35 dholland Exp $	*/
 /*  from NetBSD: ufs_rename.c,v 1.6 2013/01/22 09:39:18 dholland Exp  */
 
 /*-
@@ -89,7 +89,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.6 2014/02/06 10:57:12 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.7 2014/05/17 07:08:35 dholland Exp $");
 
 #include 
 #include 
@@ -1079,7 +1079,7 @@ lfs_gro_rename(struct mount *mp, kauth_c
 	KASSERT(VOP_ISLOCKED(tdvp) == LK_EXCLUSIVE);
 	KASSERT((tvp == NULL) || (VOP_ISLOCKED(tvp) == LK_EXCLUSIVE));
 
-	error = SET_DIROP_REMOVE(tdvp, tvp);
+	error = lfs_set_dirop(tdvp, tvp);
 	if (error != 0)
 		return error;
 
@@ -1092,7 +1092,15 @@ lfs_gro_rename(struct mount *mp, kauth_c
 
 	UNMARK_VNODE(fdvp);
 	UNMARK_VNODE(fvp);
-	SET_ENDOP_REMOVE(VFSTOULFS(mp)->um_lfs, tdvp, tvp, "rename");
+	UNMARK_VNODE(tdvp);
+	if (tvp) {
+		UNMARK_VNODE(tvp);
+	}
+	lfs_unset_dirop(VFSTOULFS(mp)->um_lfs, tdvp, "rename");
+	vrele(tdvp);
+	if (tvp) {
+		vrele(tvp);
+	}
 
 	return error;
 }

Index: src/sys/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.263 src/sys/ufs/lfs/lfs_vnops.c:1.264
--- src/sys/ufs/lfs/lfs_vnops.c:1.263	Fri May 16 09:34:03 2014
+++ src/sys/ufs/lfs/lfs_vnops.c	Sat May 17 07:08:35 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.263 2014/05/16 09:34:03 dholland Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.264 2014/05/17 07:08:35 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.263 2014/05/16 09:34:03 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.264 2014/05/17 07:08:35 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -473,38 +473,27 @@ lfs_set_dirop(struct vnode *dvp, struct 
 }
 
 /*
- * Get a new vnode *before* adjusting the dirop count, to avoid a deadlock
- * in getnewvnode(), if we have a stacked filesystem mounted on top
- * of us.
- *
- * NB: this means we have to clear the new vnodes on error.  Fortunately
- * SET_ENDOP is there to do that for us.
+ * Opposite of lfs_set_dirop... mostly. For now at least must call
+ * UNMARK_VNODE(dvp) explicitly first. (XXX: clean that up)
  */
-int
-lfs_set_dirop_create(struct vnode *dvp, struct vnode **vpp)
+void
+lfs_unset_dirop(struct lfs *fs, struct vnode *dvp, const char *str)
 {
-	int error;
-	struct lfs *fs;
-
-	fs = VFSTOULFS(dvp->v_mount)->um_lfs;
-	ASSERT_NO_SEGLOCK(fs);
-	if (fs->lfs_ronly)
-		return EROFS;
-	if (vpp == NULL) {
-		return lfs_set_dirop(dvp, NULL);
-	}
-	error = getnewvnode(VT_LFS, dvp->v_mount, lfs_vnodeop_p, NULL, vpp);
-	if (error) {
-		DLOG((DLOG_ALLOC, "lfs_set_dirop_create: dvp %p error %d\n",
-		  dvp, error));
-		return error;
-	}
-	if ((error = lfs_set_dirop(dvp, NULL)) != 0) {
-		ungetnewvnode(*vpp);
-		*vpp = NULL;
-		return error;
+	mutex_enter(&lfs_lock);
+	--fs->lfs_dirops;
+	if (!fs->lfs_dirops) {
+		if (fs->lfs_nadirop) {
+			panic("lfs_unset_dirop: %s: no dirops but "
+			  " nadirop=%d", str,
+			  fs->lfs_nadirop);
+		}
+		wakeup(&fs->lfs_writer);
+		mutex_exit(&lfs_lock);
+		lfs_check(dvp, LFS_UNUSED_LBN, 0);
+	} else {
+		mutex_exit(&lfs_lock);
 	}
-	return 0;
+	lfs_reserve(fs, dvp, NULL, -LFS_NRESERVE(fs));
 }
 
 void
@@ -558,13 +547,60 @@ lfs_symlink(void *v)
 		struct vattr *a_vap;
 		char *a_target;
 	} */ *ap = v;
+	struct lfs *fs;
+	struct vnode *dvp, **vpp;
 	int error;
 
-	if ((error = SET_DIROP_CREATE(ap->a_dvp, ap->a_vpp)) != 0) {
+	dvp = ap->a_dvp;
+	vpp = ap->a_vpp;
+
+	KASSERT(vpp != NULL);
+	KASSERT(*vpp == NULL);
+
+	fs = VFSTOULFS(dvp->v_mount)->um_lfs;
+	ASSERT_NO_SEGLOCK(fs);
+	if (fs->lfs_ronly) {
+		return EROFS;
+	}
+
+	/*
+	 * Get a new vnode *b

CVS commit: src/sys/ufs/lfs

2014-05-17 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat May 17 07:09:09 UTC 2014

Modified Files:
src/sys/ufs/lfs: lfs_vnops.c ulfs_vnops.c

Log Message:
Move the ulfs-level (copy of ufs) vnops for symlink, create, and mkdir
into lfs_vnops.c preparatory to folding them into the lfs entry points.

(lfs_vnops.c now has four licenses. sigh.)


To generate a diff of this commit:
cvs rdiff -u -r1.264 -r1.265 src/sys/ufs/lfs/lfs_vnops.c
cvs rdiff -u -r1.20 -r1.21 src/sys/ufs/lfs/ulfs_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/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.264 src/sys/ufs/lfs/lfs_vnops.c:1.265
--- src/sys/ufs/lfs/lfs_vnops.c:1.264	Sat May 17 07:08:35 2014
+++ src/sys/ufs/lfs/lfs_vnops.c	Sat May 17 07:09:09 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.264 2014/05/17 07:08:35 dholland Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.265 2014/05/17 07:09:09 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -59,8 +59,73 @@
  *	@(#)lfs_vnops.c	8.13 (Berkeley) 6/10/95
  */
 
+/*  from NetBSD: ufs_vnops.c,v 1.213 2013/06/08 05:47:02 kardel Exp  */
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993, 1995
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *may be used to endorse or promote products derived from this software
+ *without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)ufs_vnops.c	8.28 (Berkeley) 7/31/95
+ */
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.264 2014/05/17 07:08:35 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.265 2014/05/17 07:09:09 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_co

CVS commit: src/sys/ufs/lfs

2014-05-17 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat May 17 07:09:59 UTC 2014

Modified Files:
src/sys/ufs/lfs: lfs_vnops.c ulfs_extern.h

Log Message:
Merge ulfs_mkdir into lfs_mkdir.


To generate a diff of this commit:
cvs rdiff -u -r1.266 -r1.267 src/sys/ufs/lfs/lfs_vnops.c
cvs rdiff -u -r1.11 -r1.12 src/sys/ufs/lfs/ulfs_extern.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/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.266 src/sys/ufs/lfs/lfs_vnops.c:1.267
--- src/sys/ufs/lfs/lfs_vnops.c:1.266	Sat May 17 07:09:36 2014
+++ src/sys/ufs/lfs/lfs_vnops.c	Sat May 17 07:09:59 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.266 2014/05/17 07:09:36 dholland Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.267 2014/05/17 07:09:59 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.266 2014/05/17 07:09:36 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.267 2014/05/17 07:09:59 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -952,37 +952,77 @@ lfs_create(void *v)
 }
 
 int
-ulfs_mkdir(void *v)
+lfs_mkdir(void *v)
 {
-	struct vop_mkdir_v3_args /* {
-		struct vnode		*a_dvp;
-		struct vnode		**a_vpp;
-		struct componentname	*a_cnp;
-		struct vattr		*a_vap;
+	struct vop_mkdir_v3_args	/* {
+		struct vnode *a_dvp;
+		struct vnode **a_vpp;
+		struct componentname *a_cnp;
+		struct vattr *a_vap;
 	} */ *ap = v;
-	struct vnode		*dvp = ap->a_dvp, *tvp;
-	struct vattr		*vap = ap->a_vap;
-	struct componentname	*cnp = ap->a_cnp;
-	struct inode		*ip, *dp = VTOI(dvp);
-	struct buf		*bp;
-	struct lfs_dirtemplate	dirtemplate;
-	struct lfs_direct		*newdir;
-	int			error, dmode;
-	struct ulfsmount	*ump = dp->i_ump;
-	struct lfs *fs = ump->um_lfs;
-	int dirblksiz = fs->um_dirblksiz;
+	struct lfs *fs;
+	struct vnode *dvp, *tvp, **vpp;
+	struct inode *dp, *ip;
+	struct componentname *cnp;
+	struct vattr *vap;
 	struct ulfs_lookup_results *ulr;
+	struct buf *bp;
+	struct lfs_dirtemplate dirtemplate;
+	struct lfs_direct *newdir;
+	int dirblksiz;
+	int dmode;
+	int error;
 
-	fstrans_start(dvp->v_mount, FSTRANS_SHARED);
+	dvp = ap->a_dvp;
+	tvp = NULL;
+	vpp = ap->a_vpp;
+	cnp = ap->a_cnp;
+	vap = ap->a_vap;
+
+	dp = VTOI(dvp);
+	ip = NULL;
+
+	KASSERT(vpp != NULL);
+	KASSERT(*vpp == NULL);
 
 	/* XXX should handle this material another way */
 	ulr = &dp->i_crap;
 	ULFS_CHECK_CRAPCOUNTER(dp);
 
+	fs = VFSTOULFS(dvp->v_mount)->um_lfs;
+	ASSERT_NO_SEGLOCK(fs);
+	if (fs->lfs_ronly) {
+		return EROFS;
+	}
+	dirblksiz = fs->um_dirblksiz;
+
+	/*
+	 * Get a new vnode *before* adjusting the dirop count, to
+	 * avoid a deadlock in getnewvnode(), if we have a stacked
+	 * filesystem mounted on top of us.
+	 *
+	 * NB: this means we have to destroy the new vnode on error.
+	 */
+
+	error = getnewvnode(VT_LFS, dvp->v_mount, lfs_vnodeop_p, NULL, vpp);
+	if (error) {
+		DLOG((DLOG_ALLOC, "lfs_mkdir: dvp %p error %d\n", dvp, error));
+		return error;
+	}
+	error = lfs_set_dirop(dvp, NULL);
+	if (error) {
+		ungetnewvnode(*vpp);
+		*vpp = NULL;
+		return error;
+	}
+
+	fstrans_start(dvp->v_mount, FSTRANS_SHARED);
+
 	if ((nlink_t)dp->i_nlink >= LINK_MAX) {
 		error = EMLINK;
 		goto out;
 	}
+
 	dmode = vap->va_mode & ACCESSPERMS;
 	dmode |= LFS_IFDIR;
 	/*
@@ -990,10 +1030,10 @@ ulfs_mkdir(void *v)
 	 * but not have it entered in the parent directory. The entry is
 	 * made later after writing "." and ".." entries.
 	 */
-	if ((error = lfs_valloc(dvp, dmode, cnp->cn_cred, ap->a_vpp)) != 0)
+	if ((error = lfs_valloc(dvp, dmode, cnp->cn_cred, vpp)) != 0)
 		goto out;
 
-	tvp = *ap->a_vpp;
+	tvp = *vpp;
 	ip = VTOI(tvp);
 
 	ip->i_uid = kauth_cred_geteuid(cnp->cn_cred);
@@ -1005,7 +1045,7 @@ ulfs_mkdir(void *v)
 		lfs_vfree(tvp, ip->i_number, dmode);
 		fstrans_done(dvp->v_mount);
 		vput(tvp);
-		return (error);
+		goto out2;
 	}
 #endif
 	ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
@@ -1021,8 +1061,6 @@ ulfs_mkdir(void *v)
 
 	/*
 	 * Bump link count in parent directory to reflect work done below.
-	 * Should be done before reference is created so cleanup is
-	 * possible if we crash.
 	 */
 	dp->i_nlink++;
 	DIP_ASSIGN(dp, nlink, dp->i_nlink);
@@ -1064,9 +1102,7 @@ ulfs_mkdir(void *v)
 	memcpy((void *)bp->b_data, (void *)&dirtemplate, sizeof dirtemplate);
 
 	/*
-	 * Directory set up, now install it's entry in the parent directory.
-	 * We must write out the buffer containing the new directory body
-	 * before entering the new name in the parent.
+	 * Directory set up; now install its entry in the parent directory.
 	 */
 	if ((error = VOP_BWRITE(bp->b_vp, bp)) != 0)
 		goto bad;
@@ -1096,57 +1132,12 @@ ulfs_mkdir(void *v)
 		lfs_unmark_vnode(tvp);
 		vput(tvp);
 	}
- out:
-	fstrans_done(dvp->v_mount);
-	return (error);
-}
-
-int
-lfs_mkdir(void *v)
-{
-	st

CVS commit: src/sys/ufs/lfs

2014-05-17 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat May 17 07:09:36 UTC 2014

Modified Files:
src/sys/ufs/lfs: lfs_vnops.c ulfs_extern.h

Log Message:
Merge ulfs_symlink into lfs_symlink.


To generate a diff of this commit:
cvs rdiff -u -r1.265 -r1.266 src/sys/ufs/lfs/lfs_vnops.c
cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/lfs/ulfs_extern.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/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.265 src/sys/ufs/lfs/lfs_vnops.c:1.266
--- src/sys/ufs/lfs/lfs_vnops.c:1.265	Sat May 17 07:09:09 2014
+++ src/sys/ufs/lfs/lfs_vnops.c	Sat May 17 07:09:36 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.265 2014/05/17 07:09:09 dholland Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.266 2014/05/17 07:09:36 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.265 2014/05/17 07:09:09 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.266 2014/05/17 07:09:36 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -610,59 +610,6 @@ lfs_unmark_vnode(struct vnode *vp)
 	mutex_exit(&lfs_lock);
 }
 
-/*
- * symlink -- make a symbolic link
- */
-int
-ulfs_symlink(void *v)
-{
-	struct vop_symlink_v3_args /* {
-		struct vnode		*a_dvp;
-		struct vnode		**a_vpp;
-		struct componentname	*a_cnp;
-		struct vattr		*a_vap;
-		char			*a_target;
-	} */ *ap = v;
-	struct vnode	*vp, **vpp;
-	struct inode	*ip;
-	int		len, error;
-	struct ulfs_lookup_results *ulr;
-
-	vpp = ap->a_vpp;
-
-	/* XXX should handle this material another way */
-	ulr = &VTOI(ap->a_dvp)->i_crap;
-	ULFS_CHECK_CRAPCOUNTER(VTOI(ap->a_dvp));
-
-	fstrans_start(ap->a_dvp->v_mount, FSTRANS_SHARED);
-	error = ulfs_makeinode(LFS_IFLNK | ap->a_vap->va_mode, ap->a_dvp, ulr,
-			  vpp, ap->a_cnp);
-	if (error)
-		goto out;
-	VN_KNOTE(ap->a_dvp, NOTE_WRITE);
-	vp = *vpp;
-	len = strlen(ap->a_target);
-	ip = VTOI(vp);
-	if (len < ip->i_lfs->um_maxsymlinklen) {
-		memcpy((char *)SHORTLINK(ip), ap->a_target, len);
-		ip->i_size = len;
-		DIP_ASSIGN(ip, size, len);
-		uvm_vnp_setsize(vp, ip->i_size);
-		ip->i_flag |= IN_CHANGE | IN_UPDATE;
-		if (vp->v_mount->mnt_flag & MNT_RELATIME)
-			ip->i_flag |= IN_ACCESS;
-	} else
-		error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0,
-		UIO_SYSSPACE, IO_NODELOCKED | IO_JOURNALLOCKED,
-		ap->a_cnp->cn_cred, NULL, NULL);
-	VOP_UNLOCK(vp);
-	if (error)
-		vrele(vp);
-out:
-	fstrans_done(ap->a_dvp->v_mount);
-	return (error);
-}
-
 int
 lfs_symlink(void *v)
 {
@@ -675,6 +622,9 @@ lfs_symlink(void *v)
 	} */ *ap = v;
 	struct lfs *fs;
 	struct vnode *dvp, **vpp;
+	struct inode *ip;
+	struct ulfs_lookup_results *ulr;
+	ssize_t len; /* XXX should be size_t */
 	int error;
 
 	dvp = ap->a_dvp;
@@ -683,6 +633,10 @@ lfs_symlink(void *v)
 	KASSERT(vpp != NULL);
 	KASSERT(*vpp == NULL);
 
+	/* XXX should handle this material another way */
+	ulr = &VTOI(ap->a_dvp)->i_crap;
+	ULFS_CHECK_CRAPCOUNTER(VTOI(ap->a_dvp));
+
 	fs = VFSTOULFS(dvp->v_mount)->um_lfs;
 	ASSERT_NO_SEGLOCK(fs);
 	if (fs->lfs_ronly) {
@@ -711,7 +665,37 @@ lfs_symlink(void *v)
 		return error;
 	}
 
-	error = ulfs_symlink(ap);
+	fstrans_start(dvp->v_mount, FSTRANS_SHARED);
+	error = ulfs_makeinode(LFS_IFLNK | ap->a_vap->va_mode, dvp, ulr,
+			  vpp, ap->a_cnp);
+	if (error) {
+		goto out;
+	}
+
+	VN_KNOTE(ap->a_dvp, NOTE_WRITE);
+	ip = VTOI(*vpp);
+
+	len = strlen(ap->a_target);
+	if (len < ip->i_lfs->um_maxsymlinklen) {
+		memcpy((char *)SHORTLINK(ip), ap->a_target, len);
+		ip->i_size = len;
+		DIP_ASSIGN(ip, size, len);
+		uvm_vnp_setsize(*vpp, ip->i_size);
+		ip->i_flag |= IN_CHANGE | IN_UPDATE;
+		if ((*vpp)->v_mount->mnt_flag & MNT_RELATIME)
+			ip->i_flag |= IN_ACCESS;
+	} else {
+		error = vn_rdwr(UIO_WRITE, *vpp, ap->a_target, len, (off_t)0,
+		UIO_SYSSPACE, IO_NODELOCKED | IO_JOURNALLOCKED,
+		ap->a_cnp->cn_cred, NULL, NULL);
+	}
+
+	VOP_UNLOCK(*vpp);
+	if (error)
+		vrele(*vpp);
+
+out:
+	fstrans_done(dvp->v_mount);
 
 	UNMARK_VNODE(dvp);
 	/* XXX: is it even possible for the symlink to get MARK'd? */

Index: src/sys/ufs/lfs/ulfs_extern.h
diff -u src/sys/ufs/lfs/ulfs_extern.h:1.10 src/sys/ufs/lfs/ulfs_extern.h:1.11
--- src/sys/ufs/lfs/ulfs_extern.h:1.10	Sun Jul 28 01:22:55 2013
+++ src/sys/ufs/lfs/ulfs_extern.h	Sat May 17 07:09:36 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ulfs_extern.h,v 1.10 2013/07/28 01:22:55 dholland Exp $	*/
+/*	$NetBSD: ulfs_extern.h,v 1.11 2014/05/17 07:09:36 dholland Exp $	*/
 /*  from NetBSD: ufs_extern.h,v 1.72 2012/05/09 00:21:18 riastradh Exp  */
 
 /*-
@@ -90,7 +90,6 @@ int	ulfs_rmdir(void *);
 #define	ulfs_poll	genfs_poll
 int	ulfs_setattr(void *);
 int	ulfs_strategy(void *);
-int	ulfs_symlink(void *);
 #define	ulfs_unlock	genfs_unlock
 int	ulfs_whiteout(void *);
 int	ulfsspec_close(void *);



CVS commit: src/sys/ufs/lfs

2014-05-17 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat May 17 07:10:27 UTC 2014

Modified Files:
src/sys/ufs/lfs: lfs_vnops.c

Log Message:
Merge ulfs_create into lfs_create.


To generate a diff of this commit:
cvs rdiff -u -r1.267 -r1.268 src/sys/ufs/lfs/lfs_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/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.267 src/sys/ufs/lfs/lfs_vnops.c:1.268
--- src/sys/ufs/lfs/lfs_vnops.c:1.267	Sat May 17 07:09:59 2014
+++ src/sys/ufs/lfs/lfs_vnops.c	Sat May 17 07:10:27 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.267 2014/05/17 07:09:59 dholland Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.268 2014/05/17 07:10:27 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.267 2014/05/17 07:09:59 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.268 2014/05/17 07:10:27 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -858,37 +858,6 @@ lfs_mknod(void *v)
  * Create a regular file
  */
 int
-ulfs_create(void *v)
-{
-	struct vop_create_v3_args /* {
-		struct vnode		*a_dvp;
-		struct vnode		**a_vpp;
-		struct componentname	*a_cnp;
-		struct vattr		*a_vap;
-	} */ *ap = v;
-	int	error;
-	struct vnode *dvp = ap->a_dvp;
-	struct ulfs_lookup_results *ulr;
-
-	/* XXX should handle this material another way */
-	ulr = &VTOI(dvp)->i_crap;
-	ULFS_CHECK_CRAPCOUNTER(VTOI(dvp));
-
-	fstrans_start(dvp->v_mount, FSTRANS_SHARED);
-	error =
-	ulfs_makeinode(MAKEIMODE(ap->a_vap->va_type, ap->a_vap->va_mode),
-			  dvp, ulr, ap->a_vpp, ap->a_cnp);
-	if (error) {
-		fstrans_done(dvp->v_mount);
-		return (error);
-	}
-	fstrans_done(dvp->v_mount);
-	VN_KNOTE(dvp, NOTE_WRITE);
-	VOP_UNLOCK(*ap->a_vpp);
-	return (0);
-}
-
-int
 lfs_create(void *v)
 {
 	struct vop_create_v3_args	/* {
@@ -899,14 +868,21 @@ lfs_create(void *v)
 	} */ *ap = v;
 	struct lfs *fs;
 	struct vnode *dvp, **vpp;
+	struct vattr *vap;
+	struct ulfs_lookup_results *ulr;
 	int error;
 
 	dvp = ap->a_dvp;
 	vpp = ap->a_vpp;
+	vap = ap->a_vap;
 
 	KASSERT(vpp != NULL);
 	KASSERT(*vpp == NULL);
 
+	/* XXX should handle this material another way */
+	ulr = &VTOI(dvp)->i_crap;
+	ULFS_CHECK_CRAPCOUNTER(VTOI(dvp));
+
 	fs = VFSTOULFS(dvp->v_mount)->um_lfs;
 	ASSERT_NO_SEGLOCK(fs);
 	if (fs->lfs_ronly) {
@@ -933,7 +909,18 @@ lfs_create(void *v)
 		return error;
 	}
 
-	error = ulfs_create(ap);
+	fstrans_start(dvp->v_mount, FSTRANS_SHARED);
+	error = ulfs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode),
+			  dvp, ulr, vpp, ap->a_cnp);
+	if (error) {
+		fstrans_done(dvp->v_mount);
+		goto out;
+	}
+	fstrans_done(dvp->v_mount);
+	VN_KNOTE(dvp, NOTE_WRITE);
+	VOP_UNLOCK(*vpp);
+
+out:
 
 	UNMARK_VNODE(dvp);
 	UNMARK_VNODE(*vpp);



CVS commit: src/sys/compat/linux

2014-05-17 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Sat May 17 09:23:51 UTC 2014

Modified Files:
src/sys/compat/linux/arch/alpha: syscalls.master
src/sys/compat/linux/arch/amd64: syscalls.master
src/sys/compat/linux/arch/arm: syscalls.master
src/sys/compat/linux/arch/i386: syscalls.master
src/sys/compat/linux/arch/m68k: syscalls.master
src/sys/compat/linux/arch/mips: syscalls.master
src/sys/compat/linux/arch/powerpc: syscalls.master
src/sys/compat/linux/common: linux_fadvise64.c

Log Message:
Fix fadvise64 syscalls to use 64bit offset types.


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/compat/linux/arch/alpha/syscalls.master
cvs rdiff -u -r1.48 -r1.49 src/sys/compat/linux/arch/amd64/syscalls.master
cvs rdiff -u -r1.57 -r1.58 src/sys/compat/linux/arch/arm/syscalls.master
cvs rdiff -u -r1.114 -r1.115 src/sys/compat/linux/arch/i386/syscalls.master
cvs rdiff -u -r1.84 -r1.85 src/sys/compat/linux/arch/m68k/syscalls.master
cvs rdiff -u -r1.52 -r1.53 src/sys/compat/linux/arch/mips/syscalls.master
cvs rdiff -u -r1.61 -r1.62 src/sys/compat/linux/arch/powerpc/syscalls.master
cvs rdiff -u -r1.1 -r1.2 src/sys/compat/linux/common/linux_fadvise64.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/compat/linux/arch/alpha/syscalls.master
diff -u src/sys/compat/linux/arch/alpha/syscalls.master:1.86 src/sys/compat/linux/arch/alpha/syscalls.master:1.87
--- src/sys/compat/linux/arch/alpha/syscalls.master:1.86	Tue May  6 17:33:35 2014
+++ src/sys/compat/linux/arch/alpha/syscalls.master	Sat May 17 09:23:51 2014
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.86 2014/05/06 17:33:35 njoly Exp $
+	$NetBSD: syscalls.master,v 1.87 2014/05/17 09:23:51 njoly Exp $
 ;
 ;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
 
@@ -657,8 +657,8 @@
 410	UNIMPL		remap_file_pages
 411	STD		{ int|linux_sys||set_tid_address(int *tid); }
 412	UNIMPL		restart_syscall
-413	STD		{ int|linux_sys||fadvise64(int fd, \
-			linux_off_t offset, size_t len, int advice); }
+413	STD		{ int|linux_sys||fadvise64(int fd, off_t offset, \
+			size_t len, int advice); }
 414	UNIMPL		timer_create
 415	UNIMPL		timer_settime
 416	UNIMPL		timer_gettime

Index: src/sys/compat/linux/arch/amd64/syscalls.master
diff -u src/sys/compat/linux/arch/amd64/syscalls.master:1.48 src/sys/compat/linux/arch/amd64/syscalls.master:1.49
--- src/sys/compat/linux/arch/amd64/syscalls.master:1.48	Sun May  4 10:08:53 2014
+++ src/sys/compat/linux/arch/amd64/syscalls.master	Sat May 17 09:23:51 2014
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.48 2014/05/04 10:08:53 njoly Exp $
+	$NetBSD: syscalls.master,v 1.49 2014/05/17 09:23:51 njoly Exp $
 
 ;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
 
@@ -421,8 +421,8 @@
 218	STD		{ int|linux_sys||set_tid_address(int *tid); }
 219	UNIMPL		restart_syscall
 220	UNIMPL		semtimedop
-221	STD		{ int|linux_sys||fadvise64(int fd, \
-			linux_off_t offset, size_t len, int advice); }
+221	STD		{ int|linux_sys||fadvise64(int fd, off_t offset, \
+			size_t len, int advice); }
 222	UNIMPL		timer_create
 223	UNIMPL		timer_settime
 224	UNIMPL		timer_gettime

Index: src/sys/compat/linux/arch/arm/syscalls.master
diff -u src/sys/compat/linux/arch/arm/syscalls.master:1.57 src/sys/compat/linux/arch/arm/syscalls.master:1.58
--- src/sys/compat/linux/arch/arm/syscalls.master:1.57	Tue May  6 17:33:35 2014
+++ src/sys/compat/linux/arch/arm/syscalls.master	Sat May 17 09:23:51 2014
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.57 2014/05/06 17:33:35 njoly Exp $
+	$NetBSD: syscalls.master,v 1.58 2014/05/17 09:23:51 njoly Exp $
 
 ; Derived from sys/compat/linux/arch/*/syscalls.master
 ; and from Linux 2.4.12 arch/arm/kernel/calls.S
@@ -451,8 +451,8 @@
 			size_t sz, struct linux_statfs64 *sp); }
 268	STD		{ int|linux_sys||tgkill(int tgid, int tid, int sig); }
 269	STD		{ int|linux_sys||utimes(const char *path, struct linux_timeval *times); }
-270	STD		{ int|linux_sys||fadvise64_64(int fd, \
-			linux_off_t offset, linux_off_t len, int advice); }
+270	STD		{ int|linux_sys||fadvise64_64(int fd, off_t offset, \
+			off_t len, int advice); }
 271	UNIMPL		pciconfig_iobase
 272	UNIMPL		pciconfig_read
 273	UNIMPL		pciconfig_write

Index: src/sys/compat/linux/arch/i386/syscalls.master
diff -u src/sys/compat/linux/arch/i386/syscalls.master:1.114 src/sys/compat/linux/arch/i386/syscalls.master:1.115
--- src/sys/compat/linux/arch/i386/syscalls.master:1.114	Sun May  4 10:08:53 2014
+++ src/sys/compat/linux/arch/i386/syscalls.master	Sat May 17 09:23:51 2014
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.114 2014/05/04 10:08:53 njoly Exp $
+	$NetBSD: syscalls.master,v 1.115 2014/05/17 09:23:51 njoly Exp $
 
 ;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
 
@@ -423,8 +423,8 @@
 247	UNIMPL		io_getevents
 248	UNIMPL		io_submit
 249	UNIMPL		io_cancel
-250	STD		{ int|linux_sys||fadvise64(i

CVS commit: src/sys/compat/linux/arch

2014-05-17 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Sat May 17 09:25:07 UTC 2014

Modified Files:
src/sys/compat/linux/arch/alpha: linux_syscall.h linux_syscallargs.h
linux_syscalls.c linux_sysent.c
src/sys/compat/linux/arch/amd64: linux_syscall.h linux_syscallargs.h
linux_syscalls.c linux_sysent.c
src/sys/compat/linux/arch/arm: linux_syscall.h linux_syscallargs.h
linux_syscalls.c linux_sysent.c
src/sys/compat/linux/arch/i386: linux_syscall.h linux_syscallargs.h
linux_syscalls.c linux_sysent.c
src/sys/compat/linux/arch/m68k: linux_syscall.h linux_syscallargs.h
linux_syscalls.c linux_sysent.c
src/sys/compat/linux/arch/mips: linux_syscall.h linux_syscallargs.h
linux_syscalls.c linux_sysent.c
src/sys/compat/linux/arch/powerpc: linux_syscall.h linux_syscallargs.h
linux_syscalls.c linux_sysent.c

Log Message:
Regen for fadvise64 offset types changes.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/compat/linux/arch/alpha/linux_syscall.h \
src/sys/compat/linux/arch/alpha/linux_sysent.c
cvs rdiff -u -r1.91 -r1.92 \
src/sys/compat/linux/arch/alpha/linux_syscallargs.h
cvs rdiff -u -r1.93 -r1.94 src/sys/compat/linux/arch/alpha/linux_syscalls.c
cvs rdiff -u -r1.50 -r1.51 src/sys/compat/linux/arch/amd64/linux_syscall.h \
src/sys/compat/linux/arch/amd64/linux_syscallargs.h \
src/sys/compat/linux/arch/amd64/linux_syscalls.c \
src/sys/compat/linux/arch/amd64/linux_sysent.c
cvs rdiff -u -r1.60 -r1.61 src/sys/compat/linux/arch/arm/linux_syscall.h \
src/sys/compat/linux/arch/arm/linux_syscallargs.h \
src/sys/compat/linux/arch/arm/linux_syscalls.c \
src/sys/compat/linux/arch/arm/linux_sysent.c
cvs rdiff -u -r1.99 -r1.100 src/sys/compat/linux/arch/i386/linux_syscall.h \
src/sys/compat/linux/arch/i386/linux_syscallargs.h \
src/sys/compat/linux/arch/i386/linux_sysent.c
cvs rdiff -u -r1.100 -r1.101 src/sys/compat/linux/arch/i386/linux_syscalls.c
cvs rdiff -u -r1.90 -r1.91 src/sys/compat/linux/arch/m68k/linux_syscall.h \
src/sys/compat/linux/arch/m68k/linux_syscalls.c \
src/sys/compat/linux/arch/m68k/linux_sysent.c
cvs rdiff -u -r1.89 -r1.90 src/sys/compat/linux/arch/m68k/linux_syscallargs.h
cvs rdiff -u -r1.57 -r1.58 src/sys/compat/linux/arch/mips/linux_syscall.h
cvs rdiff -u -r1.56 -r1.57 src/sys/compat/linux/arch/mips/linux_syscallargs.h \
src/sys/compat/linux/arch/mips/linux_syscalls.c \
src/sys/compat/linux/arch/mips/linux_sysent.c
cvs rdiff -u -r1.67 -r1.68 src/sys/compat/linux/arch/powerpc/linux_syscall.h \
src/sys/compat/linux/arch/powerpc/linux_sysent.c
cvs rdiff -u -r1.66 -r1.67 \
src/sys/compat/linux/arch/powerpc/linux_syscallargs.h \
src/sys/compat/linux/arch/powerpc/linux_syscalls.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/compat/linux/arch/alpha/linux_syscall.h
diff -u src/sys/compat/linux/arch/alpha/linux_syscall.h:1.92 src/sys/compat/linux/arch/alpha/linux_syscall.h:1.93
--- src/sys/compat/linux/arch/alpha/linux_syscall.h:1.92	Tue May  6 17:34:39 2014
+++ src/sys/compat/linux/arch/alpha/linux_syscall.h	Sat May 17 09:25:06 2014
@@ -1,10 +1,10 @@
-/* $NetBSD: linux_syscall.h,v 1.92 2014/05/06 17:34:39 njoly Exp $ */
+/* $NetBSD: linux_syscall.h,v 1.93 2014/05/17 09:25:06 njoly Exp $ */
 
 /*
  * System call numbers.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from	NetBSD: syscalls.master,v 1.86 2014/05/06 17:33:35 njoly Exp
+ * created from	NetBSD: syscalls.master,v 1.87 2014/05/17 09:23:51 njoly Exp
  */
 
 #ifndef _LINUX_SYS_SYSCALL_H_
@@ -576,7 +576,7 @@
 /* syscall: "set_tid_address" ret: "int" args: "int *" */
 #define	LINUX_SYS_set_tid_address	411
 
-/* syscall: "fadvise64" ret: "int" args: "int" "linux_off_t" "size_t" "int" */
+/* syscall: "fadvise64" ret: "int" args: "int" "off_t" "size_t" "int" */
 #define	LINUX_SYS_fadvise64	413
 
 /* syscall: "clock_settime" ret: "int" args: "clockid_t" "struct linux_timespec *" */
Index: src/sys/compat/linux/arch/alpha/linux_sysent.c
diff -u src/sys/compat/linux/arch/alpha/linux_sysent.c:1.92 src/sys/compat/linux/arch/alpha/linux_sysent.c:1.93
--- src/sys/compat/linux/arch/alpha/linux_sysent.c:1.92	Tue May  6 17:34:39 2014
+++ src/sys/compat/linux/arch/alpha/linux_sysent.c	Sat May 17 09:25:06 2014
@@ -1,14 +1,14 @@
-/* $NetBSD: linux_sysent.c,v 1.92 2014/05/06 17:34:39 njoly Exp $ */
+/* $NetBSD: linux_sysent.c,v 1.93 2014/05/17 09:25:06 njoly Exp $ */
 
 /*
  * System call switch table.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from	NetBSD: syscalls.master,v 1.86 2014/05/06 17:33:35 njoly Exp
+ * created from	NetBSD: syscalls.master,v 1.87 2014/05/17 09:23:51 njoly Exp
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_sysent.c,v 1.92 2014/05/06 17:34:39 njoly Exp $");
+__KER

CVS commit: src/sys/compat/linux32/common

2014-05-17 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Sat May 17 09:30:07 UTC 2014

Modified Files:
src/sys/compat/linux32/common: linux32_fcntl.c

Log Message:
Fix fadvise64 syscalls. Unlike our, linux fadvise syscall do not
return error code; call do_posix_fadvise().


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/compat/linux32/common/linux32_fcntl.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/compat/linux32/common/linux32_fcntl.c
diff -u src/sys/compat/linux32/common/linux32_fcntl.c:1.9 src/sys/compat/linux32/common/linux32_fcntl.c:1.10
--- src/sys/compat/linux32/common/linux32_fcntl.c:1.9	Mon May 30 17:50:32 2011
+++ src/sys/compat/linux32/common/linux32_fcntl.c	Sat May 17 09:30:07 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux32_fcntl.c,v 1.9 2011/05/30 17:50:32 alnsn Exp $ */
+/*	$NetBSD: linux32_fcntl.c,v 1.10 2014/05/17 09:30:07 njoly Exp $ */
 
 /*-
  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: linux32_fcntl.c,v 1.9 2011/05/30 17:50:32 alnsn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_fcntl.c,v 1.10 2014/05/17 09:30:07 njoly Exp $");
 
 #include 
 #include 
@@ -151,20 +151,15 @@ linux32_sys_fadvise64(struct lwp *l,
 {
 	/* {
 		syscallarg(int) fd;
-		syscallarg(off_t) offset;
-		syscallarg(size_t) len;
+		syscallarg(uint32_t) offlo;
+		syscallarg(uint32_t) offhi;
+		syscallarg(netbsd32_size_t) len;
 		syscallarg(int) advice;
 	} */
-	struct sys___posix_fadvise50_args ua;
+	off_t off = ((off_t)SCARG(uap, offhi) << 32) + SCARG(uap, offlo);
 
-	/* Linux doesn't have the 'pad' pseudo-parameter */
-	NETBSD32TO64_UAP(fd);
-	SCARG(&ua, PAD) = 0;
-	SCARG(&ua, offset) = ((off_t)SCARG(uap, offhi) << 32) + SCARG(uap, offlo);
-	SCARG(&ua, len) = SCARG(uap, len);
-	SCARG(&ua, advice) = linux_to_bsd_posix_fadv(SCARG(uap, advice));
-
-	return sys___posix_fadvise50(l, &ua, retval);
+	return do_posix_fadvise(SCARG(uap, fd), off,
+	SCARG(uap, len), linux_to_bsd_posix_fadv(SCARG(uap, advice)));
 }
 
 int
@@ -173,18 +168,15 @@ linux32_sys_fadvise64_64(struct lwp *l,
 {
 	/* {
 		syscallarg(int) fd;
-		syscallarg(off_t) offset;
-		syscallarg(off_t) len;
+		syscallarg(uint32_t) offlo;
+		syscallarg(uint32_t) offhi;
+		syscallarg(uint32_t) lenlo;
+		syscallarg(uint32_t) lenhi;
 		syscallarg(int) advice;
 	} */
-	struct sys___posix_fadvise50_args ua;
-
-	/* Linux doesn't have the 'pad' pseudo-parameter */
-	NETBSD32TO64_UAP(fd);
-	SCARG(&ua, PAD) = 0;
-	SCARG(&ua, offset) = ((off_t)SCARG(uap, offhi) << 32) + SCARG(uap, offlo);
-	SCARG(&ua, len) = ((off_t)SCARG(uap, lenhi) << 32) + SCARG(uap, lenlo);
-	SCARG(&ua, advice) = linux_to_bsd_posix_fadv(SCARG(uap, advice));
+	off_t off = ((off_t)SCARG(uap, offhi) << 32) + SCARG(uap, offlo);
+	off_t len = ((off_t)SCARG(uap, lenhi) << 32) + SCARG(uap, lenlo);
 
-	return sys___posix_fadvise50(l, &ua, retval);
+	return do_posix_fadvise(SCARG(uap, fd), off,
+	len, linux_to_bsd_posix_fadv(SCARG(uap, advice)));
 }



CVS commit: src/usr.bin/find

2014-05-17 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Sat May 17 11:31:40 UTC 2014

Modified Files:
src/usr.bin/find: find.1

Log Message:
Add an example with find ... -exec sh -c 


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/usr.bin/find/find.1

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

Modified files:

Index: src/usr.bin/find/find.1
diff -u src/usr.bin/find/find.1:1.80 src/usr.bin/find/find.1:1.81
--- src/usr.bin/find/find.1:1.80	Fri Feb  8 12:50:51 2013
+++ src/usr.bin/find/find.1	Sat May 17 11:31:40 2014
@@ -1,4 +1,4 @@
-.\"	$NetBSD: find.1,v 1.80 2013/02/08 12:50:51 wiz Exp $
+.\"	$NetBSD: find.1,v 1.81 2014/05/17 11:31:40 apb Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\"	from: @(#)find.1	8.7 (Berkeley) 5/9/95
 .\"
-.Dd August 26, 2012
+.Dd May 17, 2014
 .Dt FIND 1
 .Os
 .Sh NAME
@@ -783,6 +783,8 @@ but do not print them.
 .It Li "find / \e( \-newer ttt \-or \-user wnj \e) \-ls \-exit 1"
 Same as above, but list the first file matching the criteria before exiting
 with a value of 1.
+.It Li "find . \-type f \-exec sh \-c 'file=\*[q]$1\*[q]; ...;' - {} \;"
+Perform an arbitrarily complex shell command for every file.
 .El
 .Sh SEE ALSO
 .Xr chflags 1 ,



CVS commit: src/lib/libossaudio

2014-05-17 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Sat May 17 12:38:42 UTC 2014

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
Adds ioctls and defines for OSSv4 compatibility.

The ioctl definitions and accompanying structures were
taken from FreeBSD's soundcard.h, hopefully providing
some binary compatibility.

The ioctls are as follows:
SNDCTL_SYSINFO: Returns a structure containing
details about the audio device.
SNDCTL_ENGINEINFO - SNDCTL_AUDIOINFO: Returns a
structure with playback/recording
characteristics.
SNDCTL_DSP_GETPLAYVOL, SNDCTL_DSP_SETPLAYVOL,
SNDCTL_DSP_GETRECVOL, SNDCTL_DSP_SETRECVOL:
Retrieves/Sets Playback/Recording volume.
SNDCTL_DSP_SKIP - SNDCTL_DSP_SILENCE: These ioctls
were intended to manipulate the underlying
audio buffer skip or insert silence.  These
return EINVAL.

SOUND_VERSION is unchanged, but is definable,  It will be
changed when the mixer OSSv4 ioctls are written.

Addresses PR 46611
This commit was approved by wiz@.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.22 -r1.23 src/lib/libossaudio/soundcard.h

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

Modified files:

Index: src/lib/libossaudio/ossaudio.c
diff -u src/lib/libossaudio/ossaudio.c:1.28 src/lib/libossaudio/ossaudio.c:1.29
--- src/lib/libossaudio/ossaudio.c:1.28	Sat May  5 15:57:45 2012
+++ src/lib/libossaudio/ossaudio.c	Sat May 17 12:38:42 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.28 2012/05/05 15:57:45 christos Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.29 2014/05/17 12:38:42 nat Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.28 2012/05/05 15:57:45 christos Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.29 2014/05/17 12:38:42 nat Exp $");
 
 /*
  * This is an OSS (Linux) sound API emulator.
@@ -44,6 +44,9 @@ __RCSID("$NetBSD: ossaudio.c,v 1.28 2012
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 
 #include "soundcard.h"
@@ -93,9 +96,17 @@ audio_ioctl(int fd, unsigned long com, v
 	struct audio_buf_info bufinfo;
 	struct count_info cntinfo;
 	struct audio_encoding tmpenc;
+	struct oss_sysinfo tmpsysinfo;
+	struct oss_audioinfo *tmpaudioinfo;
+	audio_device_t tmpaudiodev;
+	struct stat tmpstat;
+	dev_t devno;
+	char version[32] = "4.01";
+	char license[16] = "NetBSD";
 	u_int u;
 	int idat, idata;
 	int retval;
+	int i;
 
 	idat = 0;
 
@@ -316,13 +327,21 @@ audio_ioctl(int fd, unsigned long com, v
 idat |= AFMT_S8;
 break;
 			case AUDIO_ENCODING_SLINEAR_LE:
-if (tmpenc.precision == 16)
+if (tmpenc.precision == 32)
+	idat |= AFMT_S32_LE;
+else if (tmpenc.precision == 24)
+	idat |= AFMT_S24_LE;
+else if (tmpenc.precision == 16)
 	idat |= AFMT_S16_LE;
 else
 	idat |= AFMT_S8;
 break;
 			case AUDIO_ENCODING_SLINEAR_BE:
-if (tmpenc.precision == 16)
+if (tmpenc.precision == 32)
+	idat |= AFMT_S32_BE;
+else if (tmpenc.precision == 24)
+	idat |= AFMT_S24_BE;
+else if (tmpenc.precision == 16)
 	idat |= AFMT_S16_BE;
 else
 	idat |= AFMT_S8;
@@ -445,6 +464,130 @@ audio_ioctl(int fd, unsigned long com, v
 		cntinfo.ptr = tmpoffs.offset;
 		*(struct count_info *)argp = cntinfo;
 		break;
+	case SNDCTL_SYSINFO:
+		strncpy(tmpsysinfo.product, "OSS/NetBSD", 31);
+		tmpsysinfo.product[31] = 0; 
+		strncpy(tmpsysinfo.version, version, 31); 
+		tmpsysinfo.version[31] = 0; 
+		strncpy(tmpsysinfo.license, license, 15);
+		tmpsysinfo.license[15] = 0; 
+		tmpsysinfo.versionnum = SOUND_VERSION;
+		memset(tmpsysinfo.options, 0, 8);
+		tmpsysinfo.numaudios = OSS_MAX_AUDIO_DEVS;
+		tmpsysinfo.numaudioengines = 1;
+		memset(tmpsysinfo.openedaudio, 0, 8);
+		tmpsysinfo.numsynths = 1;
+		tmpsysinfo.nummidis = -1;
+		tmpsysinfo.numtimers = -1;
+		tmpsysinfo.nummixers = 1;
+		tmpsysinfo.numcards = 1;
+		memset(tmpsysinfo.openedmidi, 0, 8);
+		*(struct oss_sysinfo *)argp = tmpsysinfo;
+		break;
+	case SNDCTL_ENGINEINFO:
+	case SNDCTL_AUDIOINFO:
+		devno = 0;
+		tmpaudioinfo = (struct oss_audioinfo*)argp;
+		if (tmpaudioinfo == NULL)
+			return EINVAL;
+		if (tmpaudioinfo->dev < 0) {
+			fstat(fd, &tmpstat);
+			if ((tmpstat.st_rdev & 0xff00) == 0x2a00)
+devno = tmpstat.st_rdev & 0xff;
+			if (devno >= 0x80)
+tmpaudioinfo->dev = devno & 0x7f;
+		}
+		if (tmpaudioinfo->dev < 0)
+			tmpaudioinfo->dev = 0;
+
+		snprintf(tmpaudioinfo->devnode, OSS_DEVNODE_SIZE,
+		"/dev/audio%d", tmpaudioinfo->dev); 
+
+		retval = ioctl(fd, AUDIO_GETDEV, &tmpaudiodev);
+		if (retval < 0)
+			return retval;
+		retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
+		if (retval < 0)
+			return retval;
+		retval = ioctl(fd, AUDIO_GETPROPS, &idata);

CVS commit: src/sys/net

2014-05-17 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat May 17 14:51:10 UTC 2014

Modified Files:
src/sys/net: if_ppp.c

Log Message:
ppp_inproc: handle non-IP protocols correctly (hi msaitoh); PR/48813.


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.143 src/sys/net/if_ppp.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/net/if_ppp.c
diff -u src/sys/net/if_ppp.c:1.142 src/sys/net/if_ppp.c:1.143
--- src/sys/net/if_ppp.c:1.142	Thu May 15 09:23:03 2014
+++ src/sys/net/if_ppp.c	Sat May 17 14:51:09 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ppp.c,v 1.142 2014/05/15 09:23:03 msaitoh Exp $	*/
+/*	$NetBSD: if_ppp.c,v 1.143 2014/05/17 14:51:09 rmind Exp $	*/
 /*	Id: if_ppp.c,v 1.6 1997/03/04 03:33:00 paulus Exp 	*/
 
 /*
@@ -102,7 +102,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.142 2014/05/15 09:23:03 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.143 2014/05/17 14:51:09 rmind Exp $");
 
 #include "ppp.h"
 
@@ -1676,7 +1676,9 @@ ppp_inproc(struct ppp_softc *sc, struct 
 	goto bad;
 }
 IF_ENQUEUE(inq, m);
-schednetisr(isr);
+if (__predict_true(isr)) {
+schednetisr(isr);
+}
 splx(s);
 ifp->if_ipackets++;
 ifp->if_ibytes += ilen;



CVS commit: src/sys/ufs/ufs

2014-05-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat May 17 19:11:40 UTC 2014

Modified Files:
src/sys/ufs/ufs: inode.h

Log Message:
Reorder struct ufid members to avoid padding (and save 4 bytes) on some
architectures.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/ufs/ufs/inode.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/ufs/ufs/inode.h
diff -u src/sys/ufs/ufs/inode.h:1.67 src/sys/ufs/ufs/inode.h:1.68
--- src/sys/ufs/ufs/inode.h:1.67	Wed May 14 13:46:19 2014
+++ src/sys/ufs/ufs/inode.h	Sat May 17 19:11:40 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: inode.h,v 1.67 2014/05/14 13:46:19 martin Exp $	*/
+/*	$NetBSD: inode.h,v 1.68 2014/05/17 19:11:40 martin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1989, 1993
@@ -295,8 +295,8 @@ struct indir {
 struct ufid {
 	u_int16_t ufid_len;	/* Length of structure. */
 	u_int16_t ufid_pad;	/* Force 32-bit alignment. */
-	ino_t ufid_ino;	/* File number (ino). */
 	int32_t	  ufid_gen;	/* Generation number. */
+	ino_t ufid_ino;	/* File number (ino). */
 };
 #endif /* _KERNEL */
 



CVS commit: src/share/zoneinfo

2014-05-17 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Sat May 17 19:53:22 UTC 2014

Added Files:
src/share/zoneinfo: tzdata2netbsd

Log Message:
Add tzdata2netbsd, a script to help import new versions of tzdata.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/share/zoneinfo/tzdata2netbsd

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

Added files:

Index: src/share/zoneinfo/tzdata2netbsd
diff -u /dev/null src/share/zoneinfo/tzdata2netbsd:1.1
--- /dev/null	Sat May 17 19:53:22 2014
+++ src/share/zoneinfo/tzdata2netbsd	Sat May 17 19:53:22 2014
@@ -0,0 +1,204 @@
+# $NetBSD: tzdata2netbsd,v 1.1 2014/05/17 19:53:22 apb Exp $
+#
+# For use by NetBSD developers when updating to new versions of tzdata.
+#
+
+OLDVER=2013i
+NEWVER=2014c
+
+# Uppercase variants of OLDVER and NEWVER
+OLDVER_UC="$( echo "${OLDVER}" | tr '[a-z]' '[A-Z]' )"
+NEWVER_UC="$( echo "${NEWVER}" | tr '[a-z]' '[A-Z]' )"
+
+# Tags for use with version control systems
+CVSOLDTAG="TZDATA${OLDVER_UC}"
+CVSNEWTAG="TZDATA${NEWVER_UC}"
+CVSBRANCHTAG="TZDATA"
+GITHUBTAG="${NEWVER}"
+
+# URLs for fetching distribution files, etc.
+DISTURL="ftp://ftp.iana.org/tz/releases/tzdata${NEWVER}.tar.gz";
+SIGURL="${DISTURL}.asc"
+NEWSURL="https://github.com/eggert/tz/raw/${GITHUBTAG}/NEWS";
+
+# Directories
+REPODIR="src/share/zoneinfo"	# relative to the NetSBD CVS repository
+WORKDIR="$(pwd)/update-work"
+EXTRACTDIR="${WORKDIR}/extract/${NEWVER}"
+
+# Files in the work directory
+DISTFILE="${WORKDIR}/${DISTURL##*/}"
+SIGFILE="${DISTFILE}.sig"
+NEWSFILE="${WORKDIR}/NEWS"
+NEWSTRIMFILE="${WORKDIR}/NEWS.trimmed"
+IMPORTMSGFILE="${WORKDIR}/import.msg"
+MERGSMSGFILE="${WORKDIR}/merge.msg"
+
+DOIT()
+{
+	really_do_it=false
+
+	if $really_do_it; then
+		"$@"
+	else
+		echo "NOT REALLY DOING:" "$@"
+	fi
+}
+
+mkworkdir()
+{
+	mkdir -p "${WORKDIR}"
+}
+
+fetch()
+{
+	[ -f "${DISTFILE}" ] || ftp -o "${DISTFILE}" "${DISTURL}"
+	[ -f "${SIGFILE}" ] || ftp -o "${SIGFILE}" "${SIGURL}"
+	[ -f "${NEWSFILE}" ] || ftp -o "${NEWSFILE}" "${NEWSURL}"
+}
+
+checksig()
+{
+	gpg --verify "${SIGFILE}" "${DISTFILE}"
+}
+
+extract()
+{
+	mkdir -p "${EXTRACTDIR}"
+	tar -z -xf "${DISTFILE}" -C "${EXTRACTDIR}"
+}
+
+# Each release has a heading in the NEWS file, like
+# "Release  - ".
+# Find the relevant part of the NEWS file for all release between
+# OLDVAR and NEWVER, and save them to NEWSTRIMFILE.
+#
+trimnews()
+{
+	awk -v oldver="${OLDVER}" -v newver="${NEWVER}" \
+	'
+		BEGIN {inrange = 0}
+		/^Release [0-9]+[a-z]+ - .*/ {
+			inrange = ($2 > oldver && $2 <= newver)
+		}
+		// { if (inrange) print; }
+		' \
+		<"${NEWSFILE}" >"${NEWSTRIMFILE}"
+}
+
+# Create IMPORTMSGFILE from NEWSTRIMFILE, by ignoring some sections,
+# keeping only the first sentence from paragraphs in other sections,
+# and changing the format.  The result should be edited by hand before
+# performing a cvs commit.
+#
+mkimportmsg()
+{
+	[ -s "${IMPORTMSGFILE}" ] && return
+	awk -v oldver="${OLDVER}" -v newver="${NEWVER}" \
+	-v disturl="${DISTURL}" \
+	'
+		BEGIN {
+			bullet = "  * ";
+			indent = "";
+			blankline = 0;
+			goodsection = 0;
+			havesentence = 0;
+			print "Import tzdata"newver" from "disturl;
+		}
+		/^Release/ {
+			ver = $2;
+			date = gensub(".* - ", "", 1, $0);
+			print "";
+			print "Summary of changes in tzdata"ver \
+" ("date"):";
+		}
+		/^$/ { blankline = 1; havesentence = 0; }
+		/^  Changes affecting/ { goodsection = 0; }
+		/^  Changes affecting.*time/ { goodsection = 1; }
+		/^  Changes affecting.*documentation/ || \
+		/^  Changes affecting.*commentary/ {
+			t = gensub("^ *", "", 1, $0);
+			t = gensub("\\.*$", ".", 1, t);
+			print bullet t;
+			goodsection = 0;
+		}
+		/^.*/ && goodsection {
+			# In a paragraph in a "good" section.
+			# Ignore leading spaces, and ignore anything
+			# after the first sentence.
+			# First line of paragraph gets a bullet.
+			t = gensub("^ *", "", 1, $0);
+			t = gensub("\\. .*", ".", 1, t);
+			if (blankline) print bullet t;
+			else if (! havesentence) print indent t;
+			havesentence = (havesentence || (t ~ "\\.$"));
+		}
+		/./ { blankline = 0; }
+		' \
+		<"${NEWSTRIMFILE}" >"${IMPORTMSGFILE}"
+}
+
+editimportmsg()
+{
+	cat <

CVS commit: src/sys/sys

2014-05-17 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat May 17 20:34:49 UTC 2014

Modified Files:
src/sys/sys: queue.h

Log Message:
Add LIST_CONCAT().


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/sys/queue.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/sys/queue.h
diff -u src/sys/sys/queue.h:1.65 src/sys/sys/queue.h:1.66
--- src/sys/sys/queue.h:1.65	Wed Dec 25 17:19:34 2013
+++ src/sys/sys/queue.h	Sat May 17 20:34:49 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: queue.h,v 1.65 2013/12/25 17:19:34 christos Exp $	*/
+/*	$NetBSD: queue.h,v 1.66 2014/05/17 20:34:49 rmind Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993
@@ -211,6 +211,13 @@ struct {\
 	((tvar) = LIST_NEXT((var), field), 1);			\
 	(var) = (tvar))
 
+#define	LIST_CONCAT(head1, head2) do {	\
+	if (!LIST_EMPTY((head2))) {	\
+		(head1)->lh_first = (head2)->lh_first;			\
+		LIST_INIT((head2));	\
+	}\
+} while (/*CONSTCOND*/0)
+
 /*
  * List functions.
  */



CVS commit: src/sys/arch/sgimips/dev

2014-05-17 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat May 17 20:44:08 UTC 2014

Modified Files:
src/sys/arch/sgimips/dev: crime.c

Log Message:
split crime_bus_reset() into crime_{cpu,mem}_reset() and only reset
the cpu or the memory upon either error, not both.

seems to make my O2 slightly less likely to hang, and matches what
the linux crime driver does.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/sgimips/dev/crime.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/arch/sgimips/dev/crime.c
diff -u src/sys/arch/sgimips/dev/crime.c:1.36 src/sys/arch/sgimips/dev/crime.c:1.37
--- src/sys/arch/sgimips/dev/crime.c:1.36	Thu Aug 18 02:56:21 2011
+++ src/sys/arch/sgimips/dev/crime.c	Sat May 17 20:44:08 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: crime.c,v 1.36 2011/08/18 02:56:21 macallan Exp $	*/
+/*	$NetBSD: crime.c,v 1.37 2014/05/17 20:44:08 mrg Exp $	*/
 
 /*
  * Copyright (c) 2004 Christopher SEKIYA
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: crime.c,v 1.36 2011/08/18 02:56:21 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crime.c,v 1.37 2014/05/17 20:44:08 mrg Exp $");
 
 #include 
 #include 
@@ -63,7 +63,9 @@ __KERNEL_RCSID(0, "$NetBSD: crime.c,v 1.
 
 static int	crime_match(device_t, struct cfdata *, void *);
 static void	crime_attach(device_t, device_t, void *);
-void		crime_bus_reset(void);
+static void	crime_mem_reset(void);
+static void	crime_cpu_reset(void);
+static void	crime_bus_reset(void);
 void		crime_watchdog_reset(void);
 void		crime_watchdog_disable(void);
 void		crime_intr(vaddr_t, uint32_t, uint32_t);
@@ -142,7 +144,8 @@ crime_attach(device_t parent, device_t s
 	aprint_normal(" (CRIME_ID: %" PRIu64 ")\n", crm_id);
 
 	/* reset CRIME CPU & memory error registers */
-	crime_bus_reset();
+	crime_mem_reset();
+	crime_cpu_reset();
 
 	crime_watchdog_disable();
 
@@ -237,17 +240,17 @@ crime_intr(vaddr_t pc, uint32_t status, 
 			CRIME_MEM_ERROR_STAT);
 			printf("crime: memory error address %" PRIu64 
 			" status %" PRIu64 "\n", address << 2, stat);
-			crime_bus_reset();
+			crime_mem_reset();
 		}
 
 		if (crime_ipending & CRIME_INT_CRMERR) {
 			stat = bus_space_read_8(crm_iot, crm_ioh,
 			CRIME_CPU_ERROR_STAT);
-printf("crime: cpu error %" PRIu64 " at"
-" address %" PRIu64 "\n", stat,
-bus_space_read_8(crm_iot, crm_ioh,
-CRIME_CPU_ERROR_ADDR));
-			crime_bus_reset();
+			address = bus_space_read_8(crm_iot, crm_ioh,
+			CRIME_CPU_ERROR_ADDR) << 2;
+			printf("crime: cpu error %" PRIu64 " at address %"
+			   PRIu64 "\n", stat, address);
+			crime_cpu_reset();
 		}
 	}
 
@@ -283,14 +286,28 @@ crime_intr_unmask(unsigned int intr)
 }
 
 void
-crime_bus_reset(void)
+crime_mem_reset(void)
 {
 
-	bus_space_write_8(crm_iot, crm_ioh, CRIME_CPU_ERROR_STAT, 0);
 	bus_space_write_8(crm_iot, crm_ioh, CRIME_MEM_ERROR_STAT, 0);
 }
 
 void
+crime_cpu_reset(void)
+{
+
+	bus_space_write_8(crm_iot, crm_ioh, CRIME_CPU_ERROR_STAT, 0);
+}
+
+void
+crime_bus_reset(void)
+{
+
+	crime_mem_reset();
+	crime_cpu_reset();
+}
+
+void
 crime_watchdog_reset(void)
 {
 



CVS commit: src/sys

2014-05-17 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat May 17 20:44:24 UTC 2014

Modified Files:
src/sys/altq: altq_subr.c
src/sys/arch/x86/x86: vmt.c
src/sys/dist/pf/net: pf_if.c
src/sys/net: if.h
src/sys/netinet: ip_carp.c
src/sys/netinet6: in6.c in6_ifattach.c nd6.c

Log Message:
- Move IFNET_*() macros under #ifdef _KERNEL.
- Replace TAILQ_FOREACH on ifnet with IFNET_FOREACH().


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/altq/altq_subr.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/x86/vmt.c
cvs rdiff -u -r1.24 -r1.25 src/sys/dist/pf/net/pf_if.c
cvs rdiff -u -r1.163 -r1.164 src/sys/net/if.h
cvs rdiff -u -r1.54 -r1.55 src/sys/netinet/ip_carp.c
cvs rdiff -u -r1.169 -r1.170 src/sys/netinet6/in6.c
cvs rdiff -u -r1.89 -r1.90 src/sys/netinet6/in6_ifattach.c
cvs rdiff -u -r1.148 -r1.149 src/sys/netinet6/nd6.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/altq/altq_subr.c
diff -u src/sys/altq/altq_subr.c:1.28 src/sys/altq/altq_subr.c:1.29
--- src/sys/altq/altq_subr.c:1.28	Sun Jan  4 18:41:36 2009
+++ src/sys/altq/altq_subr.c	Sat May 17 20:44:24 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: altq_subr.c,v 1.28 2009/01/04 18:41:36 pooka Exp $	*/
+/*	$NetBSD: altq_subr.c,v 1.29 2014/05/17 20:44:24 rmind Exp $	*/
 /*	$KAME: altq_subr.c,v 1.24 2005/04/13 03:44:25 suz Exp $	*/
 
 /*
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: altq_subr.c,v 1.28 2009/01/04 18:41:36 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altq_subr.c,v 1.29 2014/05/17 20:44:24 rmind Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altq.h"
@@ -356,7 +356,7 @@ tbr_timeout(void *arg)
 
 	active = 0;
 	s = splnet();
-	for (ifp = TAILQ_FIRST(&ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list)) {
+	IFNET_FOREACH(ifp) {
 		if (!TBR_IS_ENABLED(&ifp->if_snd))
 			continue;
 		active++;

Index: src/sys/arch/x86/x86/vmt.c
diff -u src/sys/arch/x86/x86/vmt.c:1.8 src/sys/arch/x86/x86/vmt.c:1.9
--- src/sys/arch/x86/x86/vmt.c:1.8	Sat Mar 16 01:26:53 2013
+++ src/sys/arch/x86/x86/vmt.c	Sat May 17 20:44:24 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: vmt.c,v 1.8 2013/03/16 01:26:53 jmmv Exp $ */
+/* $NetBSD: vmt.c,v 1.9 2014/05/17 20:44:24 rmind Exp $ */
 /* $OpenBSD: vmt.c,v 1.11 2011/01/27 21:29:25 dtucker Exp $ */
 
 /*
@@ -806,7 +806,7 @@ vmt_tclo_tick(void *xarg)
 
 		/* find first available ipv4 address */
 		guest_ip = NULL;
-		TAILQ_FOREACH(iface, &ifnet, if_list) {
+		IFNET_FOREACH(iface) {
 			struct ifaddr *iface_addr;
 
 			/* skip loopback */

Index: src/sys/dist/pf/net/pf_if.c
diff -u src/sys/dist/pf/net/pf_if.c:1.24 src/sys/dist/pf/net/pf_if.c:1.25
--- src/sys/dist/pf/net/pf_if.c:1.24	Mon Jul  1 08:32:48 2013
+++ src/sys/dist/pf/net/pf_if.c	Sat May 17 20:44:24 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pf_if.c,v 1.24 2013/07/01 08:32:48 skrll Exp $	*/
+/*	$NetBSD: pf_if.c,v 1.25 2014/05/17 20:44:24 rmind Exp $	*/
 /*	$OpenBSD: pf_if.c,v 1.47 2007/07/13 09:17:48 markus Exp $ */
 
 /*
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pf_if.c,v 1.24 2013/07/01 08:32:48 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pf_if.c,v 1.25 2014/05/17 20:44:24 rmind Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -100,10 +100,6 @@ RB_GENERATE(pfi_ifhead, pfi_kif, pfik_tr
 void
 pfi_initialize(void)
 {
-#ifdef __NetBSD__
-	int i;
-#endif /* __NetBSD__ */
-
 	if (pfi_all != NULL)	/* already initialized */
 		return;
 
@@ -122,14 +118,10 @@ pfi_initialize(void)
 		panic("pfi_kif_get for pfi_all failed");
 
 #ifdef __NetBSD__
-	for (i = 0; i < if_indexlim; i++) {
-		struct ifnet *ifp = ifindex2ifnet[i];
-
-		if (ifp != NULL) {
-			pfi_init_groups(ifp);
-
-			pfi_attach_ifnet(ifp);
-		}
+	ifnet_t *ifp;
+	IFNET_FOREACH(ifp) {
+		pfi_init_groups(ifp);
+		pfi_attach_ifnet(ifp);
 	}
 
 	pfil_add_hook(pfil_ifnet_wrapper, NULL, PFIL_IFNET, if_pfil);
@@ -147,12 +139,10 @@ pfi_destroy(void)
 	pfil_remove_hook(pfil_ifaddr_wrapper, NULL, PFIL_IFADDR, if_pfil);
 	pfil_remove_hook(pfil_ifnet_wrapper, NULL, PFIL_IFNET, if_pfil);
 
-	for (i = 0; i < if_indexlim; i++) {
-		struct ifnet *ifp = ifindex2ifnet[i];
-
-		if (ifp != NULL) {
+	ifnet_t *ifp;
+	IFNET_FOREACH(ifp) {
+		if ((ifp = if_byindex(i)) != NULL) {
 			pfi_detach_ifnet(ifp);
-
 			pfi_destroy_groups(ifp);
 		}
 	}

Index: src/sys/net/if.h
diff -u src/sys/net/if.h:1.163 src/sys/net/if.h:1.164
--- src/sys/net/if.h:1.163	Sat Apr 26 11:16:22 2014
+++ src/sys/net/if.h	Sat May 17 20:44:24 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.163 2014/04/26 11:16:22 pooka Exp $	*/
+/*	$NetBSD: if.h,v 1.164 2014/05/17 20:44:24 rmind Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -845,15 +845,6 @@ do {	\
 MALLOC_DECLARE(M_IFADDR);
 MALLOC_DECLARE(M_IFMADDR);
 
-#define	IFNET_FIRST()			TAILQ_FIRST(&ifnet)
-#define	IFNET_NEXT(__ifp)		TAILQ_NEXT((__ifp), if_list)
-#define	IFNET_FOREACH(__ifp)		TAILQ_FOREACH(__ifp, &ifnet, if_l

CVS commit: src/sys/dist/pf/net

2014-05-17 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat May 17 21:00:33 UTC 2014

Modified Files:
src/sys/dist/pf/net: pf_if.c

Log Message:
Fix previous.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/dist/pf/net/pf_if.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/dist/pf/net/pf_if.c
diff -u src/sys/dist/pf/net/pf_if.c:1.25 src/sys/dist/pf/net/pf_if.c:1.26
--- src/sys/dist/pf/net/pf_if.c:1.25	Sat May 17 20:44:24 2014
+++ src/sys/dist/pf/net/pf_if.c	Sat May 17 21:00:33 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pf_if.c,v 1.25 2014/05/17 20:44:24 rmind Exp $	*/
+/*	$NetBSD: pf_if.c,v 1.26 2014/05/17 21:00:33 rmind Exp $	*/
 /*	$OpenBSD: pf_if.c,v 1.47 2007/07/13 09:17:48 markus Exp $ */
 
 /*
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pf_if.c,v 1.25 2014/05/17 20:44:24 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pf_if.c,v 1.26 2014/05/17 21:00:33 rmind Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -134,17 +134,14 @@ void
 pfi_destroy(void)
 {
 	struct pfi_kif *p;
-	int i;
+	ifnet_t *ifp;
 
 	pfil_remove_hook(pfil_ifaddr_wrapper, NULL, PFIL_IFADDR, if_pfil);
 	pfil_remove_hook(pfil_ifnet_wrapper, NULL, PFIL_IFNET, if_pfil);
 
-	ifnet_t *ifp;
 	IFNET_FOREACH(ifp) {
-		if ((ifp = if_byindex(i)) != NULL) {
-			pfi_detach_ifnet(ifp);
-			pfi_destroy_groups(ifp);
-		}
+		pfi_detach_ifnet(ifp);
+		pfi_destroy_groups(ifp);
 	}
 
 	while ((p = RB_MIN(pfi_ifhead, &pfi_ifs))) {



CVS commit: src

2014-05-17 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat May 17 21:22:56 UTC 2014

Modified Files:
src/share/man/man3: queue.3
src/sys/sys: queue.h

Log Message:
Rename LIST_CONCAT() to LIST_MOVE() as that is what it actually does (and
there is no point to implement LIST_CONCAT() which would iterate).  Update
the queue(3) manpage.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/share/man/man3/queue.3
cvs rdiff -u -r1.66 -r1.67 src/sys/sys/queue.h

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

Modified files:

Index: src/share/man/man3/queue.3
diff -u src/share/man/man3/queue.3:1.47 src/share/man/man3/queue.3:1.48
--- src/share/man/man3/queue.3:1.47	Thu Nov 28 16:45:36 2013
+++ src/share/man/man3/queue.3	Sat May 17 21:22:56 2014
@@ -1,4 +1,4 @@
-.\"	$NetBSD: queue.3,v 1.47 2013/11/28 16:45:36 wiz Exp $
+.\"	$NetBSD: queue.3,v 1.48 2014/05/17 21:22:56 rmind Exp $
 .\"
 .\" Copyright (c) 2000, 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -53,7 +53,7 @@
 .\"
 .\"	@(#)queue.3	8.1 (Berkeley) 12/13/93
 .\"
-.Dd November 27, 2013
+.Dd May 17, 2014
 .Dt QUEUE 3
 .Os
 .Sh NAME
@@ -85,6 +85,7 @@
 .Nm LIST_INSERT_HEAD ,
 .Nm LIST_REMOVE ,
 .Nm LIST_REPLACE ,
+.Nm LIST_MOVE ,
 .Nm SIMPLEQ_HEAD ,
 .Nm SIMPLEQ_HEAD_INITIALIZER ,
 .Nm SIMPLEQ_ENTRY ,
@@ -176,6 +177,7 @@
 .Fn LIST_INSERT_HEAD "LIST_HEAD *head" "TYPE *elm" "LIST_ENTRY NAME"
 .Fn LIST_REMOVE "TYPE *elm" "LIST_ENTRY NAME"
 .Fn LIST_REPLACE "TYPE *elm" "TYPE *new" "LIST_ENTRY NAME"
+.Fn LIST_MOVE "LIST_HEAD *head1" "LIST_HEAD *head2"
 .Pp
 .Fn SIMPLEQ_HEAD "HEADNAME" "TYPE"
 .Fn SIMPLEQ_HEAD_INITIALIZER "head"
@@ -661,6 +663,14 @@ replaces the element
 with
 .Fa new
 in the list.
+.Pp
+The macro
+.Nm LIST_MOVE
+moves the list headed by
+.Fa head1
+onto the list headed by
+.Fa head2 ,
+always making the former empty.
 .Sh LIST EXAMPLE
 .Bd -literal
 LIST_HEAD(listhead, entry) head;

Index: src/sys/sys/queue.h
diff -u src/sys/sys/queue.h:1.66 src/sys/sys/queue.h:1.67
--- src/sys/sys/queue.h:1.66	Sat May 17 20:34:49 2014
+++ src/sys/sys/queue.h	Sat May 17 21:22:56 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: queue.h,v 1.66 2014/05/17 20:34:49 rmind Exp $	*/
+/*	$NetBSD: queue.h,v 1.67 2014/05/17 21:22:56 rmind Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993
@@ -211,10 +211,11 @@ struct {\
 	((tvar) = LIST_NEXT((var), field), 1);			\
 	(var) = (tvar))
 
-#define	LIST_CONCAT(head1, head2) do {	\
-	if (!LIST_EMPTY((head2))) {	\
-		(head1)->lh_first = (head2)->lh_first;			\
-		LIST_INIT((head2));	\
+#define	LIST_MOVE(head1, head2) do {	\
+	LIST_INIT((head2));		\
+	if (!LIST_EMPTY((head1))) {	\
+		(head2)->lh_first = (head1)->lh_first;			\
+		LIST_INIT((head1));	\
 	}\
 } while (/*CONSTCOND*/0)
 



CVS commit: src/sys

2014-05-17 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat May 17 21:26:20 UTC 2014

Modified Files:
src/sys/compat/linux/common: linux_socket.c
src/sys/compat/linux32/common: linux32_socket.c
src/sys/netinet: ip_output.c
src/sys/netinet6: in6_src.c ip6_mroute.c ip6_output.c nd6_rtr.c
scope6.c

Log Message:
Replace open-coded access (and boundary checking) of ifindex2ifnet with
if_byindex() function.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/compat/linux/common/linux_socket.c
cvs rdiff -u -r1.17 -r1.18 src/sys/compat/linux32/common/linux32_socket.c
cvs rdiff -u -r1.224 -r1.225 src/sys/netinet/ip_output.c
cvs rdiff -u -r1.53 -r1.54 src/sys/netinet6/in6_src.c
cvs rdiff -u -r1.106 -r1.107 src/sys/netinet6/ip6_mroute.c
cvs rdiff -u -r1.155 -r1.156 src/sys/netinet6/ip6_output.c
cvs rdiff -u -r1.90 -r1.91 src/sys/netinet6/nd6_rtr.c
cvs rdiff -u -r1.8 -r1.9 src/sys/netinet6/scope6.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/compat/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.117 src/sys/compat/linux/common/linux_socket.c:1.118
--- src/sys/compat/linux/common/linux_socket.c:1.117	Mon Jan 27 19:19:15 2014
+++ src/sys/compat/linux/common/linux_socket.c	Sat May 17 21:26:20 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.c,v 1.117 2014/01/27 19:19:15 njoly Exp $	*/
+/*	$NetBSD: linux_socket.c,v 1.118 2014/05/17 21:26:20 rmind Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.117 2014/01/27 19:19:15 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.118 2014/05/17 21:26:20 rmind Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1105,10 +1105,7 @@ linux_getifname(struct lwp *l, register_
 	if (error)
 		return error;
 
-	if (ifr.ifr_ifru.ifru_ifindex >= if_indexlim)
-		return ENODEV;
-	
-	ifp = ifindex2ifnet[ifr.ifr_ifru.ifru_ifindex];
+	ifp = if_byindex(ifr.ifr_ifru.ifru_ifindex);
 	if (ifp == NULL)
 		return ENODEV;
 

Index: src/sys/compat/linux32/common/linux32_socket.c
diff -u src/sys/compat/linux32/common/linux32_socket.c:1.17 src/sys/compat/linux32/common/linux32_socket.c:1.18
--- src/sys/compat/linux32/common/linux32_socket.c:1.17	Fri Jan 11 19:01:36 2013
+++ src/sys/compat/linux32/common/linux32_socket.c	Sat May 17 21:26:20 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux32_socket.c,v 1.17 2013/01/11 19:01:36 christos Exp $ */
+/*	$NetBSD: linux32_socket.c,v 1.18 2014/05/17 21:26:20 rmind Exp $ */
 
 /*-
  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.17 2013/01/11 19:01:36 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.18 2014/05/17 21:26:20 rmind Exp $");
 
 #include 
 #include 
@@ -398,10 +398,7 @@ linux32_getifname(struct lwp *l, registe
 	if (error)
 		return error;
 
-	if (ifr.ifr_ifru.ifru_ifindex >= if_indexlim)
-		return ENODEV;
-	
-	ifp = ifindex2ifnet[ifr.ifr_ifru.ifru_ifindex];
+	ifp = if_byindex(ifr.ifr_ifru.ifru_ifindex);
 	if (ifp == NULL)
 		return ENODEV;
 

Index: src/sys/netinet/ip_output.c
diff -u src/sys/netinet/ip_output.c:1.224 src/sys/netinet/ip_output.c:1.225
--- src/sys/netinet/ip_output.c:1.224	Sat Jun 29 21:06:58 2013
+++ src/sys/netinet/ip_output.c	Sat May 17 21:26:20 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_output.c,v 1.224 2013/06/29 21:06:58 rmind Exp $	*/
+/*	$NetBSD: ip_output.c,v 1.225 2014/05/17 21:26:20 rmind Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.224 2013/06/29 21:06:58 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.225 2014/05/17 21:26:20 rmind Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -1315,9 +1315,7 @@ ip_multicast_if(struct in_addr *a, int *
 		*ifindexp = 0;
 	if (ntohl(a->s_addr) >> 24 == 0) {
 		ifindex = ntohl(a->s_addr) & 0xff;
-		if (ifindex < 0 || if_indexlim <= ifindex)
-			return NULL;
-		ifp = ifindex2ifnet[ifindex];
+		ifp = if_byindex(ifindex);
 		if (!ifp)
 			return NULL;
 		if (ifindexp)

Index: src/sys/netinet6/in6_src.c
diff -u src/sys/netinet6/in6_src.c:1.53 src/sys/netinet6/in6_src.c:1.54
--- src/sys/netinet6/in6_src.c:1.53	Mon Jun 25 15:28:39 2012
+++ src/sys/netinet6/in6_src.c	Sat May 17 21:26:20 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_src.c,v 1.53 2012/06/25 15:28:39 christos Exp $	*/
+/*	$NetBSD: in6_src.c,v 1.54 2014/05/17 21:26:20 rmind Exp $	*/
 /*	$KAME: in6_src.c,v 1.159 2005/10/19 01:40:32 t-momose Exp $	*/
 
 /*
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.53 2012/06/25 15:28:39 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.54 2014/05/17 21:26:20 rmind Exp $");
 
 #include "opt_inet.h"
 
@@ -5

CVS commit: src/sys/kern

2014-05-17 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat May 17 21:45:02 UTC 2014

Modified Files:
src/sys/kern: uipc_syscalls.c

Log Message:
Remove trailing whitespaces, wrap long lines, minor KNF; no functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.166 -r1.167 src/sys/kern/uipc_syscalls.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/kern/uipc_syscalls.c
diff -u src/sys/kern/uipc_syscalls.c:1.166 src/sys/kern/uipc_syscalls.c:1.167
--- src/sys/kern/uipc_syscalls.c:1.166	Mon Apr  7 15:35:23 2014
+++ src/sys/kern/uipc_syscalls.c	Sat May 17 21:45:02 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_syscalls.c,v 1.166 2014/04/07 15:35:23 seanb Exp $	*/
+/*	$NetBSD: uipc_syscalls.c,v 1.167 2014/05/17 21:45:02 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.166 2014/04/07 15:35:23 seanb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.167 2014/05/17 21:45:02 rmind Exp $");
 
 #include "opt_pipe.h"
 
@@ -92,23 +92,24 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_syscall
 extern const struct fileops socketops;
 
 int
-sys___socket30(struct lwp *l, const struct sys___socket30_args *uap, register_t *retval)
+sys___socket30(struct lwp *l, const struct sys___socket30_args *uap,
+register_t *retval)
 {
 	/* {
 		syscallarg(int)	domain;
 		syscallarg(int)	type;
 		syscallarg(int)	protocol;
 	} */
-	int		fd, error;
+	int fd, error;
 
 	error = fsocreate(SCARG(uap, domain), NULL, SCARG(uap, type),
-			 SCARG(uap, protocol), l, &fd);
-	if (error == 0)
+	SCARG(uap, protocol), l, &fd);
+	if (error == 0) {
 		*retval = fd;
+	}
 	return error;
 }
 
-/* ARGSUSED */
 int
 sys_bind(struct lwp *l, const struct sys_bind_args *uap, register_t *retval)
 {
@@ -145,7 +146,6 @@ do_sys_bind(struct lwp *l, int fd, struc
 	return error;
 }
 
-/* ARGSUSED */
 int
 sys_listen(struct lwp *l, const struct sys_listen_args *uap, register_t *retval)
 {
@@ -164,8 +164,8 @@ sys_listen(struct lwp *l, const struct s
 }
 
 int
-do_sys_accept(struct lwp *l, int sock, struct mbuf **name, register_t *new_sock,
-const sigset_t *mask, int flags, int clrflags)
+do_sys_accept(struct lwp *l, int sock, struct mbuf **name,
+register_t *new_sock, const sigset_t *mask, int flags, int clrflags)
 {
 	file_t		*fp, *fp2;
 	struct mbuf	*nam;
@@ -174,14 +174,14 @@ do_sys_accept(struct lwp *l, int sock, s
 	short		wakeup_state = 0;
 
 	if ((fp = fd_getfile(sock)) == NULL)
-		return (EBADF);
+		return EBADF;
 	if (fp->f_type != DTYPE_SOCKET) {
 		fd_putfile(sock);
-		return (ENOTSOCK);
+		return ENOTSOCK;
 	}
 	if ((error = fd_allocfile(&fp2, &fd)) != 0) {
 		fd_putfile(sock);
-		return (error);
+		return error;
 	}
 	nam = m_get(M_WAIT, MT_SONAME);
 	*new_sock = fd;
@@ -257,15 +257,15 @@ do_sys_accept(struct lwp *l, int sock, s
 	fd_putfile(sock);
 	if (__predict_false(mask))
 		sigsuspendteardown(l);
-	return (error);
+	return error;
  bad:
- 	sounlock(so);
- 	m_freem(nam);
+	sounlock(so);
+	m_freem(nam);
 	fd_putfile(sock);
- 	fd_abort(curproc, fp2, fd);
+	fd_abort(curproc, fp2, fd);
 	if (__predict_false(mask))
 		sigsuspendteardown(l);
- 	return (error);
+	return error;
 }
 
 int
@@ -333,9 +333,9 @@ sys_paccept(struct lwp *l, const struct 
 	return error;
 }
 
-/* ARGSUSED */
 int
-sys_connect(struct lwp *l, const struct sys_connect_args *uap, register_t *retval)
+sys_connect(struct lwp *l, const struct sys_connect_args *uap,
+register_t *retval)
 {
 	/* {
 		syscallarg(int)s;
@@ -401,21 +401,22 @@ do_sys_connect(struct lwp *l, int fd, st
 	if (error == ERESTART)
 		error = EINTR;
  out:
- 	sounlock(so);
- 	fd_putfile(fd);
+	sounlock(so);
+	fd_putfile(fd);
 	m_freem(nam);
-	return (error);
+	return error;
 }
 
 static int
 makesocket(struct lwp *l, file_t **fp, int *fd, int flags, int type,
 int domain, int proto, struct socket *soo)
 {
-	int error;
 	struct socket *so;
+	int error;
 
-	if ((error = socreate(domain, &so, type, proto, l, soo)) != 0)
+	if ((error = socreate(domain, &so, type, proto, l, soo)) != 0) {
 		return error;
+	}
 
 	if ((error = fd_allocfile(fp, fd)) != 0) {
 		soclose(so);
@@ -446,14 +447,12 @@ sys_socketpair(struct lwp *l, const stru
 	file_t		*fp1, *fp2;
 	struct socket	*so1, *so2;
 	int		fd, error, sv[2];
-	proc_t		*p;
+	proc_t		*p = curproc;
 	int		flags = SCARG(uap, type) & SOCK_FLAGS_MASK;
 	int		type = SCARG(uap, type) & ~SOCK_FLAGS_MASK;
 	int		domain = SCARG(uap, domain);
 	int		proto = SCARG(uap, protocol);
 
-	p = curproc;
-
 	error = makesocket(l, &fp1, &fd, flags, type, domain, proto, NULL);
 	if (error)
 		return error;
@@ -492,7 +491,8 @@ out:
 }
 
 int
-sys_sendto(struct lwp *l, const struct sys_sendto_args *uap, register_t *retval)
+sys_sendto(struct lwp *l, const struct sys_sendto_args *uap,
+register_t *retval)
 {
 	/* {
 		syscallarg(int)s;
@@ -517,

CVS commit: src/sys/kern

2014-05-17 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat May 17 21:48:48 UTC 2014

Modified Files:
src/sys/kern: uipc_syscalls.c

Log Message:
makesocket: set SS_NBIO slightly earlier.


To generate a diff of this commit:
cvs rdiff -u -r1.167 -r1.168 src/sys/kern/uipc_syscalls.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/kern/uipc_syscalls.c
diff -u src/sys/kern/uipc_syscalls.c:1.167 src/sys/kern/uipc_syscalls.c:1.168
--- src/sys/kern/uipc_syscalls.c:1.167	Sat May 17 21:45:02 2014
+++ src/sys/kern/uipc_syscalls.c	Sat May 17 21:48:48 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_syscalls.c,v 1.167 2014/05/17 21:45:02 rmind Exp $	*/
+/*	$NetBSD: uipc_syscalls.c,v 1.168 2014/05/17 21:48:48 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.167 2014/05/17 21:45:02 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.168 2014/05/17 21:48:48 rmind Exp $");
 
 #include "opt_pipe.h"
 
@@ -417,6 +417,9 @@ makesocket(struct lwp *l, file_t **fp, i
 	if ((error = socreate(domain, &so, type, proto, l, soo)) != 0) {
 		return error;
 	}
+	if (flags & SOCK_NONBLOCK) {
+		so->so_state |= SS_NBIO;
+	}
 
 	if ((error = fd_allocfile(fp, fd)) != 0) {
 		soclose(so);
@@ -429,8 +432,6 @@ makesocket(struct lwp *l, file_t **fp, i
 	(*fp)->f_type = DTYPE_SOCKET;
 	(*fp)->f_ops = &socketops;
 	(*fp)->f_data = so;
-	if (flags & SOCK_NONBLOCK)
-		so->so_state |= SS_NBIO;
 	return 0;
 }
 



CVS commit: src/sys

2014-05-17 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat May 17 22:52:36 UTC 2014

Modified Files:
src/sys/kern: uipc_socket2.c
src/sys/sys: socketvar.h

Log Message:
- sonewconn: improve the initialisation order and add some asserts.
- Add various comments describing primitive routines operating on sockets,
  clarify connection life-cycle and improve the description of socket queues.
- Sprinkle more asserts.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/sys/kern/uipc_socket2.c
cvs rdiff -u -r1.131 -r1.132 src/sys/sys/socketvar.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/kern/uipc_socket2.c
diff -u src/sys/kern/uipc_socket2.c:1.115 src/sys/kern/uipc_socket2.c:1.116
--- src/sys/kern/uipc_socket2.c:1.115	Tue Oct  8 19:58:25 2013
+++ src/sys/kern/uipc_socket2.c	Sat May 17 22:52:36 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_socket2.c,v 1.115 2013/10/08 19:58:25 christos Exp $	*/
+/*	$NetBSD: uipc_socket2.c,v 1.116 2014/05/17 22:52:36 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.115 2013/10/08 19:58:25 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.116 2014/05/17 22:52:36 rmind Exp $");
 
 #include "opt_mbuftrace.h"
 #include "opt_sb_max.h"
@@ -82,13 +82,44 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_socket2
 /*
  * Primitive routines for operating on sockets and socket buffers.
  *
+ * Connection life-cycle:
+ *
+ *	Normal sequence from the active (originating) side:
+ *
+ *	- soisconnecting() is called during processing of connect() call,
+ *	- resulting in an eventual call to soisconnected() if/when the
+ *	  connection is established.
+ *
+ *	When the connection is torn down during processing of disconnect():
+ *
+ *	- soisdisconnecting() is called and,
+ *	- soisdisconnected() is called when the connection to the peer
+ *	  is totally severed.
+ *
+ *	The semantics of these routines are such that connectionless protocols
+ *	can call soisconnected() and soisdisconnected() only, bypassing the
+ *	in-progress calls when setting up a ``connection'' takes no time.
+ *
+ *	From the passive side, a socket is created with two queues of sockets:
+ *
+ *	- so_q0 (0) for partial connections (i.e. connections in progress)
+ *	- so_q (1) for connections already made and awaiting user acceptance.
+ *
+ *	As a protocol is preparing incoming connections, it creates a socket
+ *	structure queued on so_q0 by calling sonewconn().  When the connection
+ *	is established, soisconnected() is called, and transfers the
+ *	socket structure to so_q, making it available to accept().
+ *
+ *	If a socket is closed with sockets on either so_q0 or so_q, these
+ *	sockets are dropped.
+ *
  * Locking rules and assumptions:
  *
  * o socket::so_lock can change on the fly.  The low level routines used
  *   to lock sockets are aware of this.  When so_lock is acquired, the
  *   routine locking must check to see if so_lock still points to the
  *   lock that was acquired.  If so_lock has changed in the meantime, the
- *   now irellevant lock that was acquired must be dropped and the lock
+ *   now irrelevant lock that was acquired must be dropped and the lock
  *   operation retried.  Although not proven here, this is completely safe
  *   on a multiprocessor system, even with relaxed memory ordering, given
  *   the next two rules:
@@ -115,45 +146,14 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_socket2
  *   locking the socket must also lock the sockets attached to both queues.
  *   Again, their lock pointers must match.
  *
- * o Beyond the initial lock assigment in socreate(), assigning locks to
+ * o Beyond the initial lock assignment in socreate(), assigning locks to
  *   sockets is the responsibility of the individual protocols / protocol
  *   domains.
  */
 
-static pool_cache_t socket_cache;
-
-u_long	sb_max = SB_MAX;	/* maximum socket buffer size */
-static u_long sb_max_adj;	/* adjusted sb_max */
-
-/*
- * Procedures to manipulate state flags of socket
- * and do appropriate wakeups.  Normal sequence from the
- * active (originating) side is that soisconnecting() is
- * called during processing of connect() call,
- * resulting in an eventual call to soisconnected() if/when the
- * connection is established.  When the connection is torn down
- * soisdisconnecting() is called during processing of disconnect() call,
- * and soisdisconnected() is called when the connection to the peer
- * is totally severed.  The semantics of these routines are such that
- * connectionless protocols can call soisconnected() and soisdisconnected()
- * only, bypassing the in-progress calls when setting up a ``connection''
- * takes no time.
- *
- * From the passive side, a socket is created with
- * two queues of sockets: so_q0 for connections in progress
- * and so_q for connections already mad

CVS commit: src/sys

2014-05-17 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat May 17 23:27:59 UTC 2014

Modified Files:
src/sys/kern: uipc_socket.c uipc_syscalls.c
src/sys/net: if_gre.c
src/sys/sys: mbuf.h socketvar.h

Log Message:
- fsocreate: set SS_NBIO before the file descriptor is affixed as there is
  a theoretical race condition (hard to trigger, though); remove the LWP
  parameter and clean up the code a little.
- Sprinkle few comments.
- Remove M_SOOPTS while here.


To generate a diff of this commit:
cvs rdiff -u -r1.221 -r1.222 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.168 -r1.169 src/sys/kern/uipc_syscalls.c
cvs rdiff -u -r1.153 -r1.154 src/sys/net/if_gre.c
cvs rdiff -u -r1.154 -r1.155 src/sys/sys/mbuf.h
cvs rdiff -u -r1.132 -r1.133 src/sys/sys/socketvar.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/kern/uipc_socket.c
diff -u src/sys/kern/uipc_socket.c:1.221 src/sys/kern/uipc_socket.c:1.222
--- src/sys/kern/uipc_socket.c:1.221	Tue Feb 25 18:30:11 2014
+++ src/sys/kern/uipc_socket.c	Sat May 17 23:27:59 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_socket.c,v 1.221 2014/02/25 18:30:11 pooka Exp $	*/
+/*	$NetBSD: uipc_socket.c,v 1.222 2014/05/17 23:27:59 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -62,8 +62,16 @@
  *	@(#)uipc_socket.c	8.6 (Berkeley) 5/2/95
  */
 
+/*
+ * Socket operation routines.
+ *
+ * These routines are called by the routines in sys_socket.c or from a
+ * system process, and implement the semantics of socket operations by
+ * switching out to the protocol specific routines.
+ */
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.221 2014/02/25 18:30:11 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.222 2014/05/17 23:27:59 rmind Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_sock_counters.h"
@@ -103,7 +111,6 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_socket.
 #include 
 #include 
 
-MALLOC_DEFINE(M_SOOPTS, "soopts", "socket options");
 MALLOC_DEFINE(M_SONAME, "soname", "socket name");
 
 extern const struct fileops socketops;
@@ -479,13 +486,11 @@ soinit1(void)
 }
 
 /*
- * Socket operation routines.
- * These routines are called by the routines in
- * sys_socket.c or from a system process, and
- * implement the semantics of socket operations by
- * switching out to the protocol specific routines.
- */
-/*ARGSUSED*/
+ * socreate: create a new socket of the specified type and the protocol.
+ *
+ * => Caller may specify another socket for lock sharing (must not be held).
+ * => Returns the new socket without lock held.
+*/
 int
 socreate(int dom, struct socket **aso, int type, int proto, struct lwp *l,
 	 struct socket *lockso)
@@ -547,6 +552,7 @@ socreate(int dom, struct socket **aso, i
 	(struct mbuf *)(long)proto, NULL, l);
 	KASSERT(solocked(so));
 	if (error != 0) {
+		KASSERT(so->so_pcb == NULL);
 		so->so_state |= SS_NOFDREF;
 		sofree(so);
 		return error;
@@ -557,38 +563,46 @@ socreate(int dom, struct socket **aso, i
 	return 0;
 }
 
-/* On success, write file descriptor to fdout and return zero.  On
- * failure, return non-zero; *fdout will be undefined.
+/*
+ * fsocreate: create a socket and a file descriptor associated with it.
+ *
+ * => On success, write file descriptor to fdout and return zero.
+ * => On failure, return non-zero; *fdout will be undefined.
  */
 int
-fsocreate(int domain, struct socket **sop, int type, int protocol,
-struct lwp *l, int *fdout)
+fsocreate(int domain, struct socket **sop, int type, int proto, int *fdout)
 {
-	struct socket	*so;
-	struct file	*fp;
-	int		fd, error;
-	int		flags = type & SOCK_FLAGS_MASK;
+	lwp_t *l = curlwp;
+	int error, fd, flags;
+	struct socket *so;
+	struct file *fp;
 
-	type &= ~SOCK_FLAGS_MASK;
-	if ((error = fd_allocfile(&fp, &fd)) != 0)
+	if ((error = fd_allocfile(&fp, &fd)) != 0) {
 		return error;
+	}
+	flags = type & SOCK_FLAGS_MASK;
 	fd_set_exclose(l, fd, (flags & SOCK_CLOEXEC) != 0);
 	fp->f_flag = FREAD|FWRITE|((flags & SOCK_NONBLOCK) ? FNONBLOCK : 0)|
 	((flags & SOCK_NOSIGPIPE) ? FNOSIGPIPE : 0);
 	fp->f_type = DTYPE_SOCKET;
 	fp->f_ops = &socketops;
-	error = socreate(domain, &so, type, protocol, l, NULL);
-	if (error != 0) {
+
+	type &= ~SOCK_FLAGS_MASK;
+	error = socreate(domain, &so, type, proto, l, NULL);
+	if (error) {
 		fd_abort(curproc, fp, fd);
-	} else {
-		if (sop != NULL)
-			*sop = so;
-		fp->f_data = so;
-		fd_affix(curproc, fp, fd);
-		*fdout = fd;
-		if (flags & SOCK_NONBLOCK)
-			so->so_state |= SS_NBIO;
+		return error;
 	}
+	if (flags & SOCK_NONBLOCK) {
+		so->so_state |= SS_NBIO;
+	}
+	fp->f_data = so;
+	fd_affix(curproc, fp, fd);
+
+	if (sop != NULL) {
+		*sop = so;
+	}
+	*fdout = fd;
 	return error;
 }
 
@@ -624,8 +638,8 @@ solisten(struct socket *so, int backlog,
 	solock(so);
 	if ((so->so_state & (SS_ISCONNECTED | SS_ISCONNECTING | 
 	SS_ISDISCONNECTING)) != 0) {
-		sounlock(so);

CVS commit: src/sys/miscfs/fifofs

2014-05-17 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat May 17 23:30:25 UTC 2014

Modified Files:
src/sys/miscfs/fifofs: fifo_vnops.c

Log Message:
fifo_open: assign v_fifoinfo once initialised; add an assert while here.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/miscfs/fifofs/fifo_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/miscfs/fifofs/fifo_vnops.c
diff -u src/sys/miscfs/fifofs/fifo_vnops.c:1.74 src/sys/miscfs/fifofs/fifo_vnops.c:1.75
--- src/sys/miscfs/fifofs/fifo_vnops.c:1.74	Fri Feb  7 15:29:22 2014
+++ src/sys/miscfs/fifofs/fifo_vnops.c	Sat May 17 23:30:24 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fifo_vnops.c,v 1.74 2014/02/07 15:29:22 hannken Exp $	*/
+/*	$NetBSD: fifo_vnops.c,v 1.75 2014/05/17 23:30:24 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fifo_vnops.c,v 1.74 2014/02/07 15:29:22 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fifo_vnops.c,v 1.75 2014/05/17 23:30:24 rmind Exp $");
 
 #include 
 #include 
@@ -116,7 +116,6 @@ fifo_lookup(void *v)
  * Open called to set up a new instance of a fifo or
  * to find an active instance of a fifo.
  */
-/* ARGSUSED */
 static int
 fifo_open(void *v)
 {
@@ -132,14 +131,13 @@ fifo_open(void *v)
 	int		error;
 
 	vp = ap->a_vp;
+	KASSERT(VOP_ISLOCKED(vp));
 
 	if ((fip = vp->v_fifoinfo) == NULL) {
 		fip = kmem_alloc(sizeof(*fip), KM_SLEEP);
-		vp->v_fifoinfo = fip;
 		error = socreate(AF_LOCAL, &rso, SOCK_STREAM, 0, l, NULL);
 		if (error != 0) {
 			kmem_free(fip, sizeof(*fip));
-			vp->v_fifoinfo = NULL;
 			return (error);
 		}
 		fip->fi_readsock = rso;
@@ -147,7 +145,6 @@ fifo_open(void *v)
 		if (error != 0) {
 			(void)soclose(rso);
 			kmem_free(fip, sizeof(*fip));
-			vp->v_fifoinfo = NULL;
 			return (error);
 		}
 		fip->fi_writesock = wso;
@@ -157,7 +154,6 @@ fifo_open(void *v)
 			(void)soclose(wso);
 			(void)soclose(rso);
 			kmem_free(fip, sizeof(*fip));
-			vp->v_fifoinfo = NULL;
 			return (error);
 		}
 		fip->fi_readers = 0;
@@ -166,6 +162,7 @@ fifo_open(void *v)
 		rso->so_state |= SS_CANTSENDMORE;
 		cv_init(&fip->fi_rcv, "fiford");
 		cv_init(&fip->fi_wcv, "fifowr");
+		vp->v_fifoinfo = fip;
 	} else {
 		wso = fip->fi_writesock;
 		rso = fip->fi_readsock;



CVS commit: src/share/mk

2014-05-17 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sat May 17 23:31:57 UTC 2014

Modified Files:
src/share/mk: bsd.own.mk

Log Message:
Structure HAVE_LIBGCC condition similar to HAVE_LIBGCC_EH.


To generate a diff of this commit:
cvs rdiff -u -r1.804 -r1.805 src/share/mk/bsd.own.mk

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

Modified files:

Index: src/share/mk/bsd.own.mk
diff -u src/share/mk/bsd.own.mk:1.804 src/share/mk/bsd.own.mk:1.805
--- src/share/mk/bsd.own.mk:1.804	Fri May 16 00:19:00 2014
+++ src/share/mk/bsd.own.mk	Sat May 17 23:31:57 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.own.mk,v 1.804 2014/05/16 00:19:00 joerg Exp $
+#	$NetBSD: bsd.own.mk,v 1.805 2014/05/17 23:31:57 joerg Exp $
 
 # This needs to be before bsd.init.mk
 .if defined(BSD_MK_COMPAT_FILE)
@@ -87,16 +87,19 @@ EXTERNAL_GCC_SUBDIR=	/does/not/exist
 
 .endif
 
-.if ${MKLLVM:Uno} == "yes" && (${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64")
+.if !empty(MACHINE_ARCH:Mearm*)
+_LIBC_UNWIND_SUPPORT.${MACHINE_ARCH}=	yes
+.endif
+
+_LIBC_COMPILER_RT.i386=		yes
+_LIBC_COMPILER_RT.x86_64=	yes
+
+.if ${MKLLVM:Uno} == "yes" && ${_LIBC_COMPILER_RT.${MACHINE_ARCH}:Uno} == "yes"
 HAVE_LIBGCC?=	no
 .else
 HAVE_LIBGCC?=	yes
 .endif
 
-.if !empty(MACHINE_ARCH:Mearm*)
-_LIBC_UNWIND_SUPPORT.${MACHINE_ARCH}=	yes
-.endif
-
 _LIBC_UNWIND_SUPPORT.alpha=	yes
 _LIBC_UNWIND_SUPPORT.hppa=	yes
 _LIBC_UNWIND_SUPPORT.i386=	yes



CVS commit: src/share/mk

2014-05-17 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sat May 17 23:32:32 UTC 2014

Modified Files:
src/share/mk: bsd.own.mk

Log Message:
Use compiler-rt in libc for Clang on NetBSD/ARM as well.


To generate a diff of this commit:
cvs rdiff -u -r1.805 -r1.806 src/share/mk/bsd.own.mk

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

Modified files:

Index: src/share/mk/bsd.own.mk
diff -u src/share/mk/bsd.own.mk:1.805 src/share/mk/bsd.own.mk:1.806
--- src/share/mk/bsd.own.mk:1.805	Sat May 17 23:31:57 2014
+++ src/share/mk/bsd.own.mk	Sat May 17 23:32:32 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.own.mk,v 1.805 2014/05/17 23:31:57 joerg Exp $
+#	$NetBSD: bsd.own.mk,v 1.806 2014/05/17 23:32:32 joerg Exp $
 
 # This needs to be before bsd.init.mk
 .if defined(BSD_MK_COMPAT_FILE)
@@ -88,6 +88,7 @@ EXTERNAL_GCC_SUBDIR=	/does/not/exist
 .endif
 
 .if !empty(MACHINE_ARCH:Mearm*)
+_LIBC_COMPILER_RT.${MACHINE_ARCH}=	yes
 _LIBC_UNWIND_SUPPORT.${MACHINE_ARCH}=	yes
 .endif
 



CVS commit: src/sys/kern

2014-05-17 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat May 17 23:55:24 UTC 2014

Modified Files:
src/sys/kern: uipc_socket2.c

Log Message:
sonewconn: insert the socket into the queue *after* the protocol attach.
This potentially avoids unnecessary race conditions when handling partial
connections.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/kern/uipc_socket2.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/kern/uipc_socket2.c
diff -u src/sys/kern/uipc_socket2.c:1.116 src/sys/kern/uipc_socket2.c:1.117
--- src/sys/kern/uipc_socket2.c:1.116	Sat May 17 22:52:36 2014
+++ src/sys/kern/uipc_socket2.c	Sat May 17 23:55:24 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_socket2.c,v 1.116 2014/05/17 22:52:36 rmind Exp $	*/
+/*	$NetBSD: uipc_socket2.c,v 1.117 2014/05/17 23:55:24 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.116 2014/05/17 22:52:36 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.117 2014/05/17 23:55:24 rmind Exp $");
 
 #include "opt_mbuftrace.h"
 #include "opt_sb_max.h"
@@ -302,13 +302,11 @@ sonewconn(struct socket *head, bool sore
 	 */
 	mutex_obj_hold(head->so_lock);
 	so->so_lock = head->so_lock;
-	soqinsque(head, so, soqueue);
 
 	error = (*so->so_proto->pr_usrreq)(so, PRU_ATTACH, NULL, NULL,
 	NULL, NULL);
 	KASSERT(solocked(so));
 	if (error) {
-		(void) soqremque(so, soqueue);
 out:
 		KASSERT(so->so_accf == NULL);
 		soput(so);
@@ -319,9 +317,10 @@ out:
 	}
 
 	/*
-	 * Update the connection status and wake up any waiters,
-	 * e.g. processes blocking on accept().
+	 * Insert into the queue.  If ready, update the connection status
+	 * and wake up any waiters, e.g. processes blocking on accept().
 	 */
+	soqinsque(head, so, soqueue);
 	if (soready) {
 		so->so_state |= SS_ISCONNECTED;
 		sorwakeup(head);



CVS commit: src/sys

2014-05-17 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sun May 18 00:10:11 UTC 2014

Modified Files:
src/sys/netinet: raw_ip.c
src/sys/netinet6: icmp6.c raw_ip6.c

Log Message:
Use IFNET_FIRST() rather than open coding ifnet access.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/netinet/raw_ip.c
cvs rdiff -u -r1.165 -r1.166 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.113 -r1.114 src/sys/netinet6/raw_ip6.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/netinet/raw_ip.c
diff -u src/sys/netinet/raw_ip.c:1.118 src/sys/netinet/raw_ip.c:1.119
--- src/sys/netinet/raw_ip.c:1.118	Tue Feb 25 18:30:12 2014
+++ src/sys/netinet/raw_ip.c	Sun May 18 00:10:11 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip.c,v 1.118 2014/02/25 18:30:12 pooka Exp $	*/
+/*	$NetBSD: raw_ip.c,v 1.119 2014/05/18 00:10:11 rmind Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.118 2014/02/25 18:30:12 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.119 2014/05/18 00:10:11 rmind Exp $");
 
 #include "opt_inet.h"
 #include "opt_compat_netbsd.h"
@@ -474,7 +474,7 @@ rip_bind(struct inpcb *inp, struct mbuf 
 
 	if (nam->m_len != sizeof(*addr))
 		return (EINVAL);
-	if (TAILQ_FIRST(&ifnet) == 0)
+	if (!IFNET_FIRST())
 		return (EADDRNOTAVAIL);
 	if (addr->sin_family != AF_INET)
 		return (EAFNOSUPPORT);
@@ -492,7 +492,7 @@ rip_connect(struct inpcb *inp, struct mb
 
 	if (nam->m_len != sizeof(*addr))
 		return (EINVAL);
-	if (TAILQ_FIRST(&ifnet) == 0)
+	if (!IFNET_FIRST())
 		return (EADDRNOTAVAIL);
 	if (addr->sin_family != AF_INET)
 		return (EAFNOSUPPORT);

Index: src/sys/netinet6/icmp6.c
diff -u src/sys/netinet6/icmp6.c:1.165 src/sys/netinet6/icmp6.c:1.166
--- src/sys/netinet6/icmp6.c:1.165	Tue Feb 25 18:30:12 2014
+++ src/sys/netinet6/icmp6.c	Sun May 18 00:10:11 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: icmp6.c,v 1.165 2014/02/25 18:30:12 pooka Exp $	*/
+/*	$NetBSD: icmp6.c,v 1.166 2014/05/18 00:10:11 rmind Exp $	*/
 /*	$KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.165 2014/02/25 18:30:12 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.166 2014/05/18 00:10:11 rmind Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -1717,7 +1717,7 @@ ni6_store_addrs(struct icmp6_nodeinfo *n
 	struct icmp6_nodeinfo *nni6, struct ifnet *ifp0,
 	int resid)
 {
-	struct ifnet *ifp = ifp0 ? ifp0 : TAILQ_FIRST(&ifnet);
+	struct ifnet *ifp = ifp0 ? ifp0 : IFNET_FIRST();
 	struct in6_ifaddr *ifa6;
 	struct ifaddr *ifa;
 	struct ifnet *ifp_dep = NULL;

Index: src/sys/netinet6/raw_ip6.c
diff -u src/sys/netinet6/raw_ip6.c:1.113 src/sys/netinet6/raw_ip6.c:1.114
--- src/sys/netinet6/raw_ip6.c:1.113	Tue Feb 25 18:30:12 2014
+++ src/sys/netinet6/raw_ip6.c	Sun May 18 00:10:11 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip6.c,v 1.113 2014/02/25 18:30:12 pooka Exp $	*/
+/*	$NetBSD: raw_ip6.c,v 1.114 2014/05/18 00:10:11 rmind Exp $	*/
 /*	$KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.113 2014/02/25 18:30:12 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.114 2014/05/18 00:10:11 rmind Exp $");
 
 #include "opt_ipsec.h"
 
@@ -677,7 +677,7 @@ rip6_usrreq(struct socket *so, int req, 
 			error = EINVAL;
 			break;
 		}
-		if (TAILQ_EMPTY(&ifnet) || addr->sin6_family != AF_INET6) {
+		if (!IFNET_FIRST() || addr->sin6_family != AF_INET6) {
 			error = EADDRNOTAVAIL;
 			break;
 		}
@@ -718,7 +718,7 @@ rip6_usrreq(struct socket *so, int req, 
 			error = EINVAL;
 			break;
 		}
-		if (TAILQ_EMPTY(&ifnet)) {
+		if (!IFNET_FIRST()) {
 			error = EADDRNOTAVAIL;
 			break;
 		}



CVS commit: src/sys/net

2014-05-17 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sun May 18 00:33:20 UTC 2014

Modified Files:
src/sys/net: if.c if.h

Log Message:
- Move ifnet_list (and lo0ifp while here) under #ifdef _KERNEL.
- Make ifindex2ifnet, if_indexlim and some other variables static.
- Move if_index generation into its own function.
- if_alloc/if_free: replace malloc with kmem.


To generate a diff of this commit:
cvs rdiff -u -r1.273 -r1.274 src/sys/net/if.c
cvs rdiff -u -r1.164 -r1.165 src/sys/net/if.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/net/if.c
diff -u src/sys/net/if.c:1.273 src/sys/net/if.c:1.274
--- src/sys/net/if.c:1.273	Sat Apr 26 11:16:22 2014
+++ src/sys/net/if.c	Sun May 18 00:33:20 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.273 2014/04/26 11:16:22 pooka Exp $	*/
+/*	$NetBSD: if.c,v 1.274 2014/05/18 00:33:20 rmind Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.273 2014/04/26 11:16:22 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.274 2014/05/18 00:33:20 rmind Exp $");
 
 #include "opt_inet.h"
 
@@ -138,6 +138,7 @@ __KERNEL_RCSID(0, "$NetBSD: if.c,v 1.273
 
 #include "carp.h"
 #if NCARP > 0
+#include 
 #include 
 #endif
 
@@ -147,10 +148,23 @@ __KERNEL_RCSID(0, "$NetBSD: if.c,v 1.273
 MALLOC_DEFINE(M_IFADDR, "ifaddr", "interface address");
 MALLOC_DEFINE(M_IFMADDR, "ether_multi", "link-level multicast address");
 
-int	ifqmaxlen = IFQ_MAXLEN;
-callout_t if_slowtimo_ch;
+/*
+ * Global list of interfaces.
+ */
+struct ifnet_head		ifnet_list;
+static ifnet_t **		ifindex2ifnet = NULL;
+
+static u_int			if_index = 1;
+static size_t			if_indexlim = 0;
+static uint64_t			index_gen;
+static kmutex_t			index_gen_mtx;
 
-int netisr;			/* scheduling bits for network */
+static struct ifaddr **		ifnet_addrs = NULL;
+
+static callout_t		if_slowtimo_ch;
+
+struct ifnet *lo0ifp;
+int	ifqmaxlen = IFQ_MAXLEN;
 
 static int	if_rt_walktree(struct rtentry *, void *);
 
@@ -160,9 +174,6 @@ static int	if_clone_list(struct if_clone
 static LIST_HEAD(, if_clone) if_cloners = LIST_HEAD_INITIALIZER(if_cloners);
 static int if_cloners_count;
 
-static uint64_t index_gen;
-static kmutex_t index_gen_mtx;
-
 /* Packet filtering hook for interfaces. */
 pfil_head_t *	if_pfil;
 
@@ -240,20 +251,23 @@ void
 ifinit1(void)
 {
 	mutex_init(&index_gen_mtx, MUTEX_DEFAULT, IPL_NONE);
+	TAILQ_INIT(&ifnet_list);
+	if_indexlim = 8;
+
 	if_pfil = pfil_head_create(PFIL_TYPE_IFNET, NULL);
 	KASSERT(if_pfil != NULL);
 }
 
-struct ifnet *
+ifnet_t *
 if_alloc(u_char type)
 {
-	return malloc(sizeof(struct ifnet), M_DEVBUF, M_WAITOK|M_ZERO);
+	return kmem_zalloc(sizeof(ifnet_t), KM_SLEEP);
 }
 
 void
-if_free(struct ifnet *ifp)
+if_free(ifnet_t *ifp)
 {
-	free(ifp, M_DEVBUF);
+	kmem_free(ifp, sizeof(ifnet_t));
 }
 
 void
@@ -329,13 +343,6 @@ if_nulldrain(struct ifnet *ifp)
 	/* Nothing. */
 }
 
-static u_int if_index = 1;
-struct ifnet_head ifnet;
-size_t if_indexlim = 0;
-struct ifaddr **ifnet_addrs = NULL;
-struct ifnet **ifindex2ifnet = NULL;
-struct ifnet *lo0ifp;
-
 void
 if_set_sadl(struct ifnet *ifp, const void *lla, u_char addrlen, bool factory)
 {
@@ -488,61 +495,47 @@ if_free_sadl(struct ifnet *ifp)
 	splx(s);
 }
 
-/*
- * Attach an interface to the
- * list of "active" interfaces.
- */
-void
-if_attach(struct ifnet *ifp)
+static void
+if_getindex(ifnet_t *ifp)
 {
-	int indexlim = 0;
-
-	if (if_indexlim == 0) {
-		TAILQ_INIT(&ifnet);
-		if_indexlim = 8;
-	}
-	TAILQ_INIT(&ifp->if_addrlist);
-	TAILQ_INSERT_TAIL(&ifnet, ifp, if_list);
-
-	if (ifioctl_attach(ifp) != 0)
-		panic("%s: ifioctl_attach() failed", __func__);
+	bool hitlimit = false;
 
 	mutex_enter(&index_gen_mtx);
 	ifp->if_index_gen = index_gen++;
 	mutex_exit(&index_gen_mtx);
 
 	ifp->if_index = if_index;
-	if (ifindex2ifnet == NULL)
+	if (ifindex2ifnet == NULL) {
 		if_index++;
-	else
-		while (ifp->if_index < if_indexlim &&
-		ifindex2ifnet[ifp->if_index] != NULL) {
-			++if_index;
-			if (if_index == 0)
-if_index = 1;
+		goto skip;
+	}
+	while (if_byindex(ifp->if_index)) {
+		/*
+		 * If we hit USHRT_MAX, we skip back to 0 since
+		 * there are a number of places where the value
+		 * of if_index or if_index itself is compared
+		 * to or stored in an unsigned short.  By
+		 * jumping back, we won't botch those assignments
+		 * or comparisons.
+		 */
+		if (++if_index == 0) {
+			if_index = 1;
+		} else if (if_index == USHRT_MAX) {
 			/*
-			 * If we hit USHRT_MAX, we skip back to 0 since
-			 * there are a number of places where the value
-			 * of if_index or if_index itself is compared
-			 * to or stored in an unsigned short.  By
-			 * jumping back, we won't botch those assignments
-			 * or comparisons.
+			 * However, if we have to jump back to
+			 * zero *twice* without finding an empty
+			 * slot in ifindex2ifnet[], then there
+			 *