CVS commit: src/sys/miscfs/kernfs

2021-07-18 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jul 19 01:33:53 UTC 2021

Modified Files:
src/sys/miscfs/kernfs: kernfs_vnops.c

Log Message:
Abolish all the silly indirection macros for initializing vnode ops tables.

These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.

Part 3; cvs randomly didn't commit all the files the first time, still
hunting down the files it skipped.


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/sys/miscfs/kernfs/kernfs_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/kernfs/kernfs_vnops.c
diff -u src/sys/miscfs/kernfs/kernfs_vnops.c:1.171 src/sys/miscfs/kernfs/kernfs_vnops.c:1.172
--- src/sys/miscfs/kernfs/kernfs_vnops.c:1.171	Sun Jul 18 23:56:13 2021
+++ src/sys/miscfs/kernfs/kernfs_vnops.c	Mon Jul 19 01:33:53 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernfs_vnops.c,v 1.171 2021/07/18 23:56:13 dholland Exp $	*/
+/*	$NetBSD: kernfs_vnops.c,v 1.172 2021/07/19 01:33:53 dholland Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.171 2021/07/18 23:56:13 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.172 2021/07/19 01:33:53 dholland Exp $");
 
 #include 
 #include 
@@ -137,8 +137,6 @@ const struct kernfs_fileop kernfs_defaul
 };
 
 int	kernfs_lookup(void *);
-#define	kernfs_create	genfs_eopnotsupp
-#define	kernfs_mknod	genfs_eopnotsupp
 int	kernfs_open(void *);
 int	kernfs_close(void *);
 int	kernfs_access(void *);
@@ -146,34 +144,15 @@ int	kernfs_getattr(void *);
 int	kernfs_setattr(void *);
 int	kernfs_read(void *);
 int	kernfs_write(void *);
-#define	kernfs_fcntl	genfs_fcntl
 int	kernfs_ioctl(void *);
-#define	kernfs_poll	genfs_poll
-#define kernfs_revoke	genfs_revoke
-#define	kernfs_fsync	genfs_nullop
-#define	kernfs_seek	genfs_nullop
-#define	kernfs_remove	genfs_eopnotsupp
 int	kernfs_link(void *);
-#define	kernfs_rename	genfs_eopnotsupp
-#define	kernfs_mkdir	genfs_eopnotsupp
-#define	kernfs_rmdir	genfs_eopnotsupp
 int	kernfs_symlink(void *);
 int	kernfs_readdir(void *);
-#define	kernfs_readlink	genfs_eopnotsupp
-#define	kernfs_abortop	genfs_abortop
 int	kernfs_inactive(void *);
 int	kernfs_reclaim(void *);
-#define	kernfs_lock	genfs_lock
-#define	kernfs_unlock	genfs_unlock
-#define	kernfs_bmap	genfs_badop
-#define	kernfs_strategy	genfs_eopnotsupp
 int	kernfs_print(void *);
-#define	kernfs_islocked	genfs_islocked
 int	kernfs_pathconf(void *);
-#define	kernfs_advlock	genfs_einval
-#define	kernfs_bwrite	genfs_eopnotsupp
 int	kernfs_getpages(void *);
-#define	kernfs_putpages	genfs_putpages
 
 static int	kernfs_xread(struct kernfs_node *, int, char **,
 size_t, size_t *);
@@ -184,8 +163,8 @@ const struct vnodeopv_entry_desc kernfs_
 	{ &vop_default_desc, vn_default_error },
 	{ &vop_parsepath_desc, genfs_parsepath },	/* parsepath */
 	{ &vop_lookup_desc, kernfs_lookup },		/* lookup */
-	{ &vop_create_desc, kernfs_create },		/* create */
-	{ &vop_mknod_desc, kernfs_mknod },		/* mknod */
+	{ &vop_create_desc, genfs_eopnotsupp },		/* create */
+	{ &vop_mknod_desc, genfs_eopnotsupp },		/* mknod */
 	{ &vop_open_desc, kernfs_open },		/* open */
 	{ &vop_close_desc, kernfs_close },		/* close */
 	{ &vop_access_desc, kernfs_access },		/* access */
@@ -196,35 +175,35 @@ const struct vnodeopv_entry_desc kernfs_
 	{ &vop_write_desc, kernfs_write },		/* write */
 	{ &vop_fallocate_desc, genfs_eopnotsupp },	/* fallocate */
 	{ &vop_fdiscard_desc, genfs_eopnotsupp },	/* fdiscard */
-	{ &vop_fcntl_desc, kernfs_fcntl },		/* fcntl */
+	{ &vop_fcntl_desc, genfs_fcntl },		/* fcntl */
 	{ &vop_ioctl_desc, kernfs_ioctl },		/* ioctl */
-	{ &vop_poll_desc, kernfs_poll },		/* poll */
+	{ &vop_poll_desc, genfs_poll },			/* poll */
 	{ &vop_kqfilter_desc, genfs_kqfilter },		/* kqfilter */
-	{ &vop_revoke_desc, kernfs_revoke },		/* revoke */
-	{ &vop_fsync_desc, kernfs_fsync },		/* fsync */
-	{ &vop_seek_desc, kernfs_seek },		/* seek */
-	{ &vop_remove_desc, kernfs_remove },		/* remove */
+	{ &vop_revoke_desc, genfs_revoke },		/* revoke */
+	{ &vop_fsync_desc, genfs_nullop },		/* fsync */
+	{ &vop_seek_desc, genfs_nullop },		/* seek */
+	{ &vop_remove_desc, genfs_eopnotsupp },		/* remove */
 	{ &vop_link_desc, kernfs_link },		/* link */
-	{ &vop_rename_desc, kernfs_rename },		/* rename */
-	{ &vop_mkdir_desc, kernfs_mkdir },		/* mkdir */
-	{ &vop_rmdir_desc, kernfs_rmdir },		/* rmdir */
+	{ &vop_rename_desc, genfs_eopnotsupp },		/* rename */
+	{ &vop_mkdir_desc, genfs_eopnotsupp },		/* mkdir */
+	{ &vop_rmdir_desc, genfs_eopnotsupp },		/* rmdir */
 	{ &vop_symlink_desc, kernfs_symlink },		/* symlink */
 	{ &vop_readdir_desc, kernfs_readdir },		/* readdir */
-	{ &vop_readlink_desc, kernfs_readlink },	/* readlink */
-	{ &vo

CVS commit: src/sys/miscfs/kernfs

2021-07-05 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Tue Jul  6 03:23:03 UTC 2021

Modified Files:
src/sys/miscfs/kernfs: kernfs_vnops.c

Log Message:
Fix perms on /kern/{r,}rootdev.


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/sys/miscfs/kernfs/kernfs_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/kernfs/kernfs_vnops.c
diff -u src/sys/miscfs/kernfs/kernfs_vnops.c:1.169 src/sys/miscfs/kernfs/kernfs_vnops.c:1.170
--- src/sys/miscfs/kernfs/kernfs_vnops.c:1.169	Tue Jul  6 03:22:44 2021
+++ src/sys/miscfs/kernfs/kernfs_vnops.c	Tue Jul  6 03:23:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernfs_vnops.c,v 1.169 2021/07/06 03:22:44 dholland Exp $	*/
+/*	$NetBSD: kernfs_vnops.c,v 1.170 2021/07/06 03:23:03 dholland Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.169 2021/07/06 03:22:44 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.170 2021/07/06 03:23:03 dholland Exp $");
 
 #include 
 #include 
@@ -91,8 +91,8 @@ const struct kern_target kern_targets[] 
 #if 0
  { DT_DIR, N("root"),  0,KFSnull,VDIR, DIR_MODE   },
 #endif
- { DT_BLK, N("rootdev"),   &rootdev, KFSdevice,  VBLK, READ_MODE  },
- { DT_CHR, N("rrootdev"),  &rrootdev,KFSdevice,  VCHR, READ_MODE  },
+ { DT_BLK, N("rootdev"),   &rootdev, KFSdevice,  VBLK, UREAD_MODE  },
+ { DT_CHR, N("rrootdev"),  &rrootdev,KFSdevice,  VCHR, UREAD_MODE  },
  { DT_REG, N("time"),  0,KFStime,VREG, READ_MODE  },
 			/* XXXUNCONST */
  { DT_REG, N("version"),   __UNCONST(version),



CVS commit: src/sys/miscfs/kernfs

2021-07-05 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Tue Jul  6 03:22:44 UTC 2021

Modified Files:
src/sys/miscfs/kernfs: kernfs_vnops.c

Log Message:
Add missing VOP_KQFILTER to kernfs.

Not sure if lack of it can be used for local DoS or not, but best to
fix.


To generate a diff of this commit:
cvs rdiff -u -r1.168 -r1.169 src/sys/miscfs/kernfs/kernfs_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/kernfs/kernfs_vnops.c
diff -u src/sys/miscfs/kernfs/kernfs_vnops.c:1.168 src/sys/miscfs/kernfs/kernfs_vnops.c:1.169
--- src/sys/miscfs/kernfs/kernfs_vnops.c:1.168	Tue Jun 29 22:34:08 2021
+++ src/sys/miscfs/kernfs/kernfs_vnops.c	Tue Jul  6 03:22:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernfs_vnops.c,v 1.168 2021/06/29 22:34:08 dholland Exp $	*/
+/*	$NetBSD: kernfs_vnops.c,v 1.169 2021/07/06 03:22:44 dholland Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.168 2021/06/29 22:34:08 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.169 2021/07/06 03:22:44 dholland Exp $");
 
 #include 
 #include 
@@ -199,6 +199,7 @@ const struct vnodeopv_entry_desc kernfs_
 	{ &vop_fcntl_desc, kernfs_fcntl },		/* fcntl */
 	{ &vop_ioctl_desc, kernfs_ioctl },		/* ioctl */
 	{ &vop_poll_desc, kernfs_poll },		/* poll */
+	{ &vop_kqfilter_desc, genfs_kqfilter },		/* kqfilter */
 	{ &vop_revoke_desc, kernfs_revoke },		/* revoke */
 	{ &vop_fsync_desc, kernfs_fsync },		/* fsync */
 	{ &vop_seek_desc, kernfs_seek },		/* seek */
@@ -249,6 +250,7 @@ const struct vnodeopv_entry_desc kernfs_
 	{ &vop_fcntl_desc, spec_fcntl },		/* fcntl */
 	{ &vop_ioctl_desc, spec_ioctl },		/* ioctl */
 	{ &vop_poll_desc, spec_poll },			/* poll */
+	{ &vop_kqfilter_desc, genfs_kqfilter },		/* kqfilter */
 	{ &vop_revoke_desc, spec_revoke },		/* revoke */
 	{ &vop_fsync_desc, spec_fsync },		/* fsync */
 	{ &vop_seek_desc, spec_seek },			/* seek */



CVS commit: src/sys/miscfs/fdesc

2021-05-01 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat May  1 15:08:14 UTC 2021

Modified Files:
src/sys/miscfs/fdesc: fdesc_vnops.c

Log Message:
Make sure fdesc_lookup() never returns VNON vnodes.

Should fix PR kern/56130 (fdescfs create nodes with wrong major number)


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/sys/miscfs/fdesc/fdesc_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/fdesc/fdesc_vnops.c
diff -u src/sys/miscfs/fdesc/fdesc_vnops.c:1.134 src/sys/miscfs/fdesc/fdesc_vnops.c:1.135
--- src/sys/miscfs/fdesc/fdesc_vnops.c:1.134	Sat Jun 27 17:29:19 2020
+++ src/sys/miscfs/fdesc/fdesc_vnops.c	Sat May  1 15:08:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdesc_vnops.c,v 1.134 2020/06/27 17:29:19 christos Exp $	*/
+/*	$NetBSD: fdesc_vnops.c,v 1.135 2021/05/01 15:08:14 hannken Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.134 2020/06/27 17:29:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.135 2021/05/01 15:08:14 hannken Exp $");
 
 #include 
 #include 
@@ -295,9 +295,20 @@ bad:
 good:
 	KASSERT(ix != -1);
 	error = vcache_get(dvp->v_mount, &ix, sizeof(ix), vpp);
-	if (error == 0 && ix == FD_CTTY)
+	if (error)
+		return error;
+
+	/*
+	 * Prevent returning VNON nodes.
+	 * Operation fdesc_inactive() will reset the type to VNON.
+	 */
+	if (ix == FD_CTTY)
 		(*vpp)->v_type = VCHR;
-	return error;
+	else if (ix >= FD_DESC)
+		(*vpp)->v_type = VREG;
+	KASSERT((*vpp)->v_type != VNON);
+
+	return 0;
 }
 
 int



CVS commit: src/sys/miscfs/procfs

2020-12-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Dec 28 22:36:16 UTC 2020

Modified Files:
src/sys/miscfs/procfs: procfs_vfsops.c

Log Message:
Fix procfs environ node.


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/sys/miscfs/procfs/procfs_vfsops.c

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

Modified files:

Index: src/sys/miscfs/procfs/procfs_vfsops.c
diff -u src/sys/miscfs/procfs/procfs_vfsops.c:1.109 src/sys/miscfs/procfs/procfs_vfsops.c:1.110
--- src/sys/miscfs/procfs/procfs_vfsops.c:1.109	Sat May 23 23:42:43 2020
+++ src/sys/miscfs/procfs/procfs_vfsops.c	Mon Dec 28 22:36:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vfsops.c,v 1.109 2020/05/23 23:42:43 ad Exp $	*/
+/*	$NetBSD: procfs_vfsops.c,v 1.110 2020/12/28 22:36:16 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.109 2020/05/23 23:42:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.110 2020/12/28 22:36:16 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -387,6 +387,7 @@ procfs_loadvnode(struct mount *mp, struc
 	case PFSmap:		/* /proc/N/map = -r */
 	case PFSmaps:		/* /proc/N/maps = -r */
 	case PFSauxv:		/* /proc/N/auxv = -r */
+	case PFSenviron:	/* /proc/N/environ = -r */
 		pfs->pfs_mode = S_IRUSR;
 		vp->v_type = VREG;
 		break;
@@ -394,7 +395,6 @@ procfs_loadvnode(struct mount *mp, struc
 	case PFSstatus:		/* /proc/N/status = -r--r--r-- */
 	case PFSstat:		/* /proc/N/stat = -r--r--r-- */
 	case PFScmdline:	/* /proc/N/cmdline = -r--r--r-- */
-	case PFSenviron:	/* /proc/N/environ = -r--r--r-- */
 	case PFSemul:		/* /proc/N/emul = -r--r--r-- */
 	case PFSmeminfo:	/* /proc/meminfo = -r--r--r-- */
 	case PFScpustat:	/* /proc/stat = -r--r--r-- */



CVS commit: src/sys/miscfs/specfs

2020-12-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Dec 25 09:28:56 UTC 2020

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
When reading from a block device, queue parallel block requests to
fill a buffer with breadn.


To generate a diff of this commit:
cvs rdiff -u -r1.180 -r1.181 src/sys/miscfs/specfs/spec_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/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.180 src/sys/miscfs/specfs/spec_vnops.c:1.181
--- src/sys/miscfs/specfs/spec_vnops.c:1.180	Sat Jun 27 17:29:19 2020
+++ src/sys/miscfs/specfs/spec_vnops.c	Fri Dec 25 09:28:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.180 2020/06/27 17:29:19 christos Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.181 2020/12/25 09:28:56 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.180 2020/06/27 17:29:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.181 2020/12/25 09:28:56 mlelstv Exp $");
 
 #include 
 #include 
@@ -695,6 +695,10 @@ spec_read(void *v)
 	struct partinfo pi;
 	int n, on;
 	int error = 0;
+	int i, nra;
+	daddr_t lastbn, *rablks;
+	int *rasizes;
+	int nrablks, ratogo;
 
 	KASSERT(uio->uio_rw == UIO_READ);
 	KASSERTMSG(VMSPACE_IS_KERNEL_P(uio->uio_vmspace) ||
@@ -723,18 +727,45 @@ spec_read(void *v)
 			bsize = BLKDEV_IOSIZE;
 
 		bscale = bsize >> DEV_BSHIFT;
+
+		nra = uimax(16 * MAXPHYS / bsize - 1, 511);
+		rablks = kmem_alloc(nra * sizeof(*rablks), KM_SLEEP);
+		rasizes = kmem_alloc(nra * sizeof(*rasizes), KM_SLEEP);
+		lastbn = ((uio->uio_offset + uio->uio_resid - 1) >> DEV_BSHIFT)
+		&~ (bscale - 1);
+		nrablks = ratogo = 0;
 		do {
 			bn = (uio->uio_offset >> DEV_BSHIFT) &~ (bscale - 1);
 			on = uio->uio_offset % bsize;
 			n = uimin((unsigned)(bsize - on), uio->uio_resid);
-			error = bread(vp, bn, bsize, 0, &bp);
-			if (error) {
-return (error);
+
+			if (ratogo == 0) {
+nrablks = uimin((lastbn - bn) / bscale, nra);
+ratogo = nrablks;
+
+for (i = 0; i < nrablks; ++i) {
+	rablks[i] = bn + (i+1) * bscale;
+	rasizes[i] = bsize;
+}
+
+error = breadn(vp, bn, bsize,
+	   rablks, rasizes, nrablks,
+	   0, &bp);
+			} else {
+if (ratogo > 0)
+	--ratogo;
+error = bread(vp, bn, bsize, 0, &bp);
 			}
+			if (error)
+break;
 			n = uimin(n, bsize - bp->b_resid);
 			error = uiomove((char *)bp->b_data + on, n, uio);
 			brelse(bp, 0);
 		} while (error == 0 && uio->uio_resid > 0 && n != 0);
+
+		kmem_free(rablks, nra * sizeof(*rablks));
+		kmem_free(rasizes, nra * sizeof(*rasizes));
+
 		return (error);
 
 	default:



CVS commit: src/sys/miscfs/genfs

2020-08-10 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Aug 10 11:09:15 UTC 2020

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
Output offsets in hex for UVMHIST.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/miscfs/genfs/genfs_io.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/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.98 src/sys/miscfs/genfs/genfs_io.c:1.99
--- src/sys/miscfs/genfs/genfs_io.c:1.98	Sun Jun 14 00:25:22 2020
+++ src/sys/miscfs/genfs/genfs_io.c	Mon Aug 10 11:09:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.98 2020/06/14 00:25:22 ad Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.99 2020/08/10 11:09:15 rin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.98 2020/06/14 00:25:22 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.99 2020/08/10 11:09:15 rin Exp $");
 
 #include 
 #include 
@@ -320,7 +320,7 @@ startover:
 		(void)memset(pgs, 0, pgs_size);
 	}
 
-	UVMHIST_LOG(ubchist, "ridx %jd npages %jd startoff %jd endoff %jd",
+	UVMHIST_LOG(ubchist, "ridx %jd npages %jd startoff %#jx endoff %#jx",
 	ridx, npages, startoffset, endoffset);
 
 	if (trans_mount == NULL) {



CVS commit: src/sys/miscfs/genfs

2020-08-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Aug  7 18:14:22 UTC 2020

Modified Files:
src/sys/miscfs/genfs: genfs.h genfs_vnops.c

Log Message:
accmode should be accmode_t


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/miscfs/genfs/genfs.h
cvs rdiff -u -r1.208 -r1.209 src/sys/miscfs/genfs/genfs_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/genfs/genfs.h
diff -u src/sys/miscfs/genfs/genfs.h:1.35 src/sys/miscfs/genfs/genfs.h:1.36
--- src/sys/miscfs/genfs/genfs.h:1.35	Sat Jun 27 13:29:19 2020
+++ src/sys/miscfs/genfs/genfs.h	Fri Aug  7 14:14:21 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs.h,v 1.35 2020/06/27 17:29:19 christos Exp $	*/
+/*	$NetBSD: genfs.h,v 1.36 2020/08/07 18:14:21 christos Exp $	*/
 
 #ifndef	_MISCFS_GENFS_GENFS_H_
 #define	_MISCFS_GENFS_GENFS_H_
@@ -64,7 +64,7 @@ int	genfs_can_chown(struct vnode *, kaut
 int	genfs_can_chtimes(struct vnode *, kauth_cred_t, uid_t, u_int);
 int	genfs_can_chflags(struct vnode *, kauth_cred_t, uid_t, bool);
 int	genfs_can_sticky(struct vnode *, kauth_cred_t, uid_t, uid_t);
-int	genfs_can_extattr(struct vnode *, kauth_cred_t, int, int);
+int	genfs_can_extattr(struct vnode *, kauth_cred_t, accmode_t, int);
 
 /*
  * Rename is complicated.  Sorry.

Index: src/sys/miscfs/genfs/genfs_vnops.c
diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.208 src/sys/miscfs/genfs/genfs_vnops.c:1.209
--- src/sys/miscfs/genfs/genfs_vnops.c:1.208	Sat Jun 27 13:29:19 2020
+++ src/sys/miscfs/genfs/genfs_vnops.c	Fri Aug  7 14:14:21 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_vnops.c,v 1.208 2020/06/27 17:29:19 christos Exp $	*/
+/*	$NetBSD: genfs_vnops.c,v 1.209 2020/08/07 18:14:21 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.208 2020/06/27 17:29:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.209 2020/08/07 18:14:21 christos Exp $");
 
 #include 
 #include 
@@ -1397,7 +1397,7 @@ genfs_can_sticky(vnode_t *vp, kauth_cred
 }
 
 int
-genfs_can_extattr(vnode_t *vp, kauth_cred_t cred, int accmode,
+genfs_can_extattr(vnode_t *vp, kauth_cred_t cred, accmode_t accmode,
 int attrnamespace)
 {
 	/*



CVS commit: src/sys/miscfs/genfs

2020-06-13 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sun Jun 14 00:25:22 UTC 2020

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
genfs_putpages(): when building a cluster make use of pages in the in the
existing uvm_page_array.


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/miscfs/genfs/genfs_io.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/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.97 src/sys/miscfs/genfs/genfs_io.c:1.98
--- src/sys/miscfs/genfs/genfs_io.c:1.97	Mon May 25 21:15:10 2020
+++ src/sys/miscfs/genfs/genfs_io.c	Sun Jun 14 00:25:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.97 2020/05/25 21:15:10 ad Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.98 2020/06/14 00:25:22 ad Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.97 2020/05/25 21:15:10 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.98 2020/06/14 00:25:22 ad Exp $");
 
 #include 
 #include 
@@ -1208,6 +1208,11 @@ retry:
 			 *	0
 			 *	UVM_PAGE_ARRAY_FILL_DIRTY
 			 *	UVM_PAGE_ARRAY_FILL_DIRTY|WRITEBACK
+			 *
+			 * XXX this is fragile but it'll work: the array
+			 * was earlier filled sparsely, but UFP_DIRTYONLY
+			 * implies dense.  see corresponding comment in
+			 * uvn_findpages().
 			 */
 
 			npages = MAXPAGES - nback - 1;
@@ -1215,7 +1220,7 @@ retry:
 npages = MIN(npages,
 	 (fshi - off - 1) >> PAGE_SHIFT);
 			uvn_findpages(uobj, off + PAGE_SIZE, &npages,
-			&pgs[nback + 1], NULL,
+			&pgs[nback + 1], &a,
 			UFP_NOWAIT|UFP_NOALLOC|UFP_DIRTYONLY);
 			npages += nback + 1;
 		} else {



CVS commit: src/sys/miscfs/procfs

2020-05-31 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun May 31 08:38:54 UTC 2020

Modified Files:
src/sys/miscfs/procfs: procfs_linux.c

Log Message:
struct statvfs is too large for stack. Use malloc(9) instead.

XXX
Switch to kmem(9) for entire this file.

Frame size, e.g. for m68k, becomes:
3292 --> 12


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/miscfs/procfs/procfs_linux.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/procfs/procfs_linux.c
diff -u src/sys/miscfs/procfs/procfs_linux.c:1.83 src/sys/miscfs/procfs/procfs_linux.c:1.84
--- src/sys/miscfs/procfs/procfs_linux.c:1.83	Sat May 23 23:42:43 2020
+++ src/sys/miscfs/procfs/procfs_linux.c	Sun May 31 08:38:54 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: procfs_linux.c,v 1.83 2020/05/23 23:42:43 ad Exp $  */
+/*  $NetBSD: procfs_linux.c,v 1.84 2020/05/31 08:38:54 rin Exp $  */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.83 2020/05/23 23:42:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.84 2020/05/31 08:38:54 rin Exp $");
 
 #include 
 #include 
@@ -611,18 +611,19 @@ procfs_domounts(struct lwp *curl, struct
 	struct mount *mp;
 	int error = 0, root = 0;
 	struct cwdinfo *cwdi = curl->l_proc->p_cwdi;
+	struct statvfs *sfs;
 
 	bf = malloc(LBFSZ, M_TEMP, M_WAITOK);
 
+	sfs = malloc(sizeof(*sfs), M_TEMP, M_WAITOK);
 	mountlist_iterator_init(&iter);
 	while ((mp = mountlist_iterator_next(iter)) != NULL) {
-		struct statvfs sfs;
-
-		if ((error = dostatvfs(mp, &sfs, curl, MNT_WAIT, 0)) == 0)
+		if ((error = dostatvfs(mp, sfs, curl, MNT_WAIT, 0)) == 0)
 			root |= procfs_format_sfs(&mtab, &mtabsz, bf, LBFSZ,
-			&sfs, curl, 0);
+			sfs, curl, 0);
 	}
 	mountlist_iterator_destroy(iter);
+	free(sfs, M_TEMP);
 
 	/*
 	 * If we are inside a chroot that is not itself a mount point,



CVS commit: src/sys/miscfs/genfs

2020-05-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May 20 17:06:15 UTC 2020

Modified Files:
src/sys/miscfs/genfs: genfs_vnops.c

Log Message:
Fix EPERM vs EACCES on chtimes (thanks @hannken)


To generate a diff of this commit:
cvs rdiff -u -r1.206 -r1.207 src/sys/miscfs/genfs/genfs_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/genfs/genfs_vnops.c
diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.206 src/sys/miscfs/genfs/genfs_vnops.c:1.207
--- src/sys/miscfs/genfs/genfs_vnops.c:1.206	Mon May 18 15:55:42 2020
+++ src/sys/miscfs/genfs/genfs_vnops.c	Wed May 20 13:06:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_vnops.c,v 1.206 2020/05/18 19:55:42 christos Exp $	*/
+/*	$NetBSD: genfs_vnops.c,v 1.207 2020/05/20 17:06:15 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.206 2020/05/18 19:55:42 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.207 2020/05/20 17:06:15 christos Exp $");
 
 #include 
 #include 
@@ -1320,7 +1320,7 @@ genfs_can_chtimes(vnode_t *vp, kauth_cre
 	 * server time.
 	 */
 	if ((error = VOP_ACCESSX(vp, VWRITE_ATTRIBUTES, cred)) != 0)
-		return (error);
+		return (vaflags & VA_UTIMES_NULL) == 0 ? EPERM : EACCES;
 
 	/* Must be owner, or... */
 	if (kauth_cred_geteuid(cred) == owner_uid)



CVS commit: src/sys/miscfs/genfs

2020-05-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon May 18 19:55:42 UTC 2020

Modified Files:
src/sys/miscfs/genfs: genfs_vnops.c

Log Message:
remove debugging, it is just clutter.


To generate a diff of this commit:
cvs rdiff -u -r1.205 -r1.206 src/sys/miscfs/genfs/genfs_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/genfs/genfs_vnops.c
diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.205 src/sys/miscfs/genfs/genfs_vnops.c:1.206
--- src/sys/miscfs/genfs/genfs_vnops.c:1.205	Mon May 18 15:42:16 2020
+++ src/sys/miscfs/genfs/genfs_vnops.c	Mon May 18 15:55:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_vnops.c,v 1.205 2020/05/18 19:42:16 christos Exp $	*/
+/*	$NetBSD: genfs_vnops.c,v 1.206 2020/05/18 19:55:42 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.205 2020/05/18 19:42:16 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.206 2020/05/18 19:55:42 christos Exp $");
 
 #include 
 #include 
@@ -695,13 +695,7 @@ genfs_can_access(vnode_t *vp, kauth_cred
 
 	KASSERT((accmode & ~(VEXEC | VWRITE | VREAD | VADMIN | VAPPEND)) == 0);
 	KASSERT((accmode & VAPPEND) == 0 || (accmode & VWRITE));
-#ifdef ACL_DEBUG
-	char buf[128];
-	snprintb(buf, sizeof(buf), __VNODE_PERM_BITS, accmode);
-	printf("%s: %s cred_uid=%d cred_gid=%d file_uid=%d file_gid=%d\n",
-	__func__, buf, kauth_cred_geteuid(cred), kauth_cred_getegid(cred),
-	file_uid, file_gid);
-#endif
+
 	/*
 	 * Look for a normal, non-privileged way to access the file/directory
 	 * as requested.  If it exists, go with that.
@@ -719,10 +713,6 @@ genfs_can_access(vnode_t *vp, kauth_cred
 		if (file_mode & S_IWUSR)
 			dac_granted |= (VWRITE | VAPPEND);
 
-#ifdef ACL_DEBUG
-		printf("%s: owner %o %o\n", __func__,
-		accmode & dac_granted, accmode);
-#endif
 		goto privchk;
 	}
 
@@ -739,10 +729,6 @@ genfs_can_access(vnode_t *vp, kauth_cred
 		if (file_mode & S_IWGRP)
 			dac_granted |= (VWRITE | VAPPEND);
 
-#ifdef ACL_DEBUG
-		printf("%s: group %o %o\n", __func__,
-		accmode & dac_granted, accmode);
-#endif
 		goto privchk;
 	}
 
@@ -754,10 +740,6 @@ genfs_can_access(vnode_t *vp, kauth_cred
 	if (file_mode & S_IWOTH)
 		dac_granted |= (VWRITE | VAPPEND);
 
-#ifdef ACL_DEBUG
-	printf("%s: others %o %o\n", __func__,
-	accmode & dac_granted, accmode);
-#endif
 privchk:
 	if ((accmode & dac_granted) == accmode)
 		return 0;
@@ -1127,12 +1109,6 @@ genfs_can_access_acl_nfs4(vnode_t *vp, k
 	VREAD_ACL | VWRITE_ACL | VWRITE_OWNER | VSYNCHRONIZE)) == 0);
 	KASSERT((accmode & VAPPEND) == 0 || (accmode & VWRITE));
 
-#ifdef ACL_DEBUG
-	char buf[128];
-	snprintb(buf, sizeof(buf), __VNODE_PERM_BITS, accmode);
-	printf("%s: %s file_uid=%d file_gid=%d\n", __func__, buf, file_uid, file_gid);
-#endif
-
 	if (accmode & VADMIN)
 		must_be_owner = 1;
 



CVS commit: src/sys/miscfs/genfs

2020-05-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon May 18 19:42:16 UTC 2020

Modified Files:
src/sys/miscfs/genfs: genfs_vnops.c

Log Message:
Fix EPERM vs EACCES return.


To generate a diff of this commit:
cvs rdiff -u -r1.204 -r1.205 src/sys/miscfs/genfs/genfs_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/genfs/genfs_vnops.c
diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.204 src/sys/miscfs/genfs/genfs_vnops.c:1.205
--- src/sys/miscfs/genfs/genfs_vnops.c:1.204	Sat May 16 14:31:51 2020
+++ src/sys/miscfs/genfs/genfs_vnops.c	Mon May 18 15:42:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_vnops.c,v 1.204 2020/05/16 18:31:51 christos Exp $	*/
+/*	$NetBSD: genfs_vnops.c,v 1.205 2020/05/18 19:42:16 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.204 2020/05/16 18:31:51 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.205 2020/05/18 19:42:16 christos Exp $");
 
 #include 
 #include 
@@ -695,7 +695,13 @@ genfs_can_access(vnode_t *vp, kauth_cred
 
 	KASSERT((accmode & ~(VEXEC | VWRITE | VREAD | VADMIN | VAPPEND)) == 0);
 	KASSERT((accmode & VAPPEND) == 0 || (accmode & VWRITE));
-
+#ifdef ACL_DEBUG
+	char buf[128];
+	snprintb(buf, sizeof(buf), __VNODE_PERM_BITS, accmode);
+	printf("%s: %s cred_uid=%d cred_gid=%d file_uid=%d file_gid=%d\n",
+	__func__, buf, kauth_cred_geteuid(cred), kauth_cred_getegid(cred),
+	file_uid, file_gid);
+#endif
 	/*
 	 * Look for a normal, non-privileged way to access the file/directory
 	 * as requested.  If it exists, go with that.
@@ -713,7 +719,11 @@ genfs_can_access(vnode_t *vp, kauth_cred
 		if (file_mode & S_IWUSR)
 			dac_granted |= (VWRITE | VAPPEND);
 
-		return (accmode & dac_granted) == accmode ? 0 : EPERM;
+#ifdef ACL_DEBUG
+		printf("%s: owner %o %o\n", __func__,
+		accmode & dac_granted, accmode);
+#endif
+		goto privchk;
 	}
 
 	/* Otherwise, check the groups (first match) */
@@ -729,7 +739,11 @@ genfs_can_access(vnode_t *vp, kauth_cred
 		if (file_mode & S_IWGRP)
 			dac_granted |= (VWRITE | VAPPEND);
 
-		return (accmode & dac_granted) == accmode ? 0 : EACCES;
+#ifdef ACL_DEBUG
+		printf("%s: group %o %o\n", __func__,
+		accmode & dac_granted, accmode);
+#endif
+		goto privchk;
 	}
 
 	/* Otherwise, check everyone else. */
@@ -739,8 +753,16 @@ genfs_can_access(vnode_t *vp, kauth_cred
 		dac_granted |= VREAD;
 	if (file_mode & S_IWOTH)
 		dac_granted |= (VWRITE | VAPPEND);
-	return (accmode & dac_granted) == accmode ? 0 : EACCES;
-		return (0);
+
+#ifdef ACL_DEBUG
+	printf("%s: others %o %o\n", __func__,
+	accmode & dac_granted, accmode);
+#endif
+privchk:
+	if ((accmode & dac_granted) == accmode)
+		return 0;
+
+	return (accmode & VADMIN) ? EPERM : EACCES;
 }
 
 /*
@@ -1108,7 +1130,7 @@ genfs_can_access_acl_nfs4(vnode_t *vp, k
 #ifdef ACL_DEBUG
 	char buf[128];
 	snprintb(buf, sizeof(buf), __VNODE_PERM_BITS, accmode);
-	printf("%s: %s uid=%d gid=%d\n", __func__, buf, file_uid, file_gid);
+	printf("%s: %s file_uid=%d file_gid=%d\n", __func__, buf, file_uid, file_gid);
 #endif
 
 	if (accmode & VADMIN)



CVS commit: src/sys/miscfs/procfs

2020-04-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Apr 29 07:18:24 UTC 2020

Modified Files:
src/sys/miscfs/procfs: procfs.h

Log Message:
Put forward declaration a little further forward to unbreak build.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/miscfs/procfs/procfs.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/miscfs/procfs/procfs.h
diff -u src/sys/miscfs/procfs/procfs.h:1.79 src/sys/miscfs/procfs/procfs.h:1.80
--- src/sys/miscfs/procfs/procfs.h:1.79	Wed Apr 29 01:56:54 2020
+++ src/sys/miscfs/procfs/procfs.h	Wed Apr 29 07:18:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs.h,v 1.79 2020/04/29 01:56:54 thorpej Exp $	*/
+/*	$NetBSD: procfs.h,v 1.80 2020/04/29 07:18:24 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -209,11 +209,12 @@ struct vfs_namemap {
 int vfs_getuserstr(struct uio *, char *, int *);
 const vfs_namemap_t *vfs_findname(const vfs_namemap_t *, const char *, int);
 
+struct mount;
+
 struct proc *procfs_proc_find(struct mount *, pid_t);
 bool procfs_use_linux_compat(struct mount *);
 int procfs_proc_lock(struct mount *, int, struct proc **, int);
 void procfs_proc_unlock(struct proc *);
-struct mount;
 int procfs_allocvp(struct mount *, struct vnode **, pid_t, pfstype, int);
 int procfs_donote(struct lwp *, struct proc *, struct pfsnode *,
 struct uio *);



CVS commit: src/sys/miscfs/procfs

2020-04-28 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Apr 29 01:56:54 UTC 2020

Modified Files:
src/sys/miscfs/procfs: procfs.h procfs_subr.c procfs_vfsops.c
procfs_vnops.c

Log Message:
If the procfs mount is marked as linux-compat, then allow proc lookup
by any LWP ID in the proc, not just the canonical PID.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/miscfs/procfs/procfs.h
cvs rdiff -u -r1.114 -r1.115 src/sys/miscfs/procfs/procfs_subr.c
cvs rdiff -u -r1.107 -r1.108 src/sys/miscfs/procfs/procfs_vfsops.c
cvs rdiff -u -r1.211 -r1.212 src/sys/miscfs/procfs/procfs_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/procfs/procfs.h
diff -u src/sys/miscfs/procfs/procfs.h:1.78 src/sys/miscfs/procfs/procfs.h:1.79
--- src/sys/miscfs/procfs/procfs.h:1.78	Fri Jan 17 20:08:09 2020
+++ src/sys/miscfs/procfs/procfs.h	Wed Apr 29 01:56:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs.h,v 1.78 2020/01/17 20:08:09 ad Exp $	*/
+/*	$NetBSD: procfs.h,v 1.79 2020/04/29 01:56:54 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -209,7 +209,9 @@ struct vfs_namemap {
 int vfs_getuserstr(struct uio *, char *, int *);
 const vfs_namemap_t *vfs_findname(const vfs_namemap_t *, const char *, int);
 
-int procfs_proc_lock(int, struct proc **, int);
+struct proc *procfs_proc_find(struct mount *, pid_t);
+bool procfs_use_linux_compat(struct mount *);
+int procfs_proc_lock(struct mount *, int, struct proc **, int);
 void procfs_proc_unlock(struct proc *);
 struct mount;
 int procfs_allocvp(struct mount *, struct vnode **, pid_t, pfstype, int);

Index: src/sys/miscfs/procfs/procfs_subr.c
diff -u src/sys/miscfs/procfs/procfs_subr.c:1.114 src/sys/miscfs/procfs/procfs_subr.c:1.115
--- src/sys/miscfs/procfs/procfs_subr.c:1.114	Thu Sep 26 17:34:08 2019
+++ src/sys/miscfs/procfs/procfs_subr.c	Wed Apr 29 01:56:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_subr.c,v 1.114 2019/09/26 17:34:08 christos Exp $	*/
+/*	$NetBSD: procfs_subr.c,v 1.115 2020/04/29 01:56:54 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -102,7 +102,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.114 2019/09/26 17:34:08 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.115 2020/04/29 01:56:54 thorpej Exp $");
 
 #include 
 #include 
@@ -152,7 +152,8 @@ procfs_rw(void *v)
 	if (uio->uio_offset < 0)
 		return EINVAL;
 
-	if ((error = procfs_proc_lock(pfs->pfs_pid, &p, ESRCH)) != 0)
+	if ((error =
+	 procfs_proc_lock(vp->v_mount, pfs->pfs_pid, &p, ESRCH)) != 0)
 		return error;
 
 	curl = curlwp;
@@ -408,8 +409,25 @@ procfs_revoke_vnodes(struct proc *p, voi
 	vfs_vnode_iterator_destroy(marker);
 }
 
+bool
+procfs_use_linux_compat(struct mount *mp)
+{
+	const int flags = VFSTOPROC(mp)->pmnt_flags;
+
+	return (flags & PROCFSMNT_LINUXCOMPAT) ? true : false;
+}
+
+struct proc *
+procfs_proc_find(struct mount *mp, pid_t pid)
+{
+	KASSERT(mutex_owned(proc_lock));
+	return procfs_use_linux_compat(mp) ? proc_find_lwpid(pid)
+	   : proc_find(pid);
+}
+
 int
-procfs_proc_lock(int pid, struct proc **bunghole, int notfound)
+procfs_proc_lock(struct mount *mp, int pid, struct proc **bunghole,
+		 int notfound)
 {
 	struct proc *tp;
 	int error = 0;
@@ -418,7 +436,7 @@ procfs_proc_lock(int pid, struct proc **
 
 	if (pid == 0)
 		tp = &proc0;
-	else if ((tp = proc_find(pid)) == NULL)
+	else if ((tp = procfs_proc_find(mp, pid)) == NULL)
 		error = notfound;
 	if (tp != NULL && !rw_tryenter(&tp->p_reflock, RW_READER))
 		error = EBUSY;

Index: src/sys/miscfs/procfs/procfs_vfsops.c
diff -u src/sys/miscfs/procfs/procfs_vfsops.c:1.107 src/sys/miscfs/procfs/procfs_vfsops.c:1.108
--- src/sys/miscfs/procfs/procfs_vfsops.c:1.107	Mon Apr 20 05:22:28 2020
+++ src/sys/miscfs/procfs/procfs_vfsops.c	Wed Apr 29 01:56:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vfsops.c,v 1.107 2020/04/20 05:22:28 htodd Exp $	*/
+/*	$NetBSD: procfs_vfsops.c,v 1.108 2020/04/29 01:56:54 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.107 2020/04/20 05:22:28 htodd Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.108 2020/04/29 01:56:54 thorpej Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -322,7 +322,7 @@ procfs_loadvnode(struct mount *mp, struc
 			struct proc *p;
 
 			mutex_enter(proc_lock);
-			p = proc_find(pfs->pfs_pid);
+			p = procfs_proc_find(mp, pfs->pfs_pid);
 			mutex_exit(proc_lock);
 			if (p == NULL) {
 error = ENOENT;

Index: src/sys/miscfs/procfs/procfs_vnops.c
diff -u src/sys/miscfs/procfs/procfs_vnops.c:1.211 src/sys/miscfs/procfs/procfs_vnops.c:1.212
--- src/sys/miscfs/procfs/procfs_vnops.c:1.211	Tue Apr 21 21:42:47 2020
+++ src/sys/miscfs/procfs/procfs_vnops.c	Wed Apr 29 01:56:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vnops.c,v 1.211 2020/04/21

CVS commit: src/sys/miscfs/genfs

2020-04-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Apr 25 22:28:47 UTC 2020

Modified Files:
src/sys/miscfs/genfs: genfs_vnops.c

Log Message:
Allow root to access and modify system space extended attributes.
XXX: this routine should not be using the string, but the attribute namespace.
I have fixed this in the ACL code.


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/sys/miscfs/genfs/genfs_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/genfs/genfs_vnops.c
diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.202 src/sys/miscfs/genfs/genfs_vnops.c:1.203
--- src/sys/miscfs/genfs/genfs_vnops.c:1.202	Sun Feb 23 17:14:04 2020
+++ src/sys/miscfs/genfs/genfs_vnops.c	Sat Apr 25 18:28:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_vnops.c,v 1.202 2020/02/23 22:14:04 ad Exp $	*/
+/*	$NetBSD: genfs_vnops.c,v 1.203 2020/04/25 22:28:47 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.202 2020/02/23 22:14:04 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.203 2020/04/25 22:28:47 christos Exp $");
 
 #include 
 #include 
@@ -904,9 +904,13 @@ int
 genfs_can_extattr(kauth_cred_t cred, int access_mode, vnode_t *vp,
 const char *attr)
 {
-	/* We can't allow privileged namespaces. */
-	if (strncasecmp(attr, "system", 6) == 0)
-		return EPERM;
+	/*
+	 * This string comparison is bogus: see xattr_native in vfs_xattr.c;
+	 * it is going to go away soon.
+	 */
+	if (strncasecmp(attr, "system.", 7) == 0)
+	   return kauth_authorize_system(cred, KAUTH_SYSTEM_FS_EXTATTR,
+		   0, vp->v_mount, NULL, NULL);
 
 	return VOP_ACCESS(vp, access_mode, cred);
 }



CVS commit: src/sys/miscfs/procfs

2020-04-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr 20 13:30:34 UTC 2020

Modified Files:
src/sys/miscfs/procfs: procfs_linux.c

Log Message:
Add missing include of  to fix the build


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/miscfs/procfs/procfs_linux.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/procfs/procfs_linux.c
diff -u src/sys/miscfs/procfs/procfs_linux.c:1.81 src/sys/miscfs/procfs/procfs_linux.c:1.82
--- src/sys/miscfs/procfs/procfs_linux.c:1.81	Sun Apr 19 20:31:59 2020
+++ src/sys/miscfs/procfs/procfs_linux.c	Mon Apr 20 13:30:34 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: procfs_linux.c,v 1.81 2020/04/19 20:31:59 thorpej Exp $  */
+/*  $NetBSD: procfs_linux.c,v 1.82 2020/04/20 13:30:34 martin Exp $  */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,10 +36,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.81 2020/04/19 20:31:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.82 2020/04/20 13:30:34 martin Exp $");
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 



CVS commit: src/sys/miscfs/procfs

2020-04-19 Thread Hisashi T Fujinaka
Module Name:src
Committed By:   htodd
Date:   Mon Apr 20 05:22:28 UTC 2020

Modified Files:
src/sys/miscfs/procfs: procfs_vfsops.c

Log Message:
Sort include files.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/miscfs/procfs/procfs_vfsops.c

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

Modified files:

Index: src/sys/miscfs/procfs/procfs_vfsops.c
diff -u src/sys/miscfs/procfs/procfs_vfsops.c:1.106 src/sys/miscfs/procfs/procfs_vfsops.c:1.107
--- src/sys/miscfs/procfs/procfs_vfsops.c:1.106	Mon Apr 20 05:11:00 2020
+++ src/sys/miscfs/procfs/procfs_vfsops.c	Mon Apr 20 05:22:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vfsops.c,v 1.106 2020/04/20 05:11:00 htodd Exp $	*/
+/*	$NetBSD: procfs_vfsops.c,v 1.107 2020/04/20 05:22:28 htodd Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -76,29 +76,29 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.106 2020/04/20 05:11:00 htodd Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.107 2020/04/20 05:22:28 htodd Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
 #endif
 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
+#include 
 #include 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
 



CVS commit: src/sys/miscfs/procfs

2020-04-19 Thread Hisashi T Fujinaka
Module Name:src
Committed By:   htodd
Date:   Mon Apr 20 05:11:01 UTC 2020

Modified Files:
src/sys/miscfs/procfs: procfs_vfsops.c

Log Message:
Add missing include to fix build.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/miscfs/procfs/procfs_vfsops.c

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

Modified files:

Index: src/sys/miscfs/procfs/procfs_vfsops.c
diff -u src/sys/miscfs/procfs/procfs_vfsops.c:1.105 src/sys/miscfs/procfs/procfs_vfsops.c:1.106
--- src/sys/miscfs/procfs/procfs_vfsops.c:1.105	Sun Apr 19 20:31:59 2020
+++ src/sys/miscfs/procfs/procfs_vfsops.c	Mon Apr 20 05:11:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vfsops.c,v 1.105 2020/04/19 20:31:59 thorpej Exp $	*/
+/*	$NetBSD: procfs_vfsops.c,v 1.106 2020/04/20 05:11:00 htodd Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.105 2020/04/19 20:31:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.106 2020/04/20 05:11:00 htodd Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -98,6 +98,7 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_vfsop
 #include 
 #include 
 #include 
+#include 
 
 #include 
 



CVS commit: src/sys/miscfs/specfs

2020-04-13 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Apr 13 20:02:27 UTC 2020

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
when determining I/O block size for VBLK device, only use pi_bsize
returned by DIOCGPARTINFO if it's bigger than DEV_BSIZE and less
than MAXBSIZE (MAXPHYS)

fixes panic "buf mem pool index 8" in buf_mempoolidx() when the
disklabel contains bsize 128KB and something reads the block device -
buffer cache can't allocate bufs bigger than MAXPHYS


To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.177 src/sys/miscfs/specfs/spec_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/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.176 src/sys/miscfs/specfs/spec_vnops.c:1.177
--- src/sys/miscfs/specfs/spec_vnops.c:1.176	Sun Sep 22 22:59:39 2019
+++ src/sys/miscfs/specfs/spec_vnops.c	Mon Apr 13 20:02:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.176 2019/09/22 22:59:39 christos Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.177 2020/04/13 20:02:27 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.176 2019/09/22 22:59:39 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.177 2020/04/13 20:02:27 jdolecek Exp $");
 
 #include 
 #include 
@@ -717,7 +717,7 @@ spec_read(void *v)
 			return (EINVAL);
 
 		if (bdev_ioctl(vp->v_rdev, DIOCGPARTINFO, &pi, FREAD, l) == 0)
-			bsize = pi.pi_bsize;
+			bsize = imin(imax(pi.pi_bsize, DEV_BSIZE), MAXBSIZE);
 		else
 			bsize = BLKDEV_IOSIZE;
 
@@ -786,7 +786,7 @@ spec_write(void *v)
 			return (EINVAL);
 
 		if (bdev_ioctl(vp->v_rdev, DIOCGPARTINFO, &pi, FREAD, l) == 0)
-			bsize = pi.pi_bsize;
+			bsize = imin(imax(pi.pi_bsize, DEV_BSIZE), MAXBSIZE);
 		else
 			bsize = BLKDEV_IOSIZE;
 



CVS commit: src/sys/miscfs/kernfs

2020-04-07 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Tue Apr  7 08:35:49 UTC 2020

Modified Files:
src/sys/miscfs/kernfs: kernfs_vfsops.c

Log Message:
switch to kmem_zalloc() instead of malloc() for struct kernfs_mount


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/miscfs/kernfs/kernfs_vfsops.c

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

Modified files:

Index: src/sys/miscfs/kernfs/kernfs_vfsops.c
diff -u src/sys/miscfs/kernfs/kernfs_vfsops.c:1.99 src/sys/miscfs/kernfs/kernfs_vfsops.c:1.100
--- src/sys/miscfs/kernfs/kernfs_vfsops.c:1.99	Mon Mar 16 21:20:11 2020
+++ src/sys/miscfs/kernfs/kernfs_vfsops.c	Tue Apr  7 08:35:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernfs_vfsops.c,v 1.99 2020/03/16 21:20:11 pgoyette Exp $	*/
+/*	$NetBSD: kernfs_vfsops.c,v 1.100 2020/04/07 08:35:49 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.99 2020/03/16 21:20:11 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.100 2020/04/07 08:35:49 jdolecek Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -54,7 +54,6 @@ __KERNEL_RCSID(0, "$NetBSD: kernfs_vfsop
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -65,8 +64,6 @@ __KERNEL_RCSID(0, "$NetBSD: kernfs_vfsop
 
 MODULE(MODULE_CLASS_VFS, kernfs, NULL);
 
-MALLOC_JUSTDEFINE(M_KERNFSMNT, "kernfs mount", "kernfs mount structures");
-
 dev_t rrootdev = NODEV;
 kmutex_t kfs_lock;
 
@@ -78,7 +75,6 @@ void
 kernfs_init(void)
 {
 
-	malloc_type_attach(M_KERNFSMNT);
 	mutex_init(&kfs_lock, MUTEX_DEFAULT, IPL_NONE);
 }
 
@@ -93,7 +89,6 @@ kernfs_done(void)
 {
 
 	mutex_destroy(&kfs_lock);
-	malloc_type_detach(M_KERNFSMNT);
 }
 
 void
@@ -141,7 +136,7 @@ kernfs_mount(struct mount *mp, const cha
 	if (mp->mnt_flag & MNT_UPDATE)
 		return (EOPNOTSUPP);
 
-	fmp = malloc(sizeof(struct kernfs_mount), M_KERNFSMNT, M_WAITOK|M_ZERO);
+	fmp = kmem_zalloc(sizeof(struct kernfs_mount), KM_SLEEP);
 	TAILQ_INIT(&fmp->nodelist);
 
 	mp->mnt_stat.f_namemax = KERNFS_MAXNAMLEN;
@@ -151,7 +146,7 @@ kernfs_mount(struct mount *mp, const cha
 
 	if ((error = set_statvfs_info(path, UIO_USERSPACE, "kernfs",
 	UIO_SYSSPACE, mp->mnt_op->vfs_name, mp, l)) != 0) {
-		free(fmp, M_KERNFSMNT);
+		kmem_free(fmp, sizeof(struct kernfs_mount));
 		return error;
 	}
 
@@ -181,7 +176,7 @@ kernfs_unmount(struct mount *mp, int mnt
 	/*
 	 * Finally, throw away the kernfs_mount structure
 	 */
-	free(mp->mnt_data, M_KERNFSMNT);
+	kmem_free(mp->mnt_data, sizeof(struct kernfs_mount));
 	mp->mnt_data = NULL;
 	return (0);
 }



CVS commit: src/sys/miscfs

2020-03-21 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Mar 21 16:30:39 UTC 2020

Modified Files:
src/sys/miscfs/fdesc: fdesc_vfsops.c
src/sys/miscfs/overlay: overlay_vfsops.c

Log Message:
Finish the transition to SYSCTL_SETUP by removing local sysctllog
in favor of the one provided by the module infrastructure.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/miscfs/fdesc/fdesc_vfsops.c
cvs rdiff -u -r1.69 -r1.70 src/sys/miscfs/overlay/overlay_vfsops.c

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

Modified files:

Index: src/sys/miscfs/fdesc/fdesc_vfsops.c
diff -u src/sys/miscfs/fdesc/fdesc_vfsops.c:1.94 src/sys/miscfs/fdesc/fdesc_vfsops.c:1.95
--- src/sys/miscfs/fdesc/fdesc_vfsops.c:1.94	Mon Mar 16 21:20:11 2020
+++ src/sys/miscfs/fdesc/fdesc_vfsops.c	Sat Mar 21 16:30:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdesc_vfsops.c,v 1.94 2020/03/16 21:20:11 pgoyette Exp $	*/
+/*	$NetBSD: fdesc_vfsops.c,v 1.95 2020/03/21 16:30:39 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993, 1995
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdesc_vfsops.c,v 1.94 2020/03/16 21:20:11 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdesc_vfsops.c,v 1.95 2020/03/21 16:30:39 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -68,8 +68,6 @@ MODULE(MODULE_CLASS_VFS, fdesc, NULL);
 
 VFS_PROTOS(fdesc);
 
-static struct sysctllog *fdesc_sysctl_log;
-
 /*
  * Mount the per-process file descriptors (/dev/fd)
  */
@@ -266,7 +264,7 @@ struct vfsops fdesc_vfsops = {
 SYSCTL_SETUP(fdesc_sysctl_setup, "fdesc sysctl")
 {
 
-		sysctl_createv(&fdesc_sysctl_log, 0, NULL, NULL,
+		sysctl_createv(clog, 0, NULL, NULL,
 			   CTLFLAG_PERMANENT,
 			   CTLTYPE_NODE, "fdesc",
 			   SYSCTL_DESCR("File-descriptor file system"),

Index: src/sys/miscfs/overlay/overlay_vfsops.c
diff -u src/sys/miscfs/overlay/overlay_vfsops.c:1.69 src/sys/miscfs/overlay/overlay_vfsops.c:1.70
--- src/sys/miscfs/overlay/overlay_vfsops.c:1.69	Mon Mar 16 21:20:11 2020
+++ src/sys/miscfs/overlay/overlay_vfsops.c	Sat Mar 21 16:30:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: overlay_vfsops.c,v 1.69 2020/03/16 21:20:11 pgoyette Exp $	*/
+/*	$NetBSD: overlay_vfsops.c,v 1.70 2020/03/21 16:30:39 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000 National Aeronautics & Space Administration
@@ -74,7 +74,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: overlay_vfsops.c,v 1.69 2020/03/16 21:20:11 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: overlay_vfsops.c,v 1.70 2020/03/21 16:30:39 pgoyette Exp $");
 
 #include 
 #include 
@@ -92,8 +92,6 @@ MODULE(MODULE_CLASS_VFS, overlay, "layer
 
 VFS_PROTOS(ov);
 
-static struct sysctllog *overlay_sysctl_log;
-
 #define	NOVERLAYNODECACHE	16
 
 /*
@@ -273,7 +271,7 @@ struct vfsops overlay_vfsops = {
 SYSCTL_SETUP(overlay_sysctl_setup, "overlay fs sysctl")
 {
 
-	sysctl_createv(&overlay_sysctl_log, 0, NULL, NULL,
+	sysctl_createv(clog, 0, NULL, NULL,
 		   CTLFLAG_PERMANENT, CTLTYPE_NODE, "overlay",
 		   SYSCTL_DESCR("Overlay file system"),
 		   NULL, 0, NULL, 0,



CVS commit: src/sys/miscfs/genfs

2020-03-14 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sat Mar 14 21:47:41 UTC 2020

Modified Files:
src/sys/miscfs/genfs: genfs_node.h

Log Message:
Update a comment.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/miscfs/genfs/genfs_node.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/miscfs/genfs/genfs_node.h
diff -u src/sys/miscfs/genfs/genfs_node.h:1.23 src/sys/miscfs/genfs/genfs_node.h:1.24
--- src/sys/miscfs/genfs/genfs_node.h:1.23	Wed Jan 15 17:55:44 2020
+++ src/sys/miscfs/genfs/genfs_node.h	Sat Mar 14 21:47:41 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: genfs_node.h,v 1.23 2020/01/15 17:55:44 ad Exp $ */
+/* $NetBSD: genfs_node.h,v 1.24 2020/03/14 21:47:41 ad Exp $ */
 
 /*
  * Copyright (c) 2001 Chuck Silvers.
@@ -61,7 +61,7 @@ struct genfs_ops {
 /*
  * GOP_MARKUPDATE: mark vnode's timestamps for update.
  *
- * => called with v_interlock (and possibly other locks) held.
+ * => called with vmobjlock (and possibly other locks) held.
  * => used for accesses via mmap.
  */
 



CVS commit: src/sys/miscfs/genfs

2020-03-14 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sat Mar 14 19:07:22 UTC 2020

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
Unused variable.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/miscfs/genfs/genfs_io.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/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.90 src/sys/miscfs/genfs/genfs_io.c:1.91
--- src/sys/miscfs/genfs/genfs_io.c:1.90	Sat Mar 14 18:08:39 2020
+++ src/sys/miscfs/genfs/genfs_io.c	Sat Mar 14 19:07:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.90 2020/03/14 18:08:39 ad Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.91 2020/03/14 19:07:22 ad Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.90 2020/03/14 18:08:39 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.91 2020/03/14 19:07:22 ad Exp $");
 
 #include 
 #include 
@@ -884,7 +884,6 @@ genfs_do_putpages(struct vnode *vp, off_
 	bool wasclean, needs_clean;
 	bool async = (origflags & PGO_SYNCIO) == 0;
 	bool pagedaemon = curlwp == uvm.pagedaemon_lwp;
-	struct lwp * const l = curlwp ? curlwp : &lwp0;
 	struct mount *trans_mp;
 	int flags;
 	bool modified;		/* if we write out any pages */



CVS commit: src/sys/miscfs/genfs

2020-03-14 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sat Mar 14 15:34:24 UTC 2020

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
OR into bp->b_cflags; don't overwrite.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sys/miscfs/genfs/genfs_io.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/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.88 src/sys/miscfs/genfs/genfs_io.c:1.89
--- src/sys/miscfs/genfs/genfs_io.c:1.88	Thu Feb 27 22:12:54 2020
+++ src/sys/miscfs/genfs/genfs_io.c	Sat Mar 14 15:34:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.88 2020/02/27 22:12:54 ad Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.89 2020/03/14 15:34:24 ad Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.88 2020/02/27 22:12:54 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.89 2020/03/14 15:34:24 ad Exp $");
 
 #include 
 #include 
@@ -615,7 +615,7 @@ genfs_getpages_read(struct vnode *vp, st
 	mbp->b_bufsize = totalbytes;
 	mbp->b_data = (void *)kva;
 	mbp->b_resid = mbp->b_bcount = bytes;
-	mbp->b_cflags = BC_BUSY;
+	mbp->b_cflags |= BC_BUSY;
 	if (async) {
 		mbp->b_flags = B_READ | B_ASYNC;
 		mbp->b_iodone = uvm_aio_aiodone;
@@ -1497,7 +1497,7 @@ genfs_do_io(struct vnode *vp, off_t off,
 	mbp->b_bufsize = len;
 	mbp->b_data = (void *)kva;
 	mbp->b_resid = mbp->b_bcount = bytes;
-	mbp->b_cflags = BC_BUSY | BC_AGE;
+	mbp->b_cflags |= BC_BUSY | BC_AGE;
 	if (async) {
 		mbp->b_flags = brw | B_ASYNC;
 		mbp->b_iodone = iodone;
@@ -1735,7 +1735,7 @@ genfs_compat_gop_write(struct vnode *vp,
 	mutex_exit(vp->v_interlock);
 
 	bp = getiobuf(vp, true);
-	bp->b_cflags = BC_BUSY | BC_AGE;
+	bp->b_cflags |= BC_BUSY | BC_AGE;
 	bp->b_lblkno = offset >> vp->v_mount->mnt_fs_bshift;
 	bp->b_data = (char *)kva;
 	bp->b_bcount = npages << PAGE_SHIFT;



CVS commit: src/sys/miscfs/genfs

2020-02-24 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Feb 24 20:49:51 UTC 2020

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
v_interlock -> vmobjlock


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/miscfs/genfs/genfs_io.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/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.86 src/sys/miscfs/genfs/genfs_io.c:1.87
--- src/sys/miscfs/genfs/genfs_io.c:1.86	Sun Feb 23 15:46:41 2020
+++ src/sys/miscfs/genfs/genfs_io.c	Mon Feb 24 20:49:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.86 2020/02/23 15:46:41 ad Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.87 2020/02/24 20:49:51 ad Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.86 2020/02/23 15:46:41 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.87 2020/02/24 20:49:51 ad Exp $");
 
 #include 
 #include 
@@ -1916,7 +1916,7 @@ genfs_do_directio(struct vmspace *vs, va
 
 	spoff = trunc_page(off);
 	epoff = round_page(off + len);
-	mutex_enter(vp->v_interlock);
+	rw_enter(vp->v_uobj.vmobjlock, RW_WRITER);
 	error = VOP_PUTPAGES(vp, spoff, epoff, pgoflags);
 	if (error) {
 		return error;



CVS commit: src/sys/miscfs/procfs

2020-02-24 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Feb 24 20:47:41 UTC 2020

Modified Files:
src/sys/miscfs/procfs: procfs_vnops.c

Log Message:
v_interlock -> vmobjlock


To generate a diff of this commit:
cvs rdiff -u -r1.209 -r1.210 src/sys/miscfs/procfs/procfs_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/procfs/procfs_vnops.c
diff -u src/sys/miscfs/procfs/procfs_vnops.c:1.209 src/sys/miscfs/procfs/procfs_vnops.c:1.210
--- src/sys/miscfs/procfs/procfs_vnops.c:1.209	Sun Feb 23 22:14:04 2020
+++ src/sys/miscfs/procfs/procfs_vnops.c	Mon Feb 24 20:47:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vnops.c,v 1.209 2020/02/23 22:14:04 ad Exp $	*/
+/*	$NetBSD: procfs_vnops.c,v 1.210 2020/02/24 20:47:41 ad Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -105,7 +105,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.209 2020/02/23 22:14:04 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.210 2020/02/24 20:47:41 ad Exp $");
 
 #include 
 #include 
@@ -1739,7 +1739,7 @@ procfs_getpages(void *v)
 	} */ *ap = v;
 
 	if ((ap->a_flags & PGO_LOCKED) == 0)
-		mutex_exit(ap->a_vp->v_interlock);
+		rw_exit(ap->a_vp->v_uobj.vmobjlock);
 
 	return (EFAULT);
 }



CVS commit: src/sys/miscfs/kernfs

2020-02-24 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Feb 24 20:44:25 UTC 2020

Modified Files:
src/sys/miscfs/kernfs: kernfs_vnops.c

Log Message:
v_interlock -> vmobjlock


To generate a diff of this commit:
cvs rdiff -u -r1.163 -r1.164 src/sys/miscfs/kernfs/kernfs_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/kernfs/kernfs_vnops.c
diff -u src/sys/miscfs/kernfs/kernfs_vnops.c:1.163 src/sys/miscfs/kernfs/kernfs_vnops.c:1.164
--- src/sys/miscfs/kernfs/kernfs_vnops.c:1.163	Tue Feb  4 04:19:24 2020
+++ src/sys/miscfs/kernfs/kernfs_vnops.c	Mon Feb 24 20:44:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernfs_vnops.c,v 1.163 2020/02/04 04:19:24 riastradh Exp $	*/
+/*	$NetBSD: kernfs_vnops.c,v 1.164 2020/02/24 20:44:25 ad Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.163 2020/02/04 04:19:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.164 2020/02/24 20:44:25 ad Exp $");
 
 #include 
 #include 
@@ -1229,7 +1229,7 @@ kernfs_getpages(void *v)
 	} */ *ap = v;
 
 	if ((ap->a_flags & PGO_LOCKED) == 0)
-		mutex_exit(ap->a_vp->v_interlock);
+		rw_exit(ap->a_vp->v_uobj.vmobjlock);
 
 	return (EFAULT);
 }



CVS commit: src/sys/miscfs/deadfs

2020-02-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 20 15:48:05 UTC 2020

Modified Files:
src/sys/miscfs/deadfs: dead_vnops.c

Log Message:
Use vn_bwrite, not genfs_nullop, for VOP_BWRITE.

VOP_BWRITE is responsible for calling biodone; can't just leave it
hanging.

XXX pullup


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/miscfs/deadfs/dead_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/deadfs/dead_vnops.c
diff -u src/sys/miscfs/deadfs/dead_vnops.c:1.61 src/sys/miscfs/deadfs/dead_vnops.c:1.62
--- src/sys/miscfs/deadfs/dead_vnops.c:1.61	Wed Apr 26 03:02:49 2017
+++ src/sys/miscfs/deadfs/dead_vnops.c	Thu Feb 20 15:48:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dead_vnops.c,v 1.61 2017/04/26 03:02:49 riastradh Exp $	*/
+/*	$NetBSD: dead_vnops.c,v 1.62 2020/02/20 15:48:05 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dead_vnops.c,v 1.61 2017/04/26 03:02:49 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dead_vnops.c,v 1.62 2020/02/20 15:48:05 riastradh Exp $");
 
 #include 
 #include 
@@ -48,7 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: dead_vnops.c
 /*
  * Prototypes for dead operations on vnodes.
  */
-#define dead_bwrite	genfs_nullop
+#define	dead_bwrite	vn_bwrite
 int	dead_lookup(void *);
 int	dead_open(void *);
 #define dead_close	genfs_nullop



CVS commit: src/sys/miscfs/kernfs

2020-02-03 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Feb  4 04:19:24 UTC 2020

Modified Files:
src/sys/miscfs/kernfs: kernfs.h kernfs_vfsops.c kernfs_vnops.c

Log Message:
Use specfs vnops for specnodes in kernfs.

While here, don't filter out rootdev and rrootdev merely because
they're not cached.

Fixes the elusive /kern/rootdev and /kern/rrootdev nodes, which only
appeared sometimes when they felt like it, and fixes operations on
/kern/rootdev and /kern/rrootdev always returning EOPNOTSUPP.

We didn't seem to have a single PR for these issues but the following
PRs are all relevant:

PR bin/13564
PR kern/38265
PR kern/38778
PR kern/45974

XXX pullup-9, pullup-8, pullup-7, pullup-6, pullup-5, pullup-4, pullup-3, 
pullup-2, pullup-1.4T...


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/miscfs/kernfs/kernfs.h
cvs rdiff -u -r1.97 -r1.98 src/sys/miscfs/kernfs/kernfs_vfsops.c
cvs rdiff -u -r1.162 -r1.163 src/sys/miscfs/kernfs/kernfs_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/kernfs/kernfs.h
diff -u src/sys/miscfs/kernfs/kernfs.h:1.42 src/sys/miscfs/kernfs/kernfs.h:1.43
--- src/sys/miscfs/kernfs/kernfs.h:1.42	Fri Jan 17 20:08:09 2020
+++ src/sys/miscfs/kernfs/kernfs.h	Tue Feb  4 04:19:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernfs.h,v 1.42 2020/01/17 20:08:09 ad Exp $	*/
+/*	$NetBSD: kernfs.h,v 1.43 2020/02/04 04:19:24 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -122,6 +122,7 @@ extern const struct kern_target kern_tar
 extern int nkern_targets;
 extern const int static_nkern_targets;
 extern int (**kernfs_vnodeop_p)(void *);
+extern int (**kernfs_specop_p)(void *);
 extern struct vfsops kernfs_vfsops;
 extern dev_t rrootdev;
 extern kmutex_t kfs_lock;

Index: src/sys/miscfs/kernfs/kernfs_vfsops.c
diff -u src/sys/miscfs/kernfs/kernfs_vfsops.c:1.97 src/sys/miscfs/kernfs/kernfs_vfsops.c:1.98
--- src/sys/miscfs/kernfs/kernfs_vfsops.c:1.97	Fri Jan 17 20:08:09 2020
+++ src/sys/miscfs/kernfs/kernfs_vfsops.c	Tue Feb  4 04:19:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernfs_vfsops.c,v 1.97 2020/01/17 20:08:09 ad Exp $	*/
+/*	$NetBSD: kernfs_vfsops.c,v 1.98 2020/02/04 04:19:24 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.97 2020/01/17 20:08:09 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.98 2020/02/04 04:19:24 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -283,6 +283,7 @@ again:
 		vp->v_vflag = VV_ROOT;
 
 	if (kt->kt_tag == KFSdevice) {
+		vp->v_op = kernfs_specop_p;
 		spec_node_init(vp, *(dev_t *)kt->kt_data);
 	}
 
@@ -293,9 +294,11 @@ again:
 }
 
 extern const struct vnodeopv_desc kernfs_vnodeop_opv_desc;
+extern const struct vnodeopv_desc kernfs_specop_opv_desc;
 
 const struct vnodeopv_desc * const kernfs_vnodeopv_descs[] = {
 	&kernfs_vnodeop_opv_desc,
+	&kernfs_specop_opv_desc,
 	NULL,
 };
 

Index: src/sys/miscfs/kernfs/kernfs_vnops.c
diff -u src/sys/miscfs/kernfs/kernfs_vnops.c:1.162 src/sys/miscfs/kernfs/kernfs_vnops.c:1.163
--- src/sys/miscfs/kernfs/kernfs_vnops.c:1.162	Thu Jan  2 15:42:27 2020
+++ src/sys/miscfs/kernfs/kernfs_vnops.c	Tue Feb  4 04:19:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernfs_vnops.c,v 1.162 2020/01/02 15:42:27 thorpej Exp $	*/
+/*	$NetBSD: kernfs_vnops.c,v 1.163 2020/02/04 04:19:24 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.162 2020/01/02 15:42:27 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.163 2020/02/04 04:19:24 riastradh Exp $");
 
 #include 
 #include 
@@ -227,6 +227,54 @@ const struct vnodeopv_entry_desc kernfs_
 const struct vnodeopv_desc kernfs_vnodeop_opv_desc =
 	{ &kernfs_vnodeop_p, kernfs_vnodeop_entries };
 
+int (**kernfs_specop_p)(void *);
+const struct vnodeopv_entry_desc kernfs_specop_entries[] = {
+	{ &vop_default_desc, vn_default_error },
+	{ &vop_lookup_desc, spec_lookup },		/* lookup */
+	{ &vop_create_desc, spec_create },		/* create */
+	{ &vop_mknod_desc, spec_mknod },		/* mknod */
+	{ &vop_open_desc, spec_open },			/* open */
+	{ &vop_close_desc, spec_close },		/* close */
+	{ &vop_access_desc, kernfs_access },		/* access */
+	{ &vop_getattr_desc, kernfs_getattr },		/* getattr */
+	{ &vop_setattr_desc, kernfs_setattr },		/* setattr */
+	{ &vop_read_desc, spec_read },			/* read */
+	{ &vop_write_desc, spec_write },		/* write */
+	{ &vop_fallocate_desc, spec_fallocate },	/* fallocate */
+	{ &vop_fdiscard_desc, spec_fdiscard },		/* fdiscard */
+	{ &vop_fcntl_desc, spec_fcntl },		/* fcntl */
+	{ &vop_ioctl_desc, spec_ioctl },		/* ioctl */
+	{ &vop_poll_desc, spec_poll },			/* poll */
+	{ &vop_revoke_desc, spec_revoke },		/* revoke */
+	{ &vop_fsync_desc, spec_fsync },		/* fsync */
+	{ &vop_seek_desc, spec_seek },			/* seek */
+	{ &vop_remove_desc,

CVS commit: src/sys/miscfs/genfs

2019-12-16 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Dec 16 18:17:32 UTC 2019

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
genfs_do_putpages(): add a missing call to uvm_page_array_advance().

Spotted by the automated test runs and:

Reported-by: syzbot+adc1f0ce21bcece53...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/miscfs/genfs/genfs_io.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/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.80 src/sys/miscfs/genfs/genfs_io.c:1.81
--- src/sys/miscfs/genfs/genfs_io.c:1.80	Mon Dec 16 08:50:42 2019
+++ src/sys/miscfs/genfs/genfs_io.c	Mon Dec 16 18:17:32 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.80 2019/12/16 08:50:42 ad Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.81 2019/12/16 18:17:32 ad Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.80 2019/12/16 08:50:42 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.81 2019/12/16 18:17:32 ad Exp $");
 
 #include 
 #include 
@@ -978,6 +978,7 @@ retry:
 		if (pg->flags & (PG_RELEASED|PG_PAGEOUT)) {
 			wasclean = false;
 			nextoff = pg->offset + PAGE_SIZE;
+			uvm_page_array_advance(&a);
 			continue;
 		}
 



CVS commit: src/sys/miscfs/genfs

2019-12-16 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Dec 16 08:50:43 UTC 2019

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
Correction to previous for DEBUG case.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/miscfs/genfs/genfs_io.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/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.79 src/sys/miscfs/genfs/genfs_io.c:1.80
--- src/sys/miscfs/genfs/genfs_io.c:1.79	Sun Dec 15 21:43:42 2019
+++ src/sys/miscfs/genfs/genfs_io.c	Mon Dec 16 08:50:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.79 2019/12/15 21:43:42 ad Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.80 2019/12/16 08:50:42 ad Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.79 2019/12/15 21:43:42 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.80 2019/12/16 08:50:42 ad Exp $");
 
 #include 
 #include 
@@ -1239,6 +1239,7 @@ retry:
 			if (pg == NULL) {
 break;
 			}
+			uvm_page_array_advance(&a);
 			if ((pg->flags & (PG_FAKE | PG_MARKER)) != 0) {
 continue;
 			}



CVS commit: src/sys/miscfs/genfs

2019-12-15 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sun Dec 15 21:43:42 UTC 2019

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
Fix DEBUG build.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/miscfs/genfs/genfs_io.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/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.78 src/sys/miscfs/genfs/genfs_io.c:1.79
--- src/sys/miscfs/genfs/genfs_io.c:1.78	Sun Dec 15 21:11:34 2019
+++ src/sys/miscfs/genfs/genfs_io.c	Sun Dec 15 21:43:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.78 2019/12/15 21:11:34 ad Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.79 2019/12/15 21:43:42 ad Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.78 2019/12/15 21:11:34 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.79 2019/12/15 21:43:42 ad Exp $");
 
 #include 
 #include 
@@ -1232,7 +1232,13 @@ retry:
 	if (cleanall && wasclean && gp->g_dirtygen == dirtygen &&
 	(vp->v_iflag & VI_ONWORKLST) != 0) {
 #if defined(DEBUG)
-		TAILQ_FOREACH(pg, &uobj->memq, listq.queue) {
+		uvm_page_array_init(&a);
+		for (nextoff = 0;; nextoff = pg->offset + PAGE_SIZE) {
+			pg = uvm_page_array_fill_and_peek(&a, uobj, nextoff,
+			0, 0);
+			if (pg == NULL) {
+break;
+			}
 			if ((pg->flags & (PG_FAKE | PG_MARKER)) != 0) {
 continue;
 			}
@@ -1243,6 +1249,7 @@ retry:
 printf("%s: %p: modified\n", __func__, pg);
 			}
 		}
+		uvm_page_array_fini(&a);
 #endif /* defined(DEBUG) */
 		vp->v_iflag &= ~VI_WRMAPDIRTY;
 		if (LIST_FIRST(&vp->v_dirtyblkhd) == NULL)



CVS commit: src/sys/miscfs/nullfs

2019-12-15 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun Dec 15 20:30:56 UTC 2019

Modified Files:
src/sys/miscfs/nullfs: null_vfsops.c

Log Message:
Set IMNT_MPSAFE before creating the vnode for the root of the
filesystem. Otherwise, it won't be created with VV_MPSAFE and require
the kernel_lock.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sys/miscfs/nullfs/null_vfsops.c

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

Modified files:

Index: src/sys/miscfs/nullfs/null_vfsops.c
diff -u src/sys/miscfs/nullfs/null_vfsops.c:1.95 src/sys/miscfs/nullfs/null_vfsops.c:1.96
--- src/sys/miscfs/nullfs/null_vfsops.c:1.95	Wed Feb 20 10:06:00 2019
+++ src/sys/miscfs/nullfs/null_vfsops.c	Sun Dec 15 20:30:56 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: null_vfsops.c,v 1.95 2019/02/20 10:06:00 hannken Exp $	*/
+/*	$NetBSD: null_vfsops.c,v 1.96 2019/12/15 20:30:56 joerg Exp $	*/
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: null_vfsops.c,v 1.95 2019/02/20 10:06:00 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: null_vfsops.c,v 1.96 2019/12/15 20:30:56 joerg Exp $");
 
 #include 
 #include 
@@ -140,6 +140,7 @@ nullfs_mount(struct mount *mp, const cha
 	/* Create the mount point. */
 	nmp = kmem_zalloc(sizeof(struct null_mount), KM_SLEEP);
 	mp->mnt_data = nmp;
+	mp->mnt_iflag |= IMNT_MPSAFE;
 
 	/*
 	 * Make sure that the mount point is sufficiently initialized
@@ -168,7 +169,6 @@ nullfs_mount(struct mount *mp, const cha
 	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 	vp->v_vflag |= VV_ROOT;
 	nmp->nullm_rootvp = vp;
-	mp->mnt_iflag |= IMNT_MPSAFE;
 	VOP_UNLOCK(vp);
 
 	error = set_statvfs_info(path, UIO_USERSPACE, args->la.target,



CVS commit: src/sys/miscfs/procfs

2019-04-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Apr 25 22:48:42 UTC 2019

Modified Files:
src/sys/miscfs/procfs: procfs.h

Log Message:
Restore mapping of file id to pid/type/fd.
Use 64bit file id to allow for 32bit fd and 25-26bit pid.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/miscfs/procfs/procfs.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/miscfs/procfs/procfs.h
diff -u src/sys/miscfs/procfs/procfs.h:1.75 src/sys/miscfs/procfs/procfs.h:1.76
--- src/sys/miscfs/procfs/procfs.h:1.75	Sat Mar 30 23:28:30 2019
+++ src/sys/miscfs/procfs/procfs.h	Thu Apr 25 22:48:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs.h,v 1.75 2019/03/30 23:28:30 christos Exp $	*/
+/*	$NetBSD: procfs.h,v 1.76 2019/04/25 22:48:42 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -115,6 +115,7 @@ typedef enum {
 #ifdef __HAVE_PROCFS_MACHDEP
 	PROCFS_MACHDEP_NODE_TYPES
 #endif
+	PFSlast,	/* track number of types */
 } pfstype;
 
 /*
@@ -133,7 +134,7 @@ struct pfsnode {
 #define pfs_fd pfs_key.pk_fd
 	mode_t		pfs_mode;	/* mode bits for stat() */
 	u_long		pfs_flags;	/* open flags */
-	u_long		pfs_fileno;	/* unique file id */
+	uint64_t	pfs_fileno;	/* unique file id */
 };
 
 #define PROCFS_NOTELEN	64	/* max length of a note (/proc/$pid/note) */
@@ -164,10 +165,12 @@ struct procfs_args {
 #define UIO_MX 32
 
 #define PROCFS_FILENO(pid, type, fd) \
-(((type) < PFSproc) ? ((type) + 2) : \
-	(((fd) == -1) ? pid)+1) << 5) + ((int) (type))) : \
-	pid)+1) << 16) | ((fd) << 5) | ((int) (type)
-#define PROCFS_TYPE(type)	((type) & 0x1f)
+	(  (type) == PFSroot ? 2 \
+	 : (type) == PFScurproc ? 3 \
+	 : (type) == PFSself ? 4 \
+ : (fd) == -1 ? ((pid)+1) * PFSlast + (type) \
+ : ((uint64_t)((pid)+1) << 32 | (fd)) * PFSlast + (type))
+#define PROCFS_TYPE(type)	((type) % PFSlast)
 
 struct procfsmount {
 	void *pmnt_exechook;



CVS commit: src/sys/miscfs/procfs

2019-03-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar 30 23:28:30 UTC 2019

Modified Files:
src/sys/miscfs/procfs: files.procfs procfs.h procfs_subr.c
procfs_vfsops.c procfs_vnops.c
Added Files:
src/sys/miscfs/procfs: procfs_limit.c

Log Message:
add a node for the process resource limits.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/miscfs/procfs/files.procfs
cvs rdiff -u -r1.74 -r1.75 src/sys/miscfs/procfs/procfs.h
cvs rdiff -u -r0 -r1.1 src/sys/miscfs/procfs/procfs_limit.c
cvs rdiff -u -r1.112 -r1.113 src/sys/miscfs/procfs/procfs_subr.c
cvs rdiff -u -r1.100 -r1.101 src/sys/miscfs/procfs/procfs_vfsops.c
cvs rdiff -u -r1.205 -r1.206 src/sys/miscfs/procfs/procfs_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/procfs/files.procfs
diff -u src/sys/miscfs/procfs/files.procfs:1.12 src/sys/miscfs/procfs/files.procfs:1.13
--- src/sys/miscfs/procfs/files.procfs:1.12	Sun Aug 27 20:46:07 2017
+++ src/sys/miscfs/procfs/files.procfs	Sat Mar 30 19:28:30 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.procfs,v 1.12 2017/08/28 00:46:07 kamil Exp $
+#	$NetBSD: files.procfs,v 1.13 2019/03/30 23:28:30 christos Exp $
 
 deffs	PROCFS:	PTRACE_HOOKS
 
@@ -7,6 +7,7 @@ file	miscfs/procfs/procfs_auxv.c	procfs
 file	miscfs/procfs/procfs_cmdline.c	procfs
 file	miscfs/procfs/procfs_fd.c	procfs
 file	miscfs/procfs/procfs_fpregs.c	procfs
+file	miscfs/procfs/procfs_limit.c	procfs
 file	miscfs/procfs/procfs_linux.c	procfs
 file	miscfs/procfs/procfs_map.c	procfs
 file	miscfs/procfs/procfs_mem.c	procfs

Index: src/sys/miscfs/procfs/procfs.h
diff -u src/sys/miscfs/procfs/procfs.h:1.74 src/sys/miscfs/procfs/procfs.h:1.75
--- src/sys/miscfs/procfs/procfs.h:1.74	Sat Dec 30 22:29:18 2017
+++ src/sys/miscfs/procfs/procfs.h	Sat Mar 30 19:28:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs.h,v 1.74 2017/12/31 03:29:18 christos Exp $	*/
+/*	$NetBSD: procfs.h,v 1.75 2019/03/30 23:28:30 christos Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -79,38 +79,39 @@
  * The different types of node in a procfs filesystem
  */
 typedef enum {
-	PFSroot,	/* the filesystem root */
+	PFSauxv,	/* ELF Auxiliary Vector */
+	PFSchroot,	/* the process's current root directory */
+	PFScmdline,	/* process command line args */
+	PFScpuinfo,	/* CPU info (if -o linux) */
+	PFScpustat,	/* status info (if -o linux) */
 	PFScurproc,	/* symbolic link for curproc */
-	PFSself,	/* like curproc, but this is the Linux name */
-	PFSproc,	/* a process-specific sub-directory */
-	PFSfile,	/* the executable file */
+	PFScwd,		/* the process's current working directory */
+	PFSdevices,	/* major/device name mappings (if -o linux) */
+	PFSemul,	/* the process's emulation */
+	PFSenviron,	/* process environment */
 	PFSexe,		/* symlink to the executable file */
-	PFSmem,		/* the process's memory image */
-	PFSregs,	/* the process's register set */
+	PFSfd,		/* a directory containing the processes open fd's */
+	PFSfile,	/* the executable file */
 	PFSfpregs,	/* the process's FP register set */
-	PFSstat,	/* process status (if -o linux) */
-	PFSstatus,	/* process status */
-	PFSnote,	/* process notifier */
-	PFSnotepg,	/* process group notifier */
+	PFSloadavg,	/* load average (if -o linux) */
+	PFSlimit,	/* resource limits */
 	PFSmap,		/* memory map */
-	PFScmdline,	/* process command line args */
-	PFSenviron,	/* process environment */
-	PFSmeminfo,	/* system memory info (if -o linux) */
-	PFScpuinfo,	/* CPU info (if -o linux) */
 	PFSmaps,	/* memory map, Linux style (if -o linux) */
-	PFSfd,		/* a directory containing the processes open fd's */
-	PFSuptime,	/* elapsed time since (if -o linux) */
+	PFSmem,		/* the process's memory image */
+	PFSmeminfo,	/* system memory info (if -o linux) */
 	PFSmounts,	/* mounted filesystems (if -o linux) */
-	PFScwd,		/* the process's current working directory */
-	PFSchroot,	/* the process's current root directory */
-	PFSemul,	/* the process's emulation */
-	PFSdevices,	/* major/device name mappings (if -o linux) */
-	PFScpustat,	/* status info (if -o linux) */
-	PFSloadavg,	/* load average (if -o linux) */
+	PFSnote,	/* process notifier */
+	PFSnotepg,	/* process group notifier */
+	PFSproc,	/* a process-specific sub-directory */
+	PFSregs,	/* the process's register set */
+	PFSroot,	/* the filesystem root */
+	PFSself,	/* like curproc, but this is the Linux name */
+	PFSstat,	/* process status (if -o linux) */
 	PFSstatm,	/* process memory info (if -o linux) */
-	PFSversion,	/* kernel version (if -o linux) */
+	PFSstatus,	/* process status */
 	PFStask,	/* task subdirector (if -o linux) */
-	PFSauxv,	/* ELF Auxiliary Vector */
+	PFSuptime,	/* elapsed time since (if -o linux) */
+	PFSversion,	/* kernel version (if -o linux) */
 #ifdef __HAVE_PROCFS_MACHDEP
 	PROCFS_MACHDEP_NODE_TYPES
 #endif
@@ -234,6 +235,8 @@ int procfs_doversion(struct lwp *, struc
 struct uio *);
 int procfs_doaux

CVS commit: src/sys/miscfs/genfs

2018-12-10 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Dec 10 21:10:52 UTC 2018

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
assert that WAPBL journal write lock is actually held when called with
PGO_JOURNALLOCKED or IO_JOURNALLOCKED

suggested by mrg@, thanks


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/miscfs/genfs/genfs_io.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/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.73 src/sys/miscfs/genfs/genfs_io.c:1.74
--- src/sys/miscfs/genfs/genfs_io.c:1.73	Sun Dec  9 20:32:37 2018
+++ src/sys/miscfs/genfs/genfs_io.c	Mon Dec 10 21:10:52 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.73 2018/12/09 20:32:37 jdolecek Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.74 2018/12/10 21:10:52 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.73 2018/12/09 20:32:37 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.74 2018/12/10 21:10:52 jdolecek Exp $");
 
 #include 
 #include 
@@ -141,6 +141,11 @@ genfs_getpages(void *v)
 	KASSERT(vp->v_type == VREG || vp->v_type == VDIR ||
 	vp->v_type == VLNK || vp->v_type == VBLK);
 
+#ifdef DIAGNOSTIC
+	if ((flags & PGO_JOURNALLOCKED) && vp->v_mount->mnt_wapbl)
+WAPBL_JLOCK_ASSERT(vp->v_mount);
+#endif
+
 	error = vdead_check(vp, VDEAD_NOWAIT);
 	if (error) {
 		if ((flags & PGO_LOCKED) == 0)
@@ -869,6 +874,11 @@ genfs_do_putpages(struct vnode *vp, off_
 	UVMHIST_LOG(ubchist, "vp %#jx pages %jd off 0x%jx len 0x%jx",
 	(uintptr_t)vp, uobj->uo_npages, startoff, endoff - startoff);
 
+#ifdef DIAGNOSTIC
+	if ((origflags & PGO_JOURNALLOCKED) && vp->v_mount->mnt_wapbl)
+WAPBL_JLOCK_ASSERT(vp->v_mount);
+#endif
+
 	trans_mp = NULL;
 	holds_wapbl = false;
 
@@ -1714,6 +1724,11 @@ genfs_directio(struct vnode *vp, struct 
 	bool need_wapbl = (vp->v_mount && vp->v_mount->mnt_wapbl &&
 	(ioflag & IO_JOURNALLOCKED) == 0);
 
+#ifdef DIAGNOSTIC
+	if ((ioflag & IO_JOURNALLOCKED) && vp->v_mount->mnt_wapbl)
+WAPBL_JLOCK_ASSERT(vp->v_mount);
+#endif
+
 	/*
 	 * We only support direct I/O to user space for now.
 	 */



CVS commit: src/sys/miscfs/genfs

2018-12-09 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Dec  9 20:32:37 UTC 2018

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
support flag PGO_JOURNALLOCKED also for genfs_getpages()


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/miscfs/genfs/genfs_io.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/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.72 src/sys/miscfs/genfs/genfs_io.c:1.73
--- src/sys/miscfs/genfs/genfs_io.c:1.72	Mon May 28 21:04:38 2018
+++ src/sys/miscfs/genfs/genfs_io.c	Sun Dec  9 20:32:37 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.72 2018/05/28 21:04:38 chs Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.73 2018/12/09 20:32:37 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.72 2018/05/28 21:04:38 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.73 2018/12/09 20:32:37 jdolecek Exp $");
 
 #include 
 #include 
@@ -128,6 +128,8 @@ genfs_getpages(void *v)
 	const bool memwrite = (ap->a_access_type & VM_PROT_WRITE) != 0;
 	const bool overwrite = (flags & PGO_OVERWRITE) != 0;
 	const bool blockalloc = memwrite && (flags & PGO_NOBLOCKALLOC) == 0;
+	const bool need_wapbl = (vp->v_mount->mnt_wapbl &&
+			(flags & PGO_JOURNALLOCKED) == 0);
 	const bool glocked = (flags & PGO_GLOCKHELD) != 0;
 	bool holds_wapbl = false;
 	struct mount *trans_mount = NULL;
@@ -313,7 +315,7 @@ startover:
 		 * XXX: This assumes that we come here only via
 		 * the mmio path
 		 */
-		if (blockalloc && vp->v_mount->mnt_wapbl) {
+		if (blockalloc && need_wapbl) {
 			error = WAPBL_BEGIN(trans_mount);
 			if (error)
 goto out_err_free;



CVS commit: src/sys/miscfs/procfs

2018-04-16 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Apr 16 20:27:38 UTC 2018

Modified Files:
src/sys/miscfs/procfs: procfs_subr.c

Log Message:
Change procfs_revoke_vnodes() to use vrecycle()/vgone() instead
of VOP_REVOKE().

Gets rid of a bunch of suspensions on /proc as vrecycle() will
succeed most time and we suspend at most once per call.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sys/miscfs/procfs/procfs_subr.c

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

Modified files:

Index: src/sys/miscfs/procfs/procfs_subr.c
diff -u src/sys/miscfs/procfs/procfs_subr.c:1.111 src/sys/miscfs/procfs/procfs_subr.c:1.112
--- src/sys/miscfs/procfs/procfs_subr.c:1.111	Sun Dec 31 03:29:18 2017
+++ src/sys/miscfs/procfs/procfs_subr.c	Mon Apr 16 20:27:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_subr.c,v 1.111 2017/12/31 03:29:18 christos Exp $	*/
+/*	$NetBSD: procfs_subr.c,v 1.112 2018/04/16 20:27:38 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -102,13 +102,14 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.111 2017/12/31 03:29:18 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.112 2018/04/16 20:27:38 hannken Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -368,6 +369,8 @@ procfs_revoke_selector(void *arg, struct
 void
 procfs_revoke_vnodes(struct proc *p, void *arg)
 {
+	int error;
+	bool suspended;
 	struct vnode *vp;
 	struct vnode_iterator *marker;
 	struct mount *mp = (struct mount *)arg;
@@ -375,14 +378,29 @@ procfs_revoke_vnodes(struct proc *p, voi
 	if (!(p->p_flag & PK_SUGID))
 		return;
 
+	suspended = false;
 	vfs_vnode_iterator_init(mp, &marker);
 
 	while ((vp = vfs_vnode_iterator_next(marker,
 	procfs_revoke_selector, p)) != NULL) {
-		VOP_REVOKE(vp, REVOKEALL);
-		vrele(vp);
+		if (vrecycle(vp))
+			continue;
+		/* Vnode is busy, we have to suspend the mount for vgone(). */
+		while (! suspended) {
+			error = vfs_suspend(mp, 0);
+			if (error == 0) {
+suspended = true;
+			} else if (error != EINTR && error != ERESTART) {
+KASSERT(error == EOPNOTSUPP);
+break;
+			}
+		}
+		vgone(vp);
 	}
 
+	if (suspended)
+		vfs_resume(mp);
+
 	vfs_vnode_iterator_destroy(marker);
 }
 



CVS commit: src/sys/miscfs/procfs

2018-04-07 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Apr  7 13:42:42 UTC 2018

Modified Files:
src/sys/miscfs/procfs: procfs_vnops.c

Log Message:
Lock the target cwdi and take an additional reference to the
vnode we are interested in to prevent it from disappearing
before getcwd_common().

Should fix PR kern/53096 (netbsd-8 crash on heavy disk I/O)


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/sys/miscfs/procfs/procfs_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/procfs/procfs_vnops.c
diff -u src/sys/miscfs/procfs/procfs_vnops.c:1.202 src/sys/miscfs/procfs/procfs_vnops.c:1.203
--- src/sys/miscfs/procfs/procfs_vnops.c:1.202	Sun Dec 31 03:02:23 2017
+++ src/sys/miscfs/procfs/procfs_vnops.c	Sat Apr  7 13:42:42 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vnops.c,v 1.202 2017/12/31 03:02:23 christos Exp $	*/
+/*	$NetBSD: procfs_vnops.c,v 1.203 2018/04/07 13:42:42 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -105,7 +105,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.202 2017/12/31 03:02:23 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.203 2018/04/07 13:42:42 hannken Exp $");
 
 #include 
 #include 
@@ -545,11 +545,10 @@ procfs_symlink(void *v)
 }
 
 /*
- * Works out the path to (and vnode of) the target process's current
+ * Works out the path to the target process's current
  * working directory or chroot.  If the caller is in a chroot and
  * can't "reach" the target's cwd or root (or some other error
- * occurs), a "/" is returned for the path and a NULL pointer is
- * returned for the vnode.
+ * occurs), a "/" is returned for the path.
  */
 static void
 procfs_dir(pfstype t, struct lwp *caller, struct proc *target, char **bpp,
@@ -559,12 +558,12 @@ procfs_dir(pfstype t, struct lwp *caller
 	struct vnode *vp, *rvp;
 	char *bp;
 
-	cwdi = caller->l_proc->p_cwdi;
-	rw_enter(&cwdi->cwdi_lock, RW_READER);
-
-	rvp = cwdi->cwdi_rdir;
-	bp = bpp ? *bpp : NULL;
-
+	/*
+	 * Lock target cwdi and take a reference to the vnode
+	 * we are interested in to prevent it from disappearing
+	 * before getcwd_common() below.
+	 */
+	rw_enter(&target->p_cwdi->cwdi_lock, RW_READER);
 	switch (t) {
 	case PFScwd:
 		vp = target->p_cwdi->cwdi_cdir;
@@ -573,9 +572,18 @@ procfs_dir(pfstype t, struct lwp *caller
 		vp = target->p_cwdi->cwdi_rdir;
 		break;
 	default:
-		rw_exit(&cwdi->cwdi_lock);
+		rw_exit(&target->p_cwdi->cwdi_lock);
 		return;
 	}
+	if (vp != NULL)
+		vref(vp);
+	rw_exit(&target->p_cwdi->cwdi_lock);
+
+	cwdi = caller->l_proc->p_cwdi;
+	rw_enter(&cwdi->cwdi_lock, RW_READER);
+
+	rvp = cwdi->cwdi_rdir;
+	bp = bpp ? *bpp : NULL;
 
 	/*
 	 * XXX: this horrible kludge avoids locking panics when
@@ -586,6 +594,7 @@ procfs_dir(pfstype t, struct lwp *caller
 			*--bp = '/';
 			*bpp = bp;
 		}
+		vrele(vp);
 		rw_exit(&cwdi->cwdi_lock);
 		return;
 	}
@@ -594,7 +603,6 @@ procfs_dir(pfstype t, struct lwp *caller
 		rvp = rootvnode;
 	if (vp == NULL || getcwd_common(vp, rvp, bp ? &bp : NULL, path,
 	len / 2, 0, caller) != 0) {
-		vp = NULL;
 		if (bpp) {
 			bp = *bpp;
 			*--bp = '/';
@@ -604,6 +612,8 @@ procfs_dir(pfstype t, struct lwp *caller
 	if (bpp)
 		*bpp = bp;
 
+	if (vp != NULL)
+		vrele(vp);
 	rw_exit(&cwdi->cwdi_lock);
 }
 



CVS commit: src/sys/miscfs/procfs

2017-12-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec 31 03:29:18 UTC 2017

Modified Files:
src/sys/miscfs/procfs: procfs.h procfs_cmdline.c procfs_subr.c
procfs_vfsops.c

Log Message:
rename some "cmdline" stuff now that it is used to print environment too


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/miscfs/procfs/procfs.h
cvs rdiff -u -r1.29 -r1.30 src/sys/miscfs/procfs/procfs_cmdline.c
cvs rdiff -u -r1.110 -r1.111 src/sys/miscfs/procfs/procfs_subr.c
cvs rdiff -u -r1.99 -r1.100 src/sys/miscfs/procfs/procfs_vfsops.c

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

Modified files:

Index: src/sys/miscfs/procfs/procfs.h
diff -u src/sys/miscfs/procfs/procfs.h:1.73 src/sys/miscfs/procfs/procfs.h:1.74
--- src/sys/miscfs/procfs/procfs.h:1.73	Sat Dec 30 22:02:23 2017
+++ src/sys/miscfs/procfs/procfs.h	Sat Dec 30 22:29:18 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs.h,v 1.73 2017/12/31 03:02:23 christos Exp $	*/
+/*	$NetBSD: procfs.h,v 1.74 2017/12/31 03:29:18 christos Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -208,7 +208,7 @@ int procfs_dostatus(struct lwp *, struct
 struct uio *);
 int procfs_domap(struct lwp *, struct proc *, struct pfsnode *,
 struct uio *, int);
-int procfs_docmdline(struct lwp *, struct proc *, struct pfsnode *,
+int procfs_doprocargs(struct lwp *, struct proc *, struct pfsnode *,
 struct uio *, int);
 int procfs_domeminfo(struct lwp *, struct proc *, struct pfsnode *,
 struct uio *);

Index: src/sys/miscfs/procfs/procfs_cmdline.c
diff -u src/sys/miscfs/procfs/procfs_cmdline.c:1.29 src/sys/miscfs/procfs/procfs_cmdline.c:1.30
--- src/sys/miscfs/procfs/procfs_cmdline.c:1.29	Sat Dec 30 22:02:23 2017
+++ src/sys/miscfs/procfs/procfs_cmdline.c	Sat Dec 30 22:29:18 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_cmdline.c,v 1.29 2017/12/31 03:02:23 christos Exp $	*/
+/*	$NetBSD: procfs_cmdline.c,v 1.30 2017/12/31 03:29:18 christos Exp $	*/
 
 /*
  * Copyright (c) 1999 Jaromir Dolecek 
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_cmdline.c,v 1.29 2017/12/31 03:02:23 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_cmdline.c,v 1.30 2017/12/31 03:29:18 christos Exp $");
 
 #include 
 #include 
@@ -46,7 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_cmdli
 #include 
 
 static int
-procfs_docmdline_helper(void *cookie, const void *src, size_t off, size_t len)
+procfs_doprocargs_helper(void *cookie, const void *src, size_t off, size_t len)
 {
 	struct uio *uio = cookie;
 	char *buf = __UNCONST(src);
@@ -58,10 +58,10 @@ procfs_docmdline_helper(void *cookie, co
 }
 
 /*
- * code for returning process's command line arguments
+ * code for returning process's command line arguments/environment
  */
 int
-procfs_docmdline(
+procfs_doprocargs(
 struct lwp *curl,
 struct proc *p,
 struct pfsnode *pfs,
@@ -74,7 +74,7 @@ procfs_docmdline(
 
 	/* Don't allow writing. */
 	if (uio->uio_rw != UIO_READ)
-		return (EOPNOTSUPP);
+		return EOPNOTSUPP;
 
 	/*
 	 * Zombies don't have a stack, so we can't read their psstrings.
@@ -87,25 +87,22 @@ procfs_docmdline(
 		if (0 == uio->uio_offset) {
 			error = uiomove(msg, 1, uio);
 			if (error)
-return (error);
+return error;
 		}
 		len = strlen(p->p_comm);
 		if (len >= uio->uio_offset) {
 			start = uio->uio_offset - 1;
 			error = uiomove(p->p_comm + start, len - start, uio);
 			if (error)
-return (error);
+return error;
 		}
 		if (len + 2 >= uio->uio_offset) {
 			start = uio->uio_offset - 1 - len;
 			error = uiomove(msg + 1 + start, 2 - start, uio);
 		}
-		return (error);
+		return error;
 	}
 
 	len = uio->uio_offset + uio->uio_resid;
-
-	error = copy_procargs(p, oid, &len,
-	procfs_docmdline_helper, uio);
-	return error;
+	return copy_procargs(p, oid, &len, procfs_doprocargs_helper, uio);
 }

Index: src/sys/miscfs/procfs/procfs_subr.c
diff -u src/sys/miscfs/procfs/procfs_subr.c:1.110 src/sys/miscfs/procfs/procfs_subr.c:1.111
--- src/sys/miscfs/procfs/procfs_subr.c:1.110	Sat Dec 30 22:02:23 2017
+++ src/sys/miscfs/procfs/procfs_subr.c	Sat Dec 30 22:29:18 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_subr.c,v 1.110 2017/12/31 03:02:23 christos Exp $	*/
+/*	$NetBSD: procfs_subr.c,v 1.111 2017/12/31 03:29:18 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -102,7 +102,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.110 2017/12/31 03:02:23 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.111 2017/12/31 03:29:18 christos Exp $");
 
 #include 
 #include 
@@ -222,11 +222,11 @@ procfs_rw(void *v)
 		break;
 
 	case PFScmdline:
-		error = procfs_docmdline(curl, p, pfs, uio, KERN_PROC_ARGV);
+		error = procfs_doprocargs(curl, p, pfs, uio, KERN_PROC_ARGV);
 		break;
 
 	case PFSenviron:
-		error = procfs_docmdline(curl, p, pfs, uio, KERN_PROC_ENV);
+		error = procfs_doprocargs(curl, p, pfs, uio, KERN_PROC_ENV);
 

CVS commit: src/sys/miscfs/procfs

2017-12-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec 31 03:02:23 UTC 2017

Modified Files:
src/sys/miscfs/procfs: procfs.h procfs_cmdline.c procfs_subr.c
procfs_vfsops.c procfs_vnops.c

Log Message:
Add an environ node


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/miscfs/procfs/procfs.h
cvs rdiff -u -r1.28 -r1.29 src/sys/miscfs/procfs/procfs_cmdline.c
cvs rdiff -u -r1.109 -r1.110 src/sys/miscfs/procfs/procfs_subr.c
cvs rdiff -u -r1.98 -r1.99 src/sys/miscfs/procfs/procfs_vfsops.c
cvs rdiff -u -r1.201 -r1.202 src/sys/miscfs/procfs/procfs_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/procfs/procfs.h
diff -u src/sys/miscfs/procfs/procfs.h:1.72 src/sys/miscfs/procfs/procfs.h:1.73
--- src/sys/miscfs/procfs/procfs.h:1.72	Sun Aug 27 20:46:07 2017
+++ src/sys/miscfs/procfs/procfs.h	Sat Dec 30 22:02:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs.h,v 1.72 2017/08/28 00:46:07 kamil Exp $	*/
+/*	$NetBSD: procfs.h,v 1.73 2017/12/31 03:02:23 christos Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -94,6 +94,7 @@ typedef enum {
 	PFSnotepg,	/* process group notifier */
 	PFSmap,		/* memory map */
 	PFScmdline,	/* process command line args */
+	PFSenviron,	/* process environment */
 	PFSmeminfo,	/* system memory info (if -o linux) */
 	PFScpuinfo,	/* CPU info (if -o linux) */
 	PFSmaps,	/* memory map, Linux style (if -o linux) */
@@ -208,7 +209,7 @@ int procfs_dostatus(struct lwp *, struct
 int procfs_domap(struct lwp *, struct proc *, struct pfsnode *,
 struct uio *, int);
 int procfs_docmdline(struct lwp *, struct proc *, struct pfsnode *,
-struct uio *);
+struct uio *, int);
 int procfs_domeminfo(struct lwp *, struct proc *, struct pfsnode *,
 struct uio *);
 int procfs_dodevices(struct lwp *, struct proc *, struct pfsnode *,

Index: src/sys/miscfs/procfs/procfs_cmdline.c
diff -u src/sys/miscfs/procfs/procfs_cmdline.c:1.28 src/sys/miscfs/procfs/procfs_cmdline.c:1.29
--- src/sys/miscfs/procfs/procfs_cmdline.c:1.28	Fri Mar  4 17:25:32 2011
+++ src/sys/miscfs/procfs/procfs_cmdline.c	Sat Dec 30 22:02:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_cmdline.c,v 1.28 2011/03/04 22:25:32 joerg Exp $	*/
+/*	$NetBSD: procfs_cmdline.c,v 1.29 2017/12/31 03:02:23 christos Exp $	*/
 
 /*
  * Copyright (c) 1999 Jaromir Dolecek 
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_cmdline.c,v 1.28 2011/03/04 22:25:32 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_cmdline.c,v 1.29 2017/12/31 03:02:23 christos Exp $");
 
 #include 
 #include 
@@ -65,7 +65,8 @@ procfs_docmdline(
 struct lwp *curl,
 struct proc *p,
 struct pfsnode *pfs,
-struct uio *uio
+struct uio *uio,
+int oid
 )
 {
 	size_t len, start;
@@ -104,7 +105,7 @@ procfs_docmdline(
 
 	len = uio->uio_offset + uio->uio_resid;
 
-	error = copy_procargs(p, KERN_PROC_ARGV, &len,
+	error = copy_procargs(p, oid, &len,
 	procfs_docmdline_helper, uio);
 	return error;
 }

Index: src/sys/miscfs/procfs/procfs_subr.c
diff -u src/sys/miscfs/procfs/procfs_subr.c:1.109 src/sys/miscfs/procfs/procfs_subr.c:1.110
--- src/sys/miscfs/procfs/procfs_subr.c:1.109	Sun Aug 27 20:46:07 2017
+++ src/sys/miscfs/procfs/procfs_subr.c	Sat Dec 30 22:02:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_subr.c,v 1.109 2017/08/28 00:46:07 kamil Exp $	*/
+/*	$NetBSD: procfs_subr.c,v 1.110 2017/12/31 03:02:23 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -102,7 +102,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.109 2017/08/28 00:46:07 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.110 2017/12/31 03:02:23 christos Exp $");
 
 #include 
 #include 
@@ -114,6 +114,7 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_subr.
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -221,7 +222,11 @@ procfs_rw(void *v)
 		break;
 
 	case PFScmdline:
-		error = procfs_docmdline(curl, p, pfs, uio);
+		error = procfs_docmdline(curl, p, pfs, uio, KERN_PROC_ARGV);
+		break;
+
+	case PFSenviron:
+		error = procfs_docmdline(curl, p, pfs, uio, KERN_PROC_ENV);
 		break;
 
 	case PFSmeminfo:

Index: src/sys/miscfs/procfs/procfs_vfsops.c
diff -u src/sys/miscfs/procfs/procfs_vfsops.c:1.98 src/sys/miscfs/procfs/procfs_vfsops.c:1.99
--- src/sys/miscfs/procfs/procfs_vfsops.c:1.98	Sun Aug 27 20:46:07 2017
+++ src/sys/miscfs/procfs/procfs_vfsops.c	Sat Dec 30 22:02:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vfsops.c,v 1.98 2017/08/28 00:46:07 kamil Exp $	*/
+/*	$NetBSD: procfs_vfsops.c,v 1.99 2017/12/31 03:02:23 christos Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.98 2017/08/28 00:46:07 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.99 2017/12/31 03:02:23 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -395,6 +395,7 @@

CVS commit: src/sys/miscfs/procfs

2017-12-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec  1 19:01:34 UTC 2017

Modified Files:
src/sys/miscfs/procfs: procfs_vnops.c

Log Message:
Allow procfs_kqfilter, since we allow poll. "go" does it.


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.201 src/sys/miscfs/procfs/procfs_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/procfs/procfs_vnops.c
diff -u src/sys/miscfs/procfs/procfs_vnops.c:1.200 src/sys/miscfs/procfs/procfs_vnops.c:1.201
--- src/sys/miscfs/procfs/procfs_vnops.c:1.200	Tue Nov  7 19:51:47 2017
+++ src/sys/miscfs/procfs/procfs_vnops.c	Fri Dec  1 14:01:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vnops.c,v 1.200 2017/11/08 00:51:47 christos Exp $	*/
+/*	$NetBSD: procfs_vnops.c,v 1.201 2017/12/01 19:01:34 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -105,7 +105,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.200 2017/11/08 00:51:47 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.201 2017/12/01 19:01:34 christos Exp $");
 
 #include 
 #include 
@@ -217,7 +217,8 @@ int	procfs_setattr(void *);
 #define	procfs_fcntl	genfs_fcntl
 #define	procfs_ioctl	genfs_enoioctl
 #define	procfs_poll	genfs_poll
-#define procfs_revoke	genfs_revoke
+#define	procfs_kqfilter	genfs_kqfilter
+#define	procfs_revoke	genfs_revoke
 #define	procfs_fsync	genfs_nullop
 #define	procfs_seek	genfs_nullop
 #define	procfs_remove	genfs_eopnotsupp
@@ -265,6 +266,7 @@ const struct vnodeopv_entry_desc procfs_
 	{ &vop_fcntl_desc, procfs_fcntl },		/* fcntl */
 	{ &vop_ioctl_desc, procfs_ioctl },		/* ioctl */
 	{ &vop_poll_desc, procfs_poll },		/* poll */
+	{ &vop_kqfilter_desc, procfs_kqfilter },	/* kqfilter */
 	{ &vop_revoke_desc, procfs_revoke },		/* revoke */
 	{ &vop_fsync_desc, procfs_fsync },		/* fsync */
 	{ &vop_seek_desc, procfs_seek },		/* seek */



CVS commit: src/sys/miscfs/procfs

2017-11-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov  8 00:51:47 UTC 2017

Modified Files:
src/sys/miscfs/procfs: procfs_vnops.c

Log Message:
fix locking, remove error(1) comments.


To generate a diff of this commit:
cvs rdiff -u -r1.199 -r1.200 src/sys/miscfs/procfs/procfs_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/procfs/procfs_vnops.c
diff -u src/sys/miscfs/procfs/procfs_vnops.c:1.199 src/sys/miscfs/procfs/procfs_vnops.c:1.200
--- src/sys/miscfs/procfs/procfs_vnops.c:1.199	Tue Nov  7 19:42:12 2017
+++ src/sys/miscfs/procfs/procfs_vnops.c	Tue Nov  7 19:51:47 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vnops.c,v 1.199 2017/11/08 00:42:12 christos Exp $	*/
+/*	$NetBSD: procfs_vnops.c,v 1.200 2017/11/08 00:51:47 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -105,7 +105,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.199 2017/11/08 00:42:12 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.200 2017/11/08 00:51:47 christos Exp $");
 
 #include 
 #include 
@@ -782,8 +782,6 @@ procfs_getattr(void *v)
 	case PFSself:
 	case PFScurproc:
 		vap->va_bytes = vap->va_size =
-/*###785 [cc] error: 'bf' undeclared (first use in this function)%%%*/
-/*###785 [cc] note: each undeclared identifier is reported only once for each function it appears in%%%*/
 		snprintf(bf, sizeof(bf), "%ld", (long)curproc->p_pid);
 		break;
 	case PFStask:
@@ -843,7 +841,6 @@ procfs_getattr(void *v)
 		vap->va_bytes = vap->va_size = procp->p_execsw->es_arglen;
 		break;
 
-
 #if defined(PT_GETREGS) || defined(PT_SETREGS)
 	case PFSregs:
 		vap->va_bytes = vap->va_size = sizeof(struct reg);
@@ -884,7 +881,6 @@ procfs_getattr(void *v)
 
 	case PFScwd:
 	case PFSchroot:
-/*###885 [cc] error: 'bp' undeclared (first use in this function)%%%*/
 		bp = path + MAXPATHLEN;
 		*--bp = '\0';
 		procfs_dir(pfs->pfs_type, curlwp, procp, &bp, path,
@@ -1601,7 +1597,7 @@ procfs_readlink(void *v)
 	int len = 0;
 	int error = 0;
 	struct pfsnode *pfs = VTOPFS(ap->a_vp);
-	struct proc *pown;
+	struct proc *pown = NULL;
 
 	if (pfs->pfs_fileno == PROCFS_FILENO(0, PFScurproc, -1))
 		len = snprintf(bf, sizeof(bf), "%ld", (long)curproc->p_pid);
@@ -1614,7 +1610,6 @@ procfs_readlink(void *v)
 			return error;
 		bp = pown->p_path;
 		len = strlen(bp);
-		procfs_proc_unlock(pown);
 	} else if (pfs->pfs_fileno == PROCFS_FILENO(pfs->pfs_pid, PFScwd, -1) ||
 	pfs->pfs_fileno == PROCFS_FILENO(pfs->pfs_pid, PFSchroot, -1)) {
 		if ((error = procfs_proc_lock(pfs->pfs_pid, &pown, ESRCH)) != 0)
@@ -1628,7 +1623,6 @@ procfs_readlink(void *v)
 		*--bp = '\0';
 		procfs_dir(PROCFS_TYPE(pfs->pfs_fileno), curlwp, pown,
 		&bp, path, MAXPATHLEN);
-		procfs_proc_unlock(pown);
 		len = strlen(bp);
 	} else {
 		file_t *fp;
@@ -1696,11 +1690,12 @@ procfs_readlink(void *v)
 			break;
 		}	
 		closef(fp);
-		procfs_proc_unlock(pown);
 	}
 
 	if (error == 0)
 		error = uiomove(bp, len, ap->a_uio);
+	if (pown)
+		procfs_proc_unlock(pown);
 	if (path)
 		free(path, M_TEMP);
 	return error;



CVS commit: src/sys/miscfs/procfs

2017-11-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov  8 00:42:12 UTC 2017

Modified Files:
src/sys/miscfs/procfs: procfs_vnops.c

Log Message:
use p->p_path, remove unused code.


To generate a diff of this commit:
cvs rdiff -u -r1.198 -r1.199 src/sys/miscfs/procfs/procfs_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/procfs/procfs_vnops.c
diff -u src/sys/miscfs/procfs/procfs_vnops.c:1.198 src/sys/miscfs/procfs/procfs_vnops.c:1.199
--- src/sys/miscfs/procfs/procfs_vnops.c:1.198	Sun Aug 27 20:46:07 2017
+++ src/sys/miscfs/procfs/procfs_vnops.c	Tue Nov  7 19:42:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vnops.c,v 1.198 2017/08/28 00:46:07 kamil Exp $	*/
+/*	$NetBSD: procfs_vnops.c,v 1.199 2017/11/08 00:42:12 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -105,7 +105,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.198 2017/08/28 00:46:07 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.199 2017/11/08 00:42:12 christos Exp $");
 
 #include 
 #include 
@@ -569,9 +569,6 @@ procfs_dir(pfstype t, struct lwp *caller
 	case PFSchroot:
 		vp = target->p_cwdi->cwdi_rdir;
 		break;
-	case PFSexe:
-		vp = target->p_textvp;
-		break;
 	default:
 		rw_exit(&cwdi->cwdi_lock);
 		return;
@@ -596,14 +593,8 @@ procfs_dir(pfstype t, struct lwp *caller
 	len / 2, 0, caller) != 0) {
 		vp = NULL;
 		if (bpp) {
-/* 
-			if (t == PFSexe) {
-snprintf(path, len, "%s/%d/file"
-mp->mnt_stat.f_mntonname, pfs->pfs_pid);
-			} else */ {
-bp = *bpp;
-*--bp = '/';
-			}
+			bp = *bpp;
+			*--bp = '/';
 		}
 	}
 
@@ -633,7 +624,7 @@ procfs_getattr(void *v)
 	struct pfsnode *pfs = VTOPFS(ap->a_vp);
 	struct vattr *vap = ap->a_vap;
 	struct proc *procp;
-	char *path;
+	char *path, *bp, bf[16];
 	int error;
 
 	/* first check the process still exists */
@@ -660,7 +651,6 @@ procfs_getattr(void *v)
 		/*FALLTHROUGH*/
 	case PFScwd:
 	case PFSchroot:
-	case PFSexe:
 		path = malloc(MAXPATHLEN + 4, M_TEMP, M_WAITOK|M_CANFAIL);
 		if (path == NULL && procp != NULL) {
 			procfs_proc_unlock(procp);
@@ -746,6 +736,8 @@ procfs_getattr(void *v)
 		vap->va_uid = kauth_cred_geteuid(procp->p_cred);
 		vap->va_gid = kauth_cred_getegid(procp->p_cred);
 		break;
+	case PFScwd:
+	case PFSchroot:
 	case PFSmeminfo:
 	case PFSdevices:
 	case PFScpuinfo:
@@ -754,19 +746,17 @@ procfs_getattr(void *v)
 	case PFScpustat:
 	case PFSloadavg:
 	case PFSversion:
+	case PFSexe:
+	case PFSself:
+	case PFScurproc:
+	case PFSroot:
 		vap->va_nlink = 1;
 		vap->va_uid = vap->va_gid = 0;
 		break;
 
 	case PFSproc:
 	case PFStask:
-	case PFSexe:
 	case PFSfile:
-	case PFSself:
-	case PFScurproc:
-	case PFScwd:
-	case PFSroot:
-	case PFSchroot:
 	case PFSfd:
 		break;
 
@@ -786,28 +776,18 @@ procfs_getattr(void *v)
 
 	switch (pfs->pfs_type) {
 	case PFSroot:
-		/*
-		 * Set nlink to 1 to tell fts(3) we don't actually know.
-		 */
-		vap->va_nlink = 1;
-		vap->va_uid = 0;
-		vap->va_gid = 0;
 		vap->va_bytes = vap->va_size = DEV_BSIZE;
 		break;
 
 	case PFSself:
-	case PFScurproc: {
-		char bf[16];		/* should be enough */
-		vap->va_nlink = 1;
-		vap->va_uid = 0;
-		vap->va_gid = 0;
+	case PFScurproc:
 		vap->va_bytes = vap->va_size =
+/*###785 [cc] error: 'bf' undeclared (first use in this function)%%%*/
+/*###785 [cc] note: each undeclared identifier is reported only once for each function it appears in%%%*/
 		snprintf(bf, sizeof(bf), "%ld", (long)curproc->p_pid);
 		break;
-	}
 	case PFStask:
 		if (pfs->pfs_fd != -1) {
-			char bf[4];		/* should be enough */
 			vap->va_nlink = 1;
 			vap->va_uid = 0;
 			vap->va_gid = 0;
@@ -904,19 +884,17 @@ procfs_getattr(void *v)
 
 	case PFScwd:
 	case PFSchroot:
-	case PFSexe: {
-		char *bp;
-
-		vap->va_nlink = 1;
-		vap->va_uid = 0;
-		vap->va_gid = 0;
+/*###885 [cc] error: 'bp' undeclared (first use in this function)%%%*/
 		bp = path + MAXPATHLEN;
 		*--bp = '\0';
 		procfs_dir(pfs->pfs_type, curlwp, procp, &bp, path,
 		 MAXPATHLEN);
 		vap->va_bytes = vap->va_size = strlen(bp);
 		break;
-	}
+
+	case PFSexe:
+		vap->va_bytes = vap->va_size = strlen(procp->p_path);
+		break;
 
 	case PFSemul:
 		vap->va_bytes = vap->va_size = strlen(procp->p_emul->e_name);
@@ -1631,9 +1609,14 @@ procfs_readlink(void *v)
 		len = snprintf(bf, sizeof(bf), "%s", "curproc");
 	else if (pfs->pfs_fileno == PROCFS_FILENO(pfs->pfs_pid, PFStask, 0))
 		len = snprintf(bf, sizeof(bf), "..");
-	else if (pfs->pfs_fileno == PROCFS_FILENO(pfs->pfs_pid, PFScwd, -1) ||
-	pfs->pfs_fileno == PROCFS_FILENO(pfs->pfs_pid, PFSchroot, -1) ||
-	pfs->pfs_fileno == PROCFS_FILENO(pfs->pfs_pid, PFSexe, -1)) {
+	else if (pfs->pfs_fileno == PROCFS_FILENO(pfs->pfs_pid, PFSexe, -1)) {
+		if ((error = procfs_proc_lock(pfs->pfs_pid, &pown, ESRCH)) != 0)
+			return error;
+		bp = pown->p_path;
+		len = strlen(bp);
+		procfs

CVS commit: src/sys/miscfs/procfs

2017-09-29 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Fri Sep 29 17:27:26 UTC 2017

Modified Files:
src/sys/miscfs/procfs: procfs_status.c

Log Message:
Use %ju and (intmax_t) to unbreak i386 build.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/miscfs/procfs/procfs_status.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/procfs/procfs_status.c
diff -u src/sys/miscfs/procfs/procfs_status.c:1.38 src/sys/miscfs/procfs/procfs_status.c:1.39
--- src/sys/miscfs/procfs/procfs_status.c:1.38	Fri Sep 29 12:57:05 2017
+++ src/sys/miscfs/procfs/procfs_status.c	Fri Sep 29 17:27:26 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_status.c,v 1.38 2017/09/29 12:57:05 christos Exp $	*/
+/*	$NetBSD: procfs_status.c,v 1.39 2017/09/29 17:27:26 kre Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_status.c,v 1.38 2017/09/29 12:57:05 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_status.c,v 1.39 2017/09/29 17:27:26 kre Exp $");
 
 #include 
 #include 
@@ -129,11 +129,11 @@ procfs_status_netbsd(struct lwp *l, stru
 		ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "\n");
 
 		ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf),
-		"VmPeak:\t%8lu kB\n", p->p_rlimit[RLIMIT_DATA].rlim_cur / 1024);
+		"VmPeak:\t%8ju kB\n", (intmax_t)p->p_rlimit[RLIMIT_DATA].rlim_cur / 1024);
 		ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf),
-		"VmSize:\t%8lu kB\n", p->p_rlimit[RLIMIT_DATA].rlim_cur / 1024);
+		"VmSize:\t%8ju kB\n", (intmax_t)p->p_rlimit[RLIMIT_DATA].rlim_cur / 1024);
 		ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf),
-		"VmRSS:\t%8lu kB\n", p->p_rlimit[RLIMIT_RSS].rlim_cur / 1024);
+		"VmRSS:\t%8ju kB\n", (intmax_t)p->p_rlimit[RLIMIT_RSS].rlim_cur / 1024);
 
 	} else {
 /* comm pid ppid pgid sid maj,min ctty,sldr start ut st wmsg uid gid groups ... */



CVS commit: src/sys/miscfs/procfs

2017-09-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 29 12:57:05 UTC 2017

Modified Files:
src/sys/miscfs/procfs: procfs_status.c

Log Message:
Split the status printing routines (one for NetBSD and one for Linux) for
simplicity (Robert Swindelis)


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/miscfs/procfs/procfs_status.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/procfs/procfs_status.c
diff -u src/sys/miscfs/procfs/procfs_status.c:1.37 src/sys/miscfs/procfs/procfs_status.c:1.38
--- src/sys/miscfs/procfs/procfs_status.c:1.37	Mon Nov 14 03:55:51 2016
+++ src/sys/miscfs/procfs/procfs_status.c	Fri Sep 29 08:57:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_status.c,v 1.37 2016/11/14 08:55:51 kre Exp $	*/
+/*	$NetBSD: procfs_status.c,v 1.38 2017/09/29 12:57:05 christos Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_status.c,v 1.37 2016/11/14 08:55:51 kre Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_status.c,v 1.38 2017/09/29 12:57:05 christos Exp $");
 
 #include 
 #include 
@@ -88,13 +88,8 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_statu
 
 #include 
 
-int
-procfs_dostatus(
-struct lwp *curl,
-struct lwp *l,
-struct pfsnode *pfs,
-struct uio *uio
-)
+static int
+procfs_status_netbsd(struct lwp *l, struct uio *uio)
 {
 	struct session *sess;
 	struct tty *tp;
@@ -102,13 +97,12 @@ procfs_dostatus(
 	struct proc *p = l->l_proc;
 	char *ps;
 	const char *sep;
+	const char *emulname = curlwp->l_proc->p_emul->e_name;
 	int pid, ppid, pgid, sid;
 	u_int i;
 	char psbuf[256+MAXHOSTNAMELEN];		/* XXX - conservative */
 	uint16_t ngroups;
 
-	if (uio->uio_rw != UIO_READ)
-		return (EOPNOTSUPP);
 
 	mutex_enter(proc_lock);
 	mutex_enter(p->p_lock);
@@ -119,67 +113,149 @@ procfs_dostatus(
 	sess = p->p_pgrp->pg_session;
 	sid = sess->s_sid;
 
+	ps = psbuf;
+	if (strncmp(emulname, "linux", 5) == 0) {
+		ps += snprintf(ps, sizeof(psbuf), "Name:\t%s\n", p->p_comm);
+		ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "Pid:\t%d\n", pid);
+		ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "PPid:\t%d\n", ppid);
+		ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "TracerPid:\t%d\n", 0);
+
+		cr = p->p_cred;
+		ngroups = kauth_cred_ngroups(cr);
+		ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "Groups:\t");
+		for (i = 0; i < ngroups; i++)
+			ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "%d ",
+			kauth_cred_group(cr, i));
+		ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "\n");
+
+		ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf),
+		"VmPeak:\t%8lu kB\n", p->p_rlimit[RLIMIT_DATA].rlim_cur / 1024);
+		ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf),
+		"VmSize:\t%8lu kB\n", p->p_rlimit[RLIMIT_DATA].rlim_cur / 1024);
+		ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf),
+		"VmRSS:\t%8lu kB\n", p->p_rlimit[RLIMIT_RSS].rlim_cur / 1024);
+
+	} else {
 /* comm pid ppid pgid sid maj,min ctty,sldr start ut st wmsg uid gid groups ... */
 
-	ps = psbuf;
-	memcpy(ps, p->p_comm, MAXCOMLEN);
-	ps[MAXCOMLEN] = '\0';
-	ps += strlen(ps);
-	ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), " %d %d %d %d ",
-	pid, ppid, pgid, sid);
-
-	if ((p->p_lflag & PL_CONTROLT) && (tp = sess->s_ttyp))
-		ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "%llu,%llu ",
-		(unsigned long long)major(tp->t_dev),
-		(unsigned long long)minor(tp->t_dev));
-	else
-		ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "%d,%d ",
-		-1, -1);
-
-	sep = "";
-	if (sess->s_ttyvp) {
-		ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "%sctty", sep);
-		sep = ",";
-	}
-	if (SESS_LEADER(p)) {
-		ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "%ssldr", sep);
-		sep = ",";
+		memcpy(ps, p->p_comm, MAXCOMLEN);
+		ps[MAXCOMLEN] = '\0';
+		ps += strlen(ps);
+		ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), " %d %d %d %d ",
+		pid, ppid, pgid, sid);
+
+		if ((p->p_lflag & PL_CONTROLT) && (tp = sess->s_ttyp))
+			ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "%llu,%llu ",
+			(unsigned long long)major(tp->t_dev),
+			(unsigned long long)minor(tp->t_dev));
+		else
+			ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "%d,%d ",
+			-1, -1);
+
+		sep = "";
+		if (sess->s_ttyvp) {
+			ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "%sctty", sep);
+			sep = ",";
+		}
+		if (SESS_LEADER(p)) {
+			ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "%ssldr", sep);
+			sep = ",";
+		}
+		if (*sep != ',')
+			ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "noflags");
+
+		ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), " %lld,%ld",
+		(long long)p->p_stats->p_start.tv_sec,
+		(long)p->p_stats->p_start.tv_usec);
+
+		{
+			struct timeval ut, st;
+
+			calcru(p, &ut, &st, (void *) 0, NULL);
+			ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf),
+			" %lld,%ld %lld,%ld", (long long)ut.tv_sec,
+			

CVS commit: src/sys/miscfs/genfs

2017-07-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jul  1 20:07:00 UTC 2017

Modified Files:
src/sys/miscfs/genfs: genfs_vnops.c

Log Message:
Provide EVFILT_WRITE; this is what FreeBSD does and go wants it.
Makes go unit tests pass.


To generate a diff of this commit:
cvs rdiff -u -r1.197 -r1.198 src/sys/miscfs/genfs/genfs_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/genfs/genfs_vnops.c
diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.197 src/sys/miscfs/genfs/genfs_vnops.c:1.198
--- src/sys/miscfs/genfs/genfs_vnops.c:1.197	Sun Jun  4 04:02:26 2017
+++ src/sys/miscfs/genfs/genfs_vnops.c	Sat Jul  1 16:07:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_vnops.c,v 1.197 2017/06/04 08:02:26 hannken Exp $	*/
+/*	$NetBSD: genfs_vnops.c,v 1.198 2017/07/01 20:07:00 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.197 2017/06/04 08:02:26 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.198 2017/07/01 20:07:00 christos Exp $");
 
 #include 
 #include 
@@ -500,6 +500,32 @@ filt_genfsread(struct knote *kn, long hi
 }
 
 static int
+filt_genfswrite(struct knote *kn, long hint)
+{
+	struct vnode *vp = (struct vnode *)kn->kn_hook;
+
+	/*
+	 * filesystem is gone, so set the EOF flag and schedule
+	 * the knote for deletion.
+	 */
+	switch (hint) {
+	case NOTE_REVOKE:
+		KASSERT(mutex_owned(vp->v_interlock));
+		kn->kn_flags |= (EV_EOF | EV_ONESHOT);
+		return (1);
+	case 0:
+		mutex_enter(vp->v_interlock);
+		kn->kn_data = 0;
+		mutex_exit(vp->v_interlock);
+		return 1;
+	default:
+		KASSERT(mutex_owned(vp->v_interlock));
+		kn->kn_data = 0;
+		return 1;
+	}
+}
+
+static int
 filt_genfsvnode(struct knote *kn, long hint)
 {
 	struct vnode *vp = (struct vnode *)kn->kn_hook;
@@ -530,6 +556,8 @@ filt_genfsvnode(struct knote *kn, long h
 
 static const struct filterops genfsread_filtops =
 	{ 1, NULL, filt_genfsdetach, filt_genfsread };
+static const struct filterops genfswrite_filtops =
+	{ 1, NULL, filt_genfsdetach, filt_genfswrite };
 static const struct filterops genfsvnode_filtops =
 	{ 1, NULL, filt_genfsdetach, filt_genfsvnode };
 
@@ -549,6 +577,9 @@ genfs_kqfilter(void *v)
 	case EVFILT_READ:
 		kn->kn_fop = &genfsread_filtops;
 		break;
+	case EVFILT_WRITE:
+		kn->kn_fop = &genfswrite_filtops;
+		break;
 	case EVFILT_VNODE:
 		kn->kn_fop = &genfsvnode_filtops;
 		break;



CVS commit: src/sys/miscfs/genfs

2017-06-27 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jun 27 08:40:53 UTC 2017

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
Add missing check for dead or dying vnode to the entry of genfs_getpages().


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/miscfs/genfs/genfs_io.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/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.69 src/sys/miscfs/genfs/genfs_io.c:1.70
--- src/sys/miscfs/genfs/genfs_io.c:1.69	Sun Jun  4 08:05:42 2017
+++ src/sys/miscfs/genfs/genfs_io.c	Tue Jun 27 08:40:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.69 2017/06/04 08:05:42 hannken Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.70 2017/06/27 08:40:53 hannken Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.69 2017/06/04 08:05:42 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.70 2017/06/27 08:40:53 hannken Exp $");
 
 #include 
 #include 
@@ -139,6 +139,13 @@ genfs_getpages(void *v)
 	KASSERT(vp->v_type == VREG || vp->v_type == VDIR ||
 	vp->v_type == VLNK || vp->v_type == VBLK);
 
+	error = vdead_check(vp, VDEAD_NOWAIT);
+	if (error) {
+		if ((flags & PGO_LOCKED) == 0)
+			mutex_exit(uobj->vmobjlock);
+		return error;
+	}
+
 startover:
 	error = 0;
 	const voff_t origvsize = vp->v_size;



CVS commit: src/sys/miscfs/specfs

2017-06-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Jun 24 12:14:21 UTC 2017

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
Refuse to open a block device with zero open count when it has
a mountpoint set.  This may happen after forced detach or unplug
of a mounted block device.


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/sys/miscfs/specfs/spec_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/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.173 src/sys/miscfs/specfs/spec_vnops.c:1.174
--- src/sys/miscfs/specfs/spec_vnops.c:1.173	Thu Jun  1 02:45:14 2017
+++ src/sys/miscfs/specfs/spec_vnops.c	Sat Jun 24 12:14:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.173 2017/06/01 02:45:14 chs Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.174 2017/06/24 12:14:21 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.173 2017/06/01 02:45:14 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.174 2017/06/24 12:14:21 hannken Exp $");
 
 #include 
 #include 
@@ -580,13 +580,16 @@ spec_open(void *v)
 		 * For block devices, permit only one open.  The buffer
 		 * cache cannot remain self-consistent with multiple
 		 * vnodes holding a block device open.
+		 *
+		 * Treat zero opencnt with non-NULL mountpoint as open.
+		 * This may happen after forced detach of a mounted device.
 		 */
 		mutex_enter(&device_lock);
 		if (sn->sn_gone) {
 			mutex_exit(&device_lock);
 			return (EBADF);
 		}
-		if (sd->sd_opencnt != 0) {
+		if (sd->sd_opencnt != 0 || sd->sd_mountpoint != NULL) {
 			mutex_exit(&device_lock);
 			return EBUSY;
 		}



CVS commit: src/sys/miscfs/genfs

2017-06-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Jun  4 08:01:33 UTC 2017

Modified Files:
src/sys/miscfs/genfs: genfs_vnops.c

Log Message:
Now that FSTRANS is part of VOP_*LOCK() remove FSTRANS and vdead_check()
from genfs_.*lock() and assert the vnode state once the vnode is locked.


To generate a diff of this commit:
cvs rdiff -u -r1.195 -r1.196 src/sys/miscfs/genfs/genfs_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/genfs/genfs_vnops.c
diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.195 src/sys/miscfs/genfs/genfs_vnops.c:1.196
--- src/sys/miscfs/genfs/genfs_vnops.c:1.195	Tue Apr 11 14:29:32 2017
+++ src/sys/miscfs/genfs/genfs_vnops.c	Sun Jun  4 08:01:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_vnops.c,v 1.195 2017/04/11 14:29:32 riastradh Exp $	*/
+/*	$NetBSD: genfs_vnops.c,v 1.196 2017/06/04 08:01:33 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.195 2017/04/11 14:29:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.196 2017/06/04 08:01:33 hannken Exp $");
 
 #include 
 #include 
@@ -288,41 +288,18 @@ genfs_deadlock(void *v)
 	vnode_impl_t *vip = VNODE_TO_VIMPL(vp);
 	int flags = ap->a_flags;
 	krw_t op;
-	int error;
+
+	if (! ISSET(flags, LK_RETRY))
+		return ENOENT;
 
 	op = (ISSET(flags, LK_EXCLUSIVE) ? RW_WRITER : RW_READER);
 	if (ISSET(flags, LK_NOWAIT)) {
 		if (! rw_tryenter(vip->vi_lock, op))
 			return EBUSY;
-		if (mutex_tryenter(vp->v_interlock)) {
-			error = vdead_check(vp, VDEAD_NOWAIT);
-			if (error == ENOENT && ISSET(flags, LK_RETRY))
-error = 0;
-			mutex_exit(vp->v_interlock);
-		} else
-			error = EBUSY;
-		if (error)
-			rw_exit(vip->vi_lock);
-		return error;
-	}
-
-	rw_enter(vip->vi_lock, op);
-	mutex_enter(vp->v_interlock);
-	error = vdead_check(vp, VDEAD_NOWAIT);
-	if (error == EBUSY) {
-		rw_exit(vip->vi_lock);
-		error = vdead_check(vp, 0);
-		KASSERT(error == ENOENT);
-		mutex_exit(vp->v_interlock);
+	} else {
 		rw_enter(vip->vi_lock, op);
-		mutex_enter(vp->v_interlock);
-	}
-	KASSERT(error == ENOENT);
-	mutex_exit(vp->v_interlock);
-	if (! ISSET(flags, LK_RETRY)) {
-		rw_exit(vip->vi_lock);
-		return ENOENT;
 	}
+	VSTATE_ASSERT_UNLOCKED(vp, VS_RECLAIMED);
 	return 0;
 }
 
@@ -355,43 +332,18 @@ genfs_lock(void *v)
 	} */ *ap = v;
 	vnode_t *vp = ap->a_vp;
 	vnode_impl_t *vip = VNODE_TO_VIMPL(vp);
-	struct mount *mp = vp->v_mount;
 	int flags = ap->a_flags;
 	krw_t op;
-	int error;
 
 	op = (ISSET(flags, LK_EXCLUSIVE) ? RW_WRITER : RW_READER);
 	if (ISSET(flags, LK_NOWAIT)) {
-		if (fstrans_start_nowait(mp, FSTRANS_SHARED))
-			return EBUSY;
-		if (! rw_tryenter(vip->vi_lock, op)) {
-			fstrans_done(mp);
+		if (! rw_tryenter(vip->vi_lock, op))
 			return EBUSY;
-		}
-		if (mutex_tryenter(vp->v_interlock)) {
-			error = vdead_check(vp, VDEAD_NOWAIT);
-			mutex_exit(vp->v_interlock);
-		} else
-			error = EBUSY;
-		if (error) {
-			rw_exit(vip->vi_lock);
-			fstrans_done(mp);
-		}
-		return error;
-	}
-
-	fstrans_start(mp, FSTRANS_SHARED);
-	rw_enter(vip->vi_lock, op);
-	mutex_enter(vp->v_interlock);
-	error = vdead_check(vp, VDEAD_NOWAIT);
-	if (error) {
-		rw_exit(vip->vi_lock);
-		fstrans_done(mp);
-		error = vdead_check(vp, 0);
-		KASSERT(error == ENOENT);
+	} else {
+		rw_enter(vip->vi_lock, op);
 	}
-	mutex_exit(vp->v_interlock);
-	return error;
+	VSTATE_ASSERT_UNLOCKED(vp, VS_ACTIVE);
+	return 0;
 }
 
 /*
@@ -405,10 +357,8 @@ genfs_unlock(void *v)
 	} */ *ap = v;
 	vnode_t *vp = ap->a_vp;
 	vnode_impl_t *vip = VNODE_TO_VIMPL(vp);
-	struct mount *mp = vp->v_mount;
 
 	rw_exit(vip->vi_lock);
-	fstrans_done(mp);
 
 	return 0;
 }



CVS commit: src/sys/miscfs/genfs

2017-05-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed May 24 09:54:40 UTC 2017

Modified Files:
src/sys/miscfs/genfs: layer_vnops.c

Log Message:
Protect layer_getpages against vnodes disappearing during a
forced unmount.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/miscfs/genfs/layer_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/genfs/layer_vnops.c
diff -u src/sys/miscfs/genfs/layer_vnops.c:1.64 src/sys/miscfs/genfs/layer_vnops.c:1.65
--- src/sys/miscfs/genfs/layer_vnops.c:1.64	Sun May  7 08:21:57 2017
+++ src/sys/miscfs/genfs/layer_vnops.c	Wed May 24 09:54:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: layer_vnops.c,v 1.64 2017/05/07 08:21:57 hannken Exp $	*/
+/*	$NetBSD: layer_vnops.c,v 1.65 2017/05/24 09:54:40 hannken Exp $	*/
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -170,7 +170,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.64 2017/05/07 08:21:57 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.65 2017/05/24 09:54:40 hannken Exp $");
 
 #include 
 #include 
@@ -183,6 +183,7 @@ __KERNEL_RCSID(0, "$NetBSD: layer_vnops.
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -790,6 +791,8 @@ layer_getpages(void *v)
 		int a_flags;
 	} */ *ap = v;
 	struct vnode *vp = ap->a_vp;
+	struct mount *mp = vp->v_mount;
+	int error;
 
 	KASSERT(mutex_owned(vp->v_interlock));
 
@@ -800,7 +803,19 @@ layer_getpages(void *v)
 	KASSERT(vp->v_interlock == ap->a_vp->v_interlock);
 
 	/* Just pass the request on to the underlying layer. */
-	return VCALL(ap->a_vp, VOFFSET(vop_getpages), ap);
+	mutex_exit(vp->v_interlock);
+	fstrans_start(mp, FSTRANS_SHARED);
+	mutex_enter(vp->v_interlock);
+	if (mp == vp->v_mount) {
+		/* Will release the interlock. */
+		error = VCALL(ap->a_vp, VOFFSET(vop_getpages), ap);
+	} else {
+		mutex_exit(vp->v_interlock);
+		error = ENOENT;
+	}
+	fstrans_done(mp);
+
+	return error;
 }
 
 int



CVS commit: src/sys/miscfs/genfs

2017-05-07 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun May  7 08:21:57 UTC 2017

Modified Files:
src/sys/miscfs/genfs: layer_vnops.c

Log Message:
Move v_writecount adjustment from revoke to reclaim.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/miscfs/genfs/layer_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/genfs/layer_vnops.c
diff -u src/sys/miscfs/genfs/layer_vnops.c:1.63 src/sys/miscfs/genfs/layer_vnops.c:1.64
--- src/sys/miscfs/genfs/layer_vnops.c:1.63	Wed Apr 26 03:02:49 2017
+++ src/sys/miscfs/genfs/layer_vnops.c	Sun May  7 08:21:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: layer_vnops.c,v 1.63 2017/04/26 03:02:49 riastradh Exp $	*/
+/*	$NetBSD: layer_vnops.c,v 1.64 2017/05/07 08:21:57 hannken Exp $	*/
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -170,7 +170,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.63 2017/04/26 03:02:49 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.64 2017/05/07 08:21:57 hannken Exp $");
 
 #include 
 #include 
@@ -693,15 +693,8 @@ layer_revoke(void *v)
 	 * We will most likely end up in vclean which uses the v_usecount
 	 * to determine if a vnode is active.  Take an extra reference on
 	 * the lower vnode so it will always close and inactivate.
-	 * Remove our writecount from the lower vnode.
 	 */
 	vref(lvp);
-
-	mutex_enter(vp->v_interlock);
-	KASSERT(vp->v_interlock == lvp->v_interlock);
-	lvp->v_writecount -= vp->v_writecount;
-	mutex_exit(vp->v_interlock);
-
 	error = LAYERFS_DO_BYPASS(vp, ap);
 	vrele(lvp);
 
@@ -734,6 +727,12 @@ layer_reclaim(void *v)
 		 */
 		lmp->layerm_rootvp = NULL;
 	}
+
+	mutex_enter(vp->v_interlock);
+	KASSERT(vp->v_interlock == lowervp->v_interlock);
+	lowervp->v_writecount -= vp->v_writecount;
+	mutex_exit(vp->v_interlock);
+
 	/* After this assignment, this node will not be re-used. */
 	xp->layer_lowervp = NULL;
 	kmem_free(vp->v_data, lmp->layerm_size);



CVS commit: src/sys/miscfs/procfs

2017-04-13 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Apr 13 09:54:18 UTC 2017

Modified Files:
src/sys/miscfs/procfs: procfs_linux.c

Log Message:
Switch procfs_domounts() to mountlist iterator.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/miscfs/procfs/procfs_linux.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/procfs/procfs_linux.c
diff -u src/sys/miscfs/procfs/procfs_linux.c:1.72 src/sys/miscfs/procfs/procfs_linux.c:1.73
--- src/sys/miscfs/procfs/procfs_linux.c:1.72	Mon Mar 28 17:23:47 2016
+++ src/sys/miscfs/procfs/procfs_linux.c	Thu Apr 13 09:54:18 2017
@@ -1,4 +1,4 @@
-/*  $NetBSD: procfs_linux.c,v 1.72 2016/03/28 17:23:47 mlelstv Exp $  */
+/*  $NetBSD: procfs_linux.c,v 1.73 2017/04/13 09:54:18 hannken Exp $  */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.72 2016/03/28 17:23:47 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.73 2017/04/13 09:54:18 hannken Exp $");
 
 #include 
 #include 
@@ -603,26 +603,22 @@ procfs_domounts(struct lwp *curl, struct
 {
 	char *bf, *mtab = NULL;
 	size_t mtabsz = 0;
-	struct mount *mp, *nmp;
+	mount_iterator_t *iter;
+	struct mount *mp;
 	int error = 0, root = 0;
 	struct cwdinfo *cwdi = curl->l_proc->p_cwdi;
 
 	bf = malloc(LBFSZ, M_TEMP, M_WAITOK);
 
-	mutex_enter(&mountlist_lock);
-	for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
+	mountlist_iterator_init(&iter);
+	while ((mp = mountlist_iterator_next(iter)) != NULL) {
 		struct statvfs sfs;
 
-		if (vfs_busy(mp, &nmp))
-			continue;
-
 		if ((error = dostatvfs(mp, &sfs, curl, MNT_WAIT, 0)) == 0)
 			root |= procfs_format_sfs(&mtab, &mtabsz, bf, LBFSZ,
 			&sfs, curl, 0);
-
-		vfs_unbusy(mp, false, &nmp);
 	}
-	mutex_exit(&mountlist_lock);
+	mountlist_iterator_destroy(iter);
 
 	/*
 	 * If we are inside a chroot that is not itself a mount point,



CVS commit: src/sys/miscfs/specfs

2017-04-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 12 06:43:56 UTC 2017

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
Make the non-DIAGNOSTIC version compile


To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/sys/miscfs/specfs/spec_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/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.170 src/sys/miscfs/specfs/spec_vnops.c:1.171
--- src/sys/miscfs/specfs/spec_vnops.c:1.170	Tue Apr 11 14:25:01 2017
+++ src/sys/miscfs/specfs/spec_vnops.c	Wed Apr 12 06:43:56 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.170 2017/04/11 14:25:01 riastradh Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.171 2017/04/12 06:43:56 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.170 2017/04/11 14:25:01 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.171 2017/04/12 06:43:56 martin Exp $");
 
 #include 
 #include 
@@ -1086,9 +1086,8 @@ spec_inactive(void *v)
 		struct vnode *a_vp;
 		struct bool *a_recycle;
 	} */ *ap = v;
-	struct vnode *vp = ap->a_vp;
 
-	KASSERT(vp->v_mount == dead_rootmount);
+	KASSERT(ap->a_vp->v_mount == dead_rootmount);
 	*ap->a_recycle = true;
 
 	return 0;



CVS commit: src/sys/miscfs

2017-04-11 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Apr 11 07:51:37 UTC 2017

Modified Files:
src/sys/miscfs/genfs: layer.h layer_vfsops.c
src/sys/miscfs/nullfs: null.h null_vfsops.c
src/sys/miscfs/overlay: overlay.h overlay_vfsops.c
src/sys/miscfs/umapfs: umap.h umap_vfsops.c

Log Message:
Field "layerm_vfs" of "struct layer_mount" got superseded by "mnt_lower".
Adapt consumers and remove the now unused field.

Ride 7.99.68


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/miscfs/genfs/layer.h
cvs rdiff -u -r1.48 -r1.49 src/sys/miscfs/genfs/layer_vfsops.c
cvs rdiff -u -r1.19 -r1.20 src/sys/miscfs/nullfs/null.h
cvs rdiff -u -r1.93 -r1.94 src/sys/miscfs/nullfs/null_vfsops.c
cvs rdiff -u -r1.8 -r1.9 src/sys/miscfs/overlay/overlay.h
cvs rdiff -u -r1.66 -r1.67 src/sys/miscfs/overlay/overlay_vfsops.c
cvs rdiff -u -r1.16 -r1.17 src/sys/miscfs/umapfs/umap.h
cvs rdiff -u -r1.98 -r1.99 src/sys/miscfs/umapfs/umap_vfsops.c

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

Modified files:

Index: src/sys/miscfs/genfs/layer.h
diff -u src/sys/miscfs/genfs/layer.h:1.16 src/sys/miscfs/genfs/layer.h:1.17
--- src/sys/miscfs/genfs/layer.h:1.16	Wed May 28 10:51:20 2014
+++ src/sys/miscfs/genfs/layer.h	Tue Apr 11 07:51:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: layer.h,v 1.16 2014/05/28 10:51:20 hannken Exp $	*/
+/*	$NetBSD: layer.h,v 1.17 2017/04/11 07:51:37 hannken Exp $	*/
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -79,7 +79,6 @@ struct layer_args {
 #ifdef _KERNEL
 
 struct layer_mount {
-	struct mount		*layerm_vfs;
 	struct vnode		*layerm_rootvp;	/* Ref to root layer_node */
 	u_int			layerm_flags;	/* mount point layer flags */
 	u_int			layerm_size;	/* size of fs's struct node */

Index: src/sys/miscfs/genfs/layer_vfsops.c
diff -u src/sys/miscfs/genfs/layer_vfsops.c:1.48 src/sys/miscfs/genfs/layer_vfsops.c:1.49
--- src/sys/miscfs/genfs/layer_vfsops.c:1.48	Thu Mar 30 09:16:52 2017
+++ src/sys/miscfs/genfs/layer_vfsops.c	Tue Apr 11 07:51:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: layer_vfsops.c,v 1.48 2017/03/30 09:16:52 hannken Exp $	*/
+/*	$NetBSD: layer_vfsops.c,v 1.49 2017/04/11 07:51:37 hannken Exp $	*/
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -74,7 +74,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.48 2017/03/30 09:16:52 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.49 2017/04/11 07:51:37 hannken Exp $");
 
 #include 
 #include 
@@ -127,7 +127,7 @@ layerfs_start(struct mount *mp, int flag
 {
 
 #ifdef notyet
-	return VFS_START(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, flags);
+	return VFS_START(mp->mnt_lower, flags);
 #else
 	return 0;
 #endif
@@ -156,7 +156,7 @@ int
 layerfs_quotactl(struct mount *mp, struct quotactl_args *args)
 {
 
-	return VFS_QUOTACTL(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, args);
+	return VFS_QUOTACTL(mp->mnt_lower, args);
 }
 
 int
@@ -169,7 +169,7 @@ layerfs_statvfs(struct mount *mp, struct
 	if (sbuf == NULL) {
 		return ENOMEM;
 	}
-	error = VFS_STATVFS(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, sbuf);
+	error = VFS_STATVFS(mp->mnt_lower, sbuf);
 	if (error) {
 		goto done;
 	}
@@ -249,7 +249,7 @@ layerfs_vget(struct mount *mp, ino_t ino
 	struct vnode *vp;
 	int error;
 
-	error = VFS_VGET(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, ino, &vp);
+	error = VFS_VGET(mp->mnt_lower, ino, &vp);
 	if (error) {
 		*vpp = NULL;
 		return error;
@@ -276,7 +276,7 @@ layerfs_fhtovp(struct mount *mp, struct 
 	struct vnode *vp;
 	int error;
 
-	error = VFS_FHTOVP(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, fidp, &vp);
+	error = VFS_FHTOVP(mp->mnt_lower, fidp, &vp);
 	if (error) {
 		*vpp = NULL;
 		return error;
@@ -381,12 +381,12 @@ int
 layerfs_renamelock_enter(struct mount *mp)
 {
 
-	return VFS_RENAMELOCK_ENTER(MOUNTTOLAYERMOUNT(mp)->layerm_vfs);
+	return VFS_RENAMELOCK_ENTER(mp->mnt_lower);
 }
 
 void
 layerfs_renamelock_exit(struct mount *mp)
 {
 
-	VFS_RENAMELOCK_EXIT(MOUNTTOLAYERMOUNT(mp)->layerm_vfs);
+	VFS_RENAMELOCK_EXIT(mp->mnt_lower);
 }

Index: src/sys/miscfs/nullfs/null.h
diff -u src/sys/miscfs/nullfs/null.h:1.19 src/sys/miscfs/nullfs/null.h:1.20
--- src/sys/miscfs/nullfs/null.h:1.19	Fri Jul  2 03:16:01 2010
+++ src/sys/miscfs/nullfs/null.h	Tue Apr 11 07:51:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: null.h,v 1.19 2010/07/02 03:16:01 rmind Exp $	*/
+/*	$NetBSD: null.h,v 1.20 2017/04/11 07:51:37 hannken Exp $	*/
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -83,7 +83,6 @@ struct null_args {
 struct null_mount {
 	struct	layer_mount	lm;	/* generic layerfs mount stuff */
 };
-#define	nullm_vfs		lm.layerm_vfs
 #define	nullm_rootvp		lm.layerm_rootvp
 #define	nullm_export		lm.layerm_export
 #define	nullm_flags		lm.layerm_flags

Index: src/sys/miscfs/nullfs/null_vfsops.c
diff -u src/sys/miscfs/nullfs/null_vfsops.c:1.93 src/sys/miscfs/nullfs/null_vfsops.c:1.94
--- src/sys/miscfs/nullfs/n

CVS commit: src/sys/miscfs/genfs

2017-04-01 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Apr  1 23:34:17 UTC 2017

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
Clarify meaning of "glocked" argument of genfs_putpages_read.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/miscfs/genfs/genfs_io.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/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.67 src/sys/miscfs/genfs/genfs_io.c:1.68
--- src/sys/miscfs/genfs/genfs_io.c:1.67	Sat Apr  1 19:57:54 2017
+++ src/sys/miscfs/genfs/genfs_io.c	Sat Apr  1 23:34:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.67 2017/04/01 19:57:54 riastradh Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.68 2017/04/01 23:34:17 dholland Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.67 2017/04/01 19:57:54 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.68 2017/04/01 23:34:17 dholland Exp $");
 
 #include 
 #include 
@@ -508,6 +508,10 @@ out_err:
 
 /*
  * genfs_getpages_read: Read the pages in with VOP_BMAP/VOP_STRATEGY.
+ *
+ * "glocked" (which is currently not actually used) tells us not whether
+ * the genfs_node is locked on entry (it always is) but whether it was
+ * locked on entry to genfs_getpages.
  */
 static int
 genfs_getpages_read(struct vnode *vp, struct vm_page **pgs, int npages,



CVS commit: src/sys/miscfs/genfs

2017-04-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Apr  1 19:57:54 UTC 2017

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
Simplify genfs_getpages_read async/unlock protocol.

Previously the caller unlocked for error or sync I/O, whereas
genfs_getpages_read unlocked on successful async.

Now caller unlocks in every case, and genfs_getpages_read doesn't
touch the lock.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/miscfs/genfs/genfs_io.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/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.66 src/sys/miscfs/genfs/genfs_io.c:1.67
--- src/sys/miscfs/genfs/genfs_io.c:1.66	Thu Mar 30 09:12:21 2017
+++ src/sys/miscfs/genfs/genfs_io.c	Sat Apr  1 19:57:54 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.66 2017/03/30 09:12:21 hannken Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.67 2017/04/01 19:57:54 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.66 2017/03/30 09:12:21 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.67 2017/04/01 19:57:54 riastradh Exp $");
 
 #include 
 #include 
@@ -428,11 +428,11 @@ startover:
 	mutex_exit(uobj->vmobjlock);
 	error = genfs_getpages_read(vp, pgs, npages, startoffset, diskeof,
 	async, memwrite, blockalloc, glocked);
-	if (error == 0 && async)
-		goto out_err_free;
 	if (!glocked) {
 		genfs_node_unlock(vp);
 	}
+	if (error == 0 && async)
+		goto out_err_free;
 	mutex_enter(uobj->vmobjlock);
 
 	/*
@@ -714,9 +714,6 @@ loopdone:
 	nestiobuf_done(mbp, skipbytes, error);
 	if (async) {
 		UVMHIST_LOG(ubchist, "returning 0 (async)",0,0,0,0);
-		if (!glocked) {
-			genfs_node_unlock(vp);
-		}
 		return 0;
 	}
 	if (bp != NULL) {



CVS commit: src/sys/miscfs/procfs

2017-03-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Mar 30 20:21:00 UTC 2017

Modified Files:
src/sys/miscfs/procfs: procfs_auxv.c

Log Message:
remove comment.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/miscfs/procfs/procfs_auxv.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/procfs/procfs_auxv.c
diff -u src/sys/miscfs/procfs/procfs_auxv.c:1.1 src/sys/miscfs/procfs/procfs_auxv.c:1.2
--- src/sys/miscfs/procfs/procfs_auxv.c:1.1	Thu Mar 30 16:16:29 2017
+++ src/sys/miscfs/procfs/procfs_auxv.c	Thu Mar 30 16:21:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_auxv.c,v 1.1 2017/03/30 20:16:29 christos Exp $	*/
+/*	$NetBSD: procfs_auxv.c,v 1.2 2017/03/30 20:21:00 christos Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_auxv.c,v 1.1 2017/03/30 20:16:29 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_auxv.c,v 1.2 2017/03/30 20:21:00 christos Exp $");
 
 #include 
 #include 
@@ -52,11 +52,6 @@ procfs_doauxv(struct lwp *curl, struct p
 	if ((error = proc_getauxv(p, &buffer, &bufsize)) != 0)
 		return error;
 
-	/*
-	 * We support reading from an offset, because linux does.
-	 * The map could have changed between the two reads, and
-	 * that could result in junk, but typically it does not.
-	 */
 	if (uio->uio_offset < bufsize)
 		error = uiomove((char *)buffer + uio->uio_offset,
 		bufsize - uio->uio_offset, uio);



CVS commit: src/sys/miscfs/procfs

2017-03-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Mar 30 20:16:29 UTC 2017

Modified Files:
src/sys/miscfs/procfs: files.procfs procfs.h procfs_subr.c
procfs_vfsops.c procfs_vnops.c
Added Files:
src/sys/miscfs/procfs: procfs_auxv.c

Log Message:
add an auxv node.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/miscfs/procfs/files.procfs
cvs rdiff -u -r1.70 -r1.71 src/sys/miscfs/procfs/procfs.h
cvs rdiff -u -r0 -r1.1 src/sys/miscfs/procfs/procfs_auxv.c
cvs rdiff -u -r1.106 -r1.107 src/sys/miscfs/procfs/procfs_subr.c
cvs rdiff -u -r1.96 -r1.97 src/sys/miscfs/procfs/procfs_vfsops.c
cvs rdiff -u -r1.194 -r1.195 src/sys/miscfs/procfs/procfs_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/procfs/files.procfs
diff -u src/sys/miscfs/procfs/files.procfs:1.10 src/sys/miscfs/procfs/files.procfs:1.11
--- src/sys/miscfs/procfs/files.procfs:1.10	Tue Nov  1 20:12:00 2016
+++ src/sys/miscfs/procfs/files.procfs	Thu Mar 30 16:16:29 2017
@@ -1,8 +1,9 @@
-#	$NetBSD: files.procfs,v 1.10 2016/11/02 00:12:00 pgoyette Exp $
+#	$NetBSD: files.procfs,v 1.11 2017/03/30 20:16:29 christos Exp $
 
 deffs	PROCFS:	PTRACE_HOOKS
 
 define	procfs: vfs
+file	miscfs/procfs/procfs_auxv.c	procfs
 file	miscfs/procfs/procfs_cmdline.c	procfs
 file	miscfs/procfs/procfs_ctl.c	procfs
 file	miscfs/procfs/procfs_fd.c	procfs

Index: src/sys/miscfs/procfs/procfs.h
diff -u src/sys/miscfs/procfs/procfs.h:1.70 src/sys/miscfs/procfs/procfs.h:1.71
--- src/sys/miscfs/procfs/procfs.h:1.70	Sun Jul 27 12:47:26 2014
+++ src/sys/miscfs/procfs/procfs.h	Thu Mar 30 16:16:29 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs.h,v 1.70 2014/07/27 16:47:26 hannken Exp $	*/
+/*	$NetBSD: procfs.h,v 1.71 2017/03/30 20:16:29 christos Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -110,6 +110,7 @@ typedef enum {
 	PFSstatm,	/* process memory info (if -o linux) */
 	PFSversion,	/* kernel version (if -o linux) */
 	PFStask,	/* task subdirector (if -o linux) */
+	PFSauxv,	/* ELF Auxiliary Vector */
 #ifdef __HAVE_PROCFS_MACHDEP
 	PROCFS_MACHDEP_NODE_TYPES
 #endif
@@ -192,6 +193,7 @@ const vfs_namemap_t *vfs_findname(const 
 
 int procfs_proc_lock(int, struct proc **, int);
 void procfs_proc_unlock(struct proc *);
+struct mount;
 int procfs_allocvp(struct mount *, struct vnode **, pid_t, pfstype, int);
 int procfs_donote(struct lwp *, struct proc *, struct pfsnode *,
 struct uio *);
@@ -233,11 +235,14 @@ int procfs_doemul(struct lwp *, struct p
 struct uio *);
 int procfs_doversion(struct lwp *, struct proc *, struct pfsnode *,
 struct uio *);
+int procfs_doauxv(struct lwp *, struct proc *, struct pfsnode *,
+struct uio *);
 
 void procfs_revoke_vnodes(struct proc *, void *);
 int procfs_getfp(struct pfsnode *, struct proc *, struct file **);
 
 /* functions to check whether or not files should be displayed */
+int procfs_validauxv(struct lwp *, struct mount *);
 int procfs_validfile(struct lwp *, struct mount *);
 int procfs_validfpregs(struct lwp *, struct mount *);
 int procfs_validregs(struct lwp *, struct mount *);

Index: src/sys/miscfs/procfs/procfs_subr.c
diff -u src/sys/miscfs/procfs/procfs_subr.c:1.106 src/sys/miscfs/procfs/procfs_subr.c:1.107
--- src/sys/miscfs/procfs/procfs_subr.c:1.106	Mon Nov 10 13:46:34 2014
+++ src/sys/miscfs/procfs/procfs_subr.c	Thu Mar 30 16:16:29 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_subr.c,v 1.106 2014/11/10 18:46:34 maxv Exp $	*/
+/*	$NetBSD: procfs_subr.c,v 1.107 2017/03/30 20:16:29 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -102,7 +102,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.106 2014/11/10 18:46:34 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.107 2017/03/30 20:16:29 christos Exp $");
 
 #include 
 #include 
@@ -272,6 +272,10 @@ procfs_rw(void *v)
 		error = procfs_doversion(curl, p, pfs, uio);
 		break;
 
+	case PFSauxv:
+		error = procfs_doauxv(curl, p, pfs, uio);
+		break;
+
 #ifdef __HAVE_PROCFS_MACHDEP
 	PROCFS_MACHDEP_NODETYPE_CASES
 		error = procfs_machdep_rw(curl, l, pfs, uio);

Index: src/sys/miscfs/procfs/procfs_vfsops.c
diff -u src/sys/miscfs/procfs/procfs_vfsops.c:1.96 src/sys/miscfs/procfs/procfs_vfsops.c:1.97
--- src/sys/miscfs/procfs/procfs_vfsops.c:1.96	Fri Feb 17 03:31:25 2017
+++ src/sys/miscfs/procfs/procfs_vfsops.c	Thu Mar 30 16:16:29 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vfsops.c,v 1.96 2017/02/17 08:31:25 hannken Exp $	*/
+/*	$NetBSD: procfs_vfsops.c,v 1.97 2017/03/30 20:16:29 christos Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.96 2017/02/17 08:31:25 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.97 2017/03/30 20:16:29 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -386,20 +386,25 @@ procfs_loadvnode(struct mount *m

CVS commit: src/sys/miscfs/genfs

2017-03-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Mar 30 09:11:12 UTC 2017

Modified Files:
src/sys/miscfs/genfs: genfs_rename.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/miscfs/genfs/genfs_rename.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/genfs/genfs_rename.c
diff -u src/sys/miscfs/genfs/genfs_rename.c:1.2 src/sys/miscfs/genfs/genfs_rename.c:1.3
--- src/sys/miscfs/genfs/genfs_rename.c:1.2	Thu Feb  6 10:57:12 2014
+++ src/sys/miscfs/genfs/genfs_rename.c	Thu Mar 30 09:11:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_rename.c,v 1.2 2014/02/06 10:57:12 hannken Exp $	*/
+/*	$NetBSD: genfs_rename.c,v 1.3 2017/03/30 09:11:12 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.2 2014/02/06 10:57:12 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.3 2017/03/30 09:11:12 hannken Exp $");
 
 #include 
 #include 
@@ -45,7 +45,6 @@ __KERNEL_RCSID(0, "$NetBSD: genfs_rename
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
@@ -177,7 +176,6 @@ genfs_insane_rename(void *v,
 	struct componentname *fcnp = ap->a_fcnp;
 	struct vnode *tdvp = ap->a_tdvp;
 	struct vnode *tvp = ap->a_tvp;
-	struct mount *mp = fdvp->v_mount;
 	struct componentname *tcnp = ap->a_tcnp;
 	kauth_cred_t cred;
 	int error;
@@ -196,8 +194,6 @@ genfs_insane_rename(void *v,
 	KASSERT(fdvp->v_type == VDIR);
 	KASSERT(tdvp->v_type == VDIR);
 
-	fstrans_start(mp, FSTRANS_SHARED);
-
 	cred = fcnp->cn_cred;
 
 	/*
@@ -232,8 +228,6 @@ genfs_insane_rename(void *v,
 	vrele(fdvp);
 	vrele(tdvp);
 
-	fstrans_done(mp);
-
 	return error;
 }
 



CVS commit: src/sys/miscfs/genfs

2017-03-09 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Mar  9 10:10:02 UTC 2017

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
Protect genfs_do_putpages() against vnodes disappearing during
a forced mount update from read-write to read-only.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/miscfs/genfs/genfs_io.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/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.64 src/sys/miscfs/genfs/genfs_io.c:1.65
--- src/sys/miscfs/genfs/genfs_io.c:1.64	Wed Mar  1 10:47:26 2017
+++ src/sys/miscfs/genfs/genfs_io.c	Thu Mar  9 10:10:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.64 2017/03/01 10:47:26 hannken Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.65 2017/03/09 10:10:02 hannken Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.64 2017/03/01 10:47:26 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.65 2017/03/09 10:10:02 hannken Exp $");
 
 #include 
 #include 
@@ -842,11 +842,11 @@ genfs_do_putpages(struct vnode *vp, off_
 	bool pagedaemon = curlwp == uvm.pagedaemon_lwp;
 	struct lwp * const l = curlwp ? curlwp : &lwp0;
 	struct genfs_node * const gp = VTOG(vp);
+	struct mount *trans_mp;
 	int flags;
 	int dirtygen;
 	bool modified;
-	bool need_wapbl;
-	bool has_trans;
+	bool holds_wapbl;
 	bool cleanall;
 	bool onworklst;
 
@@ -859,9 +859,8 @@ genfs_do_putpages(struct vnode *vp, off_
 	UVMHIST_LOG(ubchist, "vp %p pages %d off 0x%x len 0x%x",
 	vp, uobj->uo_npages, startoff, endoff - startoff);
 
-	has_trans = false;
-	need_wapbl = (!pagedaemon && vp->v_mount && vp->v_mount->mnt_wapbl &&
-	(origflags & PGO_JOURNALLOCKED) == 0);
+	trans_mp = NULL;
+	holds_wapbl = false;
 
 retry:
 	modified = false;
@@ -874,10 +873,10 @@ retry:
 			if (LIST_FIRST(&vp->v_dirtyblkhd) == NULL)
 vn_syncer_remove_from_worklist(vp);
 		}
-		if (has_trans) {
-			if (need_wapbl)
-WAPBL_END(vp->v_mount);
-			fstrans_done(vp->v_mount);
+		if (trans_mp) {
+			if (holds_wapbl)
+WAPBL_END(trans_mp);
+			fstrans_done(trans_mp);
 		}
 		mutex_exit(slock);
 		return (0);
@@ -887,24 +886,41 @@ retry:
 	 * the vnode has pages, set up to process the request.
 	 */
 
-	if (!has_trans && (flags & PGO_CLEANIT) != 0) {
-		mutex_exit(slock);
+	if (trans_mp == NULL && (flags & PGO_CLEANIT) != 0) {
 		if (pagedaemon) {
-			error = fstrans_start_nowait(vp->v_mount, FSTRANS_LAZY);
-			if (error)
-return error;
-		} else
-			fstrans_start(vp->v_mount, FSTRANS_LAZY);
-		if (need_wapbl) {
-			error = WAPBL_BEGIN(vp->v_mount);
+			/* Pagedaemon must not sleep here. */
+			trans_mp = vp->v_mount;
+			error = fstrans_start_nowait(trans_mp, FSTRANS_LAZY);
 			if (error) {
-fstrans_done(vp->v_mount);
+mutex_exit(slock);
 return error;
 			}
+		} else {
+			/*
+			 * Cannot use vdeadcheck() here as this operation
+			 * usually gets used from VOP_RECLAIM().  Test for
+			 * change of v_mount instead and retry on change.
+			 */
+			mutex_exit(slock);
+			trans_mp = vp->v_mount;
+			fstrans_start(trans_mp, FSTRANS_LAZY);
+			if (vp->v_mount != trans_mp) {
+fstrans_done(trans_mp);
+trans_mp = NULL;
+			} else {
+holds_wapbl = (trans_mp->mnt_wapbl &&
+(origflags & PGO_JOURNALLOCKED) == 0);
+if (holds_wapbl) {
+	error = WAPBL_BEGIN(trans_mp);
+	if (error) {
+		fstrans_done(trans_mp);
+		return error;
+	}
+}
+			}
+			mutex_enter(slock);
+			goto retry;
 		}
-		has_trans = true;
-		mutex_enter(slock);
-		goto retry;
 	}
 
 	error = 0;
@@ -1277,10 +1293,10 @@ skip_scan:
 		goto retry;
 	}
 
-	if (has_trans) {
-		if (need_wapbl)
-			WAPBL_END(vp->v_mount);
-		fstrans_done(vp->v_mount);
+	if (trans_mp) {
+		if (holds_wapbl)
+			WAPBL_END(trans_mp);
+		fstrans_done(trans_mp);
 	}
 
 	return (error);



CVS commit: src/sys/miscfs/genfs

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

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
Protect genfs_getpages() against vnodes disappearing during a
forced mount update from read-write to read-only.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/miscfs/genfs/genfs_io.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/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.63 src/sys/miscfs/genfs/genfs_io.c:1.64
--- src/sys/miscfs/genfs/genfs_io.c:1.63	Thu Sep 29 19:08:48 2016
+++ src/sys/miscfs/genfs/genfs_io.c	Wed Mar  1 10:47:26 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.63 2016/09/29 19:08:48 christos Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.64 2017/03/01 10:47:26 hannken Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.63 2016/09/29 19:08:48 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.64 2017/03/01 10:47:26 hannken Exp $");
 
 #include 
 #include 
@@ -129,8 +129,8 @@ genfs_getpages(void *v)
 	const bool overwrite = (flags & PGO_OVERWRITE) != 0;
 	const bool blockalloc = memwrite && (flags & PGO_NOBLOCKALLOC) == 0;
 	const bool glocked = (flags & PGO_GLOCKHELD) != 0;
-	const bool need_wapbl = blockalloc && vp->v_mount->mnt_wapbl;
-	bool has_trans_wapbl = false;
+	bool holds_wapbl = false;
+	struct mount *trans_mount = NULL;
 	UVMHIST_FUNC("genfs_getpages"); UVMHIST_CALLED(ubchist);
 
 	UVMHIST_LOG(ubchist, "vp %p off 0x%x/%x count %d",
@@ -291,20 +291,27 @@ startover:
 	UVMHIST_LOG(ubchist, "ridx %d npages %d startoff %ld endoff %ld",
 	ridx, npages, startoffset, endoffset);
 
-	if (!has_trans_wapbl) {
-		fstrans_start(vp->v_mount, FSTRANS_SHARED);
+	if (trans_mount == NULL) {
+		trans_mount = vp->v_mount;
+		fstrans_start(trans_mount, FSTRANS_SHARED);
+		/*
+		 * check if this vnode is still valid.
+		 */
+		mutex_enter(vp->v_interlock);
+		error = vdead_check(vp, 0);
+		mutex_exit(vp->v_interlock);
+		if (error)
+			goto out_err_free;
 		/*
 		 * XXX: This assumes that we come here only via
 		 * the mmio path
 		 */
-		if (need_wapbl) {
-			error = WAPBL_BEGIN(vp->v_mount);
-			if (error) {
-fstrans_done(vp->v_mount);
+		if (blockalloc && vp->v_mount->mnt_wapbl) {
+			error = WAPBL_BEGIN(trans_mount);
+			if (error)
 goto out_err_free;
-			}
+			holds_wapbl = true;
 		}
-		has_trans_wapbl = true;
 	}
 
 	/*
@@ -491,10 +498,10 @@ out_err_free:
 	if (pgs != NULL && pgs != pgs_onstack)
 		kmem_free(pgs, pgs_size);
 out_err:
-	if (has_trans_wapbl) {
-		if (need_wapbl)
-			WAPBL_END(vp->v_mount);
-		fstrans_done(vp->v_mount);
+	if (trans_mount != NULL) {
+		if (holds_wapbl)
+			WAPBL_END(trans_mount);
+		fstrans_done(trans_mount);
 	}
 	return error;
 }



CVS commit: src/sys/miscfs/specfs

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

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
Add a diagnostic test for buffers written to a block device holding
a read-only mounted file system.

This will become a KASSERT in the near future.


To generate a diff of this commit:
cvs rdiff -u -r1.168 -r1.169 src/sys/miscfs/specfs/spec_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/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.168 src/sys/miscfs/specfs/spec_vnops.c:1.169
--- src/sys/miscfs/specfs/spec_vnops.c:1.168	Mon Jan  2 10:33:28 2017
+++ src/sys/miscfs/specfs/spec_vnops.c	Wed Mar  1 10:46:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.168 2017/01/02 10:33:28 hannken Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.169 2017/03/01 10:46:05 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.168 2017/01/02 10:33:28 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.169 2017/03/01 10:46:05 hannken Exp $");
 
 #include 
 #include 
@@ -1053,6 +1053,16 @@ spec_strategy(void *v)
 	bp->b_dev = dev;
 
 	if (!(bp->b_flags & B_READ)) {
+#ifdef DIAGNOSTIC
+		if (bp->b_vp && bp->b_vp->v_type == VBLK) {
+			struct mount *mp = spec_node_getmountedfs(bp->b_vp);
+
+			if (mp && (mp->mnt_flag & MNT_RDONLY)) {
+printf("%s blk %"PRId64" written while ro!\n",
+mp->mnt_stat.f_mntonname, bp->b_blkno);
+			}
+		}
+#endif /* DIAGNOSTIC */
 		error = fscow_run(bp, false);
 		if (error)
 			goto out;



CVS commit: src/sys/miscfs

2017-01-27 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Jan 27 10:47:13 UTC 2017

Modified Files:
src/sys/miscfs/genfs: layer_extern.h layer_vnops.c
src/sys/miscfs/nullfs: null_vnops.c
src/sys/miscfs/overlay: overlay_vnops.c
src/sys/miscfs/umapfs: umap_vnops.c

Log Message:
Handle v_writecount from layer_open(), layer_close() and layer_revoke()
so lower file system vnodes get marked as open for writing.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/miscfs/genfs/layer_extern.h
cvs rdiff -u -r1.59 -r1.60 src/sys/miscfs/genfs/layer_vnops.c
cvs rdiff -u -r1.39 -r1.40 src/sys/miscfs/nullfs/null_vnops.c
cvs rdiff -u -r1.21 -r1.22 src/sys/miscfs/overlay/overlay_vnops.c
cvs rdiff -u -r1.57 -r1.58 src/sys/miscfs/umapfs/umap_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/genfs/layer_extern.h
diff -u src/sys/miscfs/genfs/layer_extern.h:1.36 src/sys/miscfs/genfs/layer_extern.h:1.37
--- src/sys/miscfs/genfs/layer_extern.h:1.36	Sun May 25 13:51:25 2014
+++ src/sys/miscfs/genfs/layer_extern.h	Fri Jan 27 10:47:13 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: layer_extern.h,v 1.36 2014/05/25 13:51:25 hannken Exp $	*/
+/*	$NetBSD: layer_extern.h,v 1.37 2017/01/27 10:47:13 hannken Exp $	*/
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -106,6 +106,7 @@ int	layer_lookup(void *);
 int	layer_setattr(void *);
 int	layer_access(void *);
 int	layer_open(void *);
+int	layer_close(void *);
 int	layer_remove(void *);
 int	layer_rename(void *);
 int	layer_revoke(void *);

Index: src/sys/miscfs/genfs/layer_vnops.c
diff -u src/sys/miscfs/genfs/layer_vnops.c:1.59 src/sys/miscfs/genfs/layer_vnops.c:1.60
--- src/sys/miscfs/genfs/layer_vnops.c:1.59	Sat Aug 20 12:37:09 2016
+++ src/sys/miscfs/genfs/layer_vnops.c	Fri Jan 27 10:47:13 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: layer_vnops.c,v 1.59 2016/08/20 12:37:09 hannken Exp $	*/
+/*	$NetBSD: layer_vnops.c,v 1.60 2017/01/27 10:47:13 hannken Exp $	*/
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -170,7 +170,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.59 2016/08/20 12:37:09 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.60 2017/01/27 10:47:13 hannken Exp $");
 
 #include 
 #include 
@@ -182,6 +182,7 @@ __KERNEL_RCSID(0, "$NetBSD: layer_vnops.
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -491,7 +492,8 @@ layer_access(void *v)
 }
 
 /*
- * We must handle open to be able to catch MNT_NODEV and friends.
+ * We must handle open to be able to catch MNT_NODEV and friends
+ * and increment the lower v_writecount.
  */
 int
 layer_open(void *v)
@@ -503,12 +505,43 @@ layer_open(void *v)
 		kauth_cred_t a_cred;
 	} */ *ap = v;
 	struct vnode *vp = ap->a_vp;
-	enum vtype lower_type = LAYERVPTOLOWERVP(vp)->v_type;
+	struct vnode *lvp = LAYERVPTOLOWERVP(vp);
+	int error;
 
-	if (((lower_type == VBLK) || (lower_type == VCHR)) &&
+	if (((lvp->v_type == VBLK) || (lvp->v_type == VCHR)) &&
 	(vp->v_mount->mnt_flag & MNT_NODEV))
 		return ENXIO;
 
+	error = LAYERFS_DO_BYPASS(vp, ap);
+	if (error == 0 && (ap->a_mode & FWRITE)) {
+		mutex_enter(lvp->v_interlock);
+		lvp->v_writecount++;
+		mutex_exit(lvp->v_interlock);
+	}
+	return error;
+}
+
+/*
+ * We must handle close to decrement the lower v_writecount.
+ */
+int
+layer_close(void *v)
+{
+	struct vop_close_args /* {
+		const struct vnodeop_desc *a_desc;
+		struct vnode *a_vp;
+		int a_fflag;
+		kauth_cred_t a_cred;
+	} */ *ap = v;
+	struct vnode *vp = ap->a_vp;
+	struct vnode *lvp = LAYERVPTOLOWERVP(vp);
+
+	if ((ap->a_fflag & FWRITE)) {
+		mutex_enter(lvp->v_interlock);
+		KASSERT(lvp->v_writecount > 0);
+		lvp->v_writecount--;
+		mutex_exit(lvp->v_interlock);
+	}
 	return LAYERFS_DO_BYPASS(vp, ap);
 }
 
@@ -660,8 +693,15 @@ layer_revoke(void *v)
 	 * We will most likely end up in vclean which uses the v_usecount
 	 * to determine if a vnode is active.  Take an extra reference on
 	 * the lower vnode so it will always close and inactivate.
+	 * Remove our writecount from the lower vnode.
 	 */
 	vref(lvp);
+
+	mutex_enter(vp->v_interlock);
+	KASSERT(vp->v_interlock == lvp->v_interlock);
+	lvp->v_writecount -= vp->v_writecount;
+	mutex_exit(vp->v_interlock);
+
 	error = LAYERFS_DO_BYPASS(vp, ap);
 	vrele(lvp);
 

Index: src/sys/miscfs/nullfs/null_vnops.c
diff -u src/sys/miscfs/nullfs/null_vnops.c:1.39 src/sys/miscfs/nullfs/null_vnops.c:1.40
--- src/sys/miscfs/nullfs/null_vnops.c:1.39	Thu Feb 27 16:51:38 2014
+++ src/sys/miscfs/nullfs/null_vnops.c	Fri Jan 27 10:47:13 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: null_vnops.c,v 1.39 2014/02/27 16:51:38 hannken Exp $	*/
+/*	$NetBSD: null_vnops.c,v 1.40 2017/01/27 10:47:13 hannken Exp $	*/
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -80,7 +80,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: null_vnops.c,v 

CVS commit: src/sys/miscfs/procfs

2016-11-02 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Nov  3 03:53:32 UTC 2016

Modified Files:
src/sys/miscfs/procfs: procfs_vfsops.c

Log Message:
Module procfs needs ptrace_common for process_do{,fp}regs


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/miscfs/procfs/procfs_vfsops.c

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

Modified files:

Index: src/sys/miscfs/procfs/procfs_vfsops.c
diff -u src/sys/miscfs/procfs/procfs_vfsops.c:1.94 src/sys/miscfs/procfs/procfs_vfsops.c:1.95
--- src/sys/miscfs/procfs/procfs_vfsops.c:1.94	Mon Nov 10 18:46:34 2014
+++ src/sys/miscfs/procfs/procfs_vfsops.c	Thu Nov  3 03:53:32 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vfsops.c,v 1.94 2014/11/10 18:46:34 maxv Exp $	*/
+/*	$NetBSD: procfs_vfsops.c,v 1.95 2016/11/03 03:53:32 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.94 2014/11/10 18:46:34 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.95 2016/11/03 03:53:32 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -105,7 +105,7 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_vfsop
 
 #include 			/* for PAGE_SIZE */
 
-MODULE(MODULE_CLASS_VFS, procfs, NULL);
+MODULE(MODULE_CLASS_VFS, procfs, "ptrace_common");
 
 VFS_PROTOS(procfs);
 



CVS commit: src/sys/miscfs/genfs

2016-09-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Sep 29 19:08:48 UTC 2016

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
don't change the loop counts; noted by mrg@


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/miscfs/genfs/genfs_io.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/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.62 src/sys/miscfs/genfs/genfs_io.c:1.63
--- src/sys/miscfs/genfs/genfs_io.c:1.62	Thu Sep 29 14:47:35 2016
+++ src/sys/miscfs/genfs/genfs_io.c	Thu Sep 29 15:08:48 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.62 2016/09/29 18:47:35 christos Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.63 2016/09/29 19:08:48 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.62 2016/09/29 18:47:35 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.63 2016/09/29 19:08:48 christos Exp $");
 
 #include 
 #include 
@@ -821,10 +821,15 @@ genfs_do_putpages(struct vnode *vp, off_
 	struct uvm_object * const uobj = &vp->v_uobj;
 	kmutex_t * const slock = uobj->vmobjlock;
 	off_t off;
-#define MAXPAGES (MAXPHYS / MIN_PAGE_SIZE)
 	int i, error, npages, nback;
 	int freeflag;
-	struct vm_page *pgs[MAXPAGES], *pg, *nextpg, *tpg, curmp, endmp;
+	/*
+	 * This array is larger than it should so that it's size is constant.
+	 * The right size is MAXPAGES.
+	 */
+	struct vm_page *pgs[MAXPHYS / MIN_PAGE_SIZE];
+#define MAXPAGES (MAXPHYS / PAGE_SIZE)
+	struct vm_page *pg, *nextpg, *tpg, curmp, endmp;
 	bool wasclean, by_list, needs_clean, yld;
 	bool async = (origflags & PGO_SYNCIO) == 0;
 	bool pagedaemon = curlwp == uvm.pagedaemon_lwp;



CVS commit: src/sys/miscfs/specfs

2016-09-08 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Sep  8 08:45:52 UTC 2016

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
Revert rev 1.164.  This will be redone differently (using "dummy"
modules).

This implementation requires changes to a base kernel in order to
update the set of "special" modules, kinda defeating the purpose of
having modules in the first place.  The new method will use dummy
modules (with name tap and tun) which will depend on the real
modules with the if_ prefix.

Coming soon to a NetBSD near you.


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/sys/miscfs/specfs/spec_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/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.164 src/sys/miscfs/specfs/spec_vnops.c:1.165
--- src/sys/miscfs/specfs/spec_vnops.c:1.164	Thu Sep  8 00:07:48 2016
+++ src/sys/miscfs/specfs/spec_vnops.c	Thu Sep  8 08:45:52 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.164 2016/09/08 00:07:48 pgoyette Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.165 2016/09/08 08:45:52 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.164 2016/09/08 00:07:48 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.165 2016/09/08 08:45:52 pgoyette Exp $");
 
 #include 
 #include 
@@ -482,16 +482,6 @@ spec_lookup(void *v)
 
 typedef int (*spec_ioctl_t)(dev_t, u_long, void *, int, struct lwp *);
 
-struct dev_to_mod {
-	const char *dev_name, *mod_name;
-};
-
-struct dev_to_mod dev_mod_table[] = {
-	{ "tap", "if_tap" },
-	{ "tun", "if_tun" },
-	{ NULL, NULL }
-};
-	
 /*
  * Open a special file.
  */
@@ -515,7 +505,6 @@ spec_open(void *v)
 	u_int gen;
 	const char *name;
 	struct partinfo pi;
-	struct dev_to_mod *conv;
 	
 	l = curlwp;
 	vp = ap->a_vp;
@@ -582,16 +571,6 @@ spec_open(void *v)
 			/* Get device name from devsw_conv array */
 			if ((name = cdevsw_getname(major(dev))) == NULL)
 break;
-
-			/* Check exception table for alternate module name */
-			conv = dev_mod_table;
-			while (conv->dev_name != NULL) {
-if (strcmp(conv->dev_name, name) == 0) {
-	name = conv->mod_name;
-	break;
-}
-conv++;
-			}
 			
 			/* Try to autoload device module */
 			(void) module_autoload(name, MODULE_CLASS_DRIVER);
@@ -644,16 +623,6 @@ spec_open(void *v)
 
 			VOP_UNLOCK(vp);
 
-			/* Check exception table for alternate module name */
-			conv = dev_mod_table;
-			while (conv->dev_name != NULL) {
-if (strcmp(conv->dev_name, name) == 0) {
-	name = conv->mod_name;
-	break;
-}
-conv++;
-			}
-
 /* Try to autoload device module */
 			(void) module_autoload(name, MODULE_CLASS_DRIVER);
 			



CVS commit: src/sys/miscfs/specfs

2016-09-07 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Sep  8 00:07:48 UTC 2016

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
if_config processing wants to auto-load modules named with an if_ prefix,
while specfc wants to auto-load modules without the prefix.  For modules
which can be loaded both ways (ie, if_tap and if_tun), provide a simple
conversion table for specfs so it can auto-load the if_ module.

This table should always be quite small, and the auto-load operation is
relatively infrequent, so the additional overhead of comparing names should
be tolerable.


To generate a diff of this commit:
cvs rdiff -u -r1.163 -r1.164 src/sys/miscfs/specfs/spec_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/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.163 src/sys/miscfs/specfs/spec_vnops.c:1.164
--- src/sys/miscfs/specfs/spec_vnops.c:1.163	Sat Aug 20 12:37:09 2016
+++ src/sys/miscfs/specfs/spec_vnops.c	Thu Sep  8 00:07:48 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.163 2016/08/20 12:37:09 hannken Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.164 2016/09/08 00:07:48 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.163 2016/08/20 12:37:09 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.164 2016/09/08 00:07:48 pgoyette Exp $");
 
 #include 
 #include 
@@ -482,6 +482,16 @@ spec_lookup(void *v)
 
 typedef int (*spec_ioctl_t)(dev_t, u_long, void *, int, struct lwp *);
 
+struct dev_to_mod {
+	const char *dev_name, *mod_name;
+};
+
+struct dev_to_mod dev_mod_table[] = {
+	{ "tap", "if_tap" },
+	{ "tun", "if_tun" },
+	{ NULL, NULL }
+};
+	
 /*
  * Open a special file.
  */
@@ -505,6 +515,7 @@ spec_open(void *v)
 	u_int gen;
 	const char *name;
 	struct partinfo pi;
+	struct dev_to_mod *conv;
 	
 	l = curlwp;
 	vp = ap->a_vp;
@@ -571,6 +582,16 @@ spec_open(void *v)
 			/* Get device name from devsw_conv array */
 			if ((name = cdevsw_getname(major(dev))) == NULL)
 break;
+
+			/* Check exception table for alternate module name */
+			conv = dev_mod_table;
+			while (conv->dev_name != NULL) {
+if (strcmp(conv->dev_name, name) == 0) {
+	name = conv->mod_name;
+	break;
+}
+conv++;
+			}
 			
 			/* Try to autoload device module */
 			(void) module_autoload(name, MODULE_CLASS_DRIVER);
@@ -623,6 +644,16 @@ spec_open(void *v)
 
 			VOP_UNLOCK(vp);
 
+			/* Check exception table for alternate module name */
+			conv = dev_mod_table;
+			while (conv->dev_name != NULL) {
+if (strcmp(conv->dev_name, name) == 0) {
+	name = conv->mod_name;
+	break;
+}
+conv++;
+			}
+
 /* Try to autoload device module */
 			(void) module_autoload(name, MODULE_CLASS_DRIVER);
 			



CVS commit: src/sys/miscfs/specfs

2016-04-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Apr  4 08:03:54 UTC 2016

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
Avoid a race with spec_revoke for the assertion too.

Final fix for PR kern/50467 Panic from disconnecting phone while reading
its contents


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/sys/miscfs/specfs/spec_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/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.161 src/sys/miscfs/specfs/spec_vnops.c:1.162
--- src/sys/miscfs/specfs/spec_vnops.c:1.161	Sat Mar 26 14:58:13 2016
+++ src/sys/miscfs/specfs/spec_vnops.c	Mon Apr  4 08:03:53 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.161 2016/03/26 14:58:13 hannken Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.162 2016/04/04 08:03:53 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.161 2016/03/26 14:58:13 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.162 2016/04/04 08:03:53 hannken Exp $");
 
 #include 
 #include 
@@ -1041,6 +1041,7 @@ spec_strategy(void *v)
 
 	mutex_enter(vp->v_interlock);
 	if (vdead_check(vp, VDEAD_NOWAIT) == 0 && vp->v_specnode != NULL) {
+		KASSERT(vp == vp->v_specnode->sn_dev->sd_bdevvp);
 		dev = vp->v_rdev;
 	}
 	mutex_exit(vp->v_interlock);
@@ -1051,8 +1052,6 @@ spec_strategy(void *v)
 	}
 	bp->b_dev = dev;
 
-	KASSERT(vp == vp->v_specnode->sn_dev->sd_bdevvp);
-
 	if (!(bp->b_flags & B_READ)) {
 		error = fscow_run(bp, false);
 		if (error)



CVS commit: src/sys/miscfs/procfs

2016-03-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Mar 28 17:23:47 UTC 2016

Modified Files:
src/sys/miscfs/procfs: procfs_linux.c

Log Message:
Align /proc//statm data with /proc//stat and
provide RSS information. There is no data about shared
pages.

Helps PR 50801.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/miscfs/procfs/procfs_linux.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/procfs/procfs_linux.c
diff -u src/sys/miscfs/procfs/procfs_linux.c:1.71 src/sys/miscfs/procfs/procfs_linux.c:1.72
--- src/sys/miscfs/procfs/procfs_linux.c:1.71	Fri Jul 24 13:02:52 2015
+++ src/sys/miscfs/procfs/procfs_linux.c	Mon Mar 28 17:23:47 2016
@@ -1,4 +1,4 @@
-/*  $NetBSD: procfs_linux.c,v 1.71 2015/07/24 13:02:52 maxv Exp $  */
+/*  $NetBSD: procfs_linux.c,v 1.72 2016/03/28 17:23:47 mlelstv Exp $  */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.71 2015/07/24 13:02:52 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.72 2016/03/28 17:23:47 mlelstv Exp $");
 
 #include 
 #include 
@@ -366,10 +366,10 @@ procfs_do_pid_statm(struct lwp *curl, st
 {
 	struct vmspace	*vm;
 	struct proc	*p = l->l_proc;
-	struct rusage	*ru = &p->p_stats->p_ru;
 	char		*bf;
 	int	 	 error;
 	int	 	 len;
+	struct kinfo_proc2 ki;
 
 	bf = malloc(LBFSZ, M_TEMP, M_WAITOK);
 
@@ -379,18 +379,27 @@ procfs_do_pid_statm(struct lwp *curl, st
 		goto out;
 	}
 
-	len = snprintf(bf, LBFSZ,
-	"%lu %lu %lu %lu %lu %lu %lu\n",
-		(unsigned long)(vm->vm_tsize + vm->vm_dsize + vm->vm_ssize), /* size */
-		(unsigned long)(vm->vm_rssize),	/* resident */
-		(unsigned long)(ru->ru_ixrss),	/* shared */
-		(unsigned long)(vm->vm_tsize),	/* text size in pages */
-		(unsigned long)(vm->vm_dsize),	/* data size in pages */
-		(unsigned long)(vm->vm_ssize),	/* stack size in pages */
-		(unsigned long) 0);
+	mutex_enter(proc_lock);
+	mutex_enter(p->p_lock);
+
+	/* retrieve RSS size */
+	fill_kproc2(p, &ki, false);
+
+	mutex_exit(p->p_lock);
+	mutex_exit(proc_lock);
 
 	uvmspace_free(vm);
 
+	len = snprintf(bf, LBFSZ,
+	"%lu %lu %lu %lu %lu %lu %lu\n",
+		(unsigned long)(ki.p_vm_msize),	/* size */
+		(unsigned long)(ki.p_vm_rssize),/* resident */
+		(unsigned long)(ki.p_uru_ixrss),/* shared */
+		(unsigned long)(ki.p_vm_tsize),	/* text */
+		(unsigned long) 0,		/* library (unused) */
+		(unsigned long)(ki.p_vm_dsize + ki.p_vm_ssize),	/* data+stack */
+		(unsigned long) 0);		/* dirty */
+
 	if (len == 0)
 		goto out;
 



CVS commit: src/sys/miscfs/specfs

2016-03-26 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Mar 26 14:58:13 UTC 2016

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
Whhen spec_strategy() extracts v_rdev take care to avoid a
race with spec_revoke.

Fixes PR kern/50467 Panic from disconnecting phone while reading its contents


To generate a diff of this commit:
cvs rdiff -u -r1.160 -r1.161 src/sys/miscfs/specfs/spec_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/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.160 src/sys/miscfs/specfs/spec_vnops.c:1.161
--- src/sys/miscfs/specfs/spec_vnops.c:1.160	Tue Jan  5 09:07:19 2016
+++ src/sys/miscfs/specfs/spec_vnops.c	Sat Mar 26 14:58:13 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.160 2016/01/05 09:07:19 pgoyette Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.161 2016/03/26 14:58:13 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.160 2016/01/05 09:07:19 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.161 2016/03/26 14:58:13 hannken Exp $");
 
 #include 
 #include 
@@ -1029,26 +1029,45 @@ spec_strategy(void *v)
 	} */ *ap = v;
 	struct vnode *vp = ap->a_vp;
 	struct buf *bp = ap->a_bp;
+	dev_t dev;
 	int error;
 
-	KASSERT(vp == vp->v_specnode->sn_dev->sd_bdevvp);
+	dev = NODEV;
 
-	error = 0;
-	bp->b_dev = vp->v_rdev;
+	/*
+	 * Extract all the info we need from the vnode, taking care to
+	 * avoid a race with VOP_REVOKE().
+	 */
 
-	if (!(bp->b_flags & B_READ))
-		error = fscow_run(bp, false);
+	mutex_enter(vp->v_interlock);
+	if (vdead_check(vp, VDEAD_NOWAIT) == 0 && vp->v_specnode != NULL) {
+		dev = vp->v_rdev;
+	}
+	mutex_exit(vp->v_interlock);
 
-	if (error) {
-		bp->b_error = error;
-		bp->b_resid = bp->b_bcount;
-		biodone(bp);
-		return (error);
+	if (dev == NODEV) {
+		error = ENXIO;
+		goto out;
 	}
+	bp->b_dev = dev;
 
+	KASSERT(vp == vp->v_specnode->sn_dev->sd_bdevvp);
+
+	if (!(bp->b_flags & B_READ)) {
+		error = fscow_run(bp, false);
+		if (error)
+			goto out;
+	}
 	bdev_strategy(bp);
 
-	return (0);
+	return 0;
+
+out:
+	bp->b_error = error;
+	bp->b_resid = bp->b_bcount;
+	biodone(bp);
+
+	return error;
 }
 
 int



CVS commit: src/sys/miscfs/specfs

2016-01-05 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Tue Jan  5 09:07:19 UTC 2016

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
Fix a couple of checks for kernel vm_space, and convert the 'naked
panic" code to KASSERT/KASSERTMSG.

Thanks,  Taylor!


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/sys/miscfs/specfs/spec_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/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.159 src/sys/miscfs/specfs/spec_vnops.c:1.160
--- src/sys/miscfs/specfs/spec_vnops.c:1.159	Wed Dec 23 00:13:57 2015
+++ src/sys/miscfs/specfs/spec_vnops.c	Tue Jan  5 09:07:19 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.159 2015/12/23 00:13:57 pgoyette Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.160 2016/01/05 09:07:19 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.159 2015/12/23 00:13:57 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.160 2016/01/05 09:07:19 pgoyette Exp $");
 
 #include 
 #include 
@@ -690,13 +690,11 @@ spec_read(void *v)
 	int n, on;
 	int error = 0;
 
-#ifdef DIAGNOSTIC
-	if (uio->uio_rw != UIO_READ)
-		panic("spec_read mode");
-	if (&uio->uio_vmspace->vm_map != kernel_map &&
-	uio->uio_vmspace != curproc->p_vmspace)
-		panic("spec_read proc");
-#endif
+	KASSERT(uio->uio_rw == UIO_READ);
+	KASSERTMSG(VMSPACE_IS_KERNEL_P(uio->uio_vmspace) ||
+		   uio->uio_vmspace == curproc->p_vmspace,
+		"vmspace belongs to neither kernel nor curproc");
+
 	if (uio->uio_resid == 0)
 		return (0);
 
@@ -762,13 +760,10 @@ spec_write(void *v)
 	int n, on;
 	int error = 0;
 
-#ifdef DIAGNOSTIC
-	if (uio->uio_rw != UIO_WRITE)
-		panic("spec_write mode");
-	if (&uio->uio_vmspace->vm_map != kernel_map &&
-	uio->uio_vmspace != curproc->p_vmspace)
-		panic("spec_write proc");
-#endif
+	KASSERT(uio->uio_rw == UIO_WRITE);
+	KASSERTMSG(VMSPACE_IS_KERNEL_P(uio->uio_vmspace) ||
+		   uio->uio_vmspace == curproc->p_vmspace,
+		"vmspace belongs to neither kernel nor curproc");
 
 	switch (vp->v_type) {
 



CVS commit: src/sys/miscfs/specfs

2015-12-22 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Dec 23 00:13:57 UTC 2015

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
Revert previous


To generate a diff of this commit:
cvs rdiff -u -r1.158 -r1.159 src/sys/miscfs/specfs/spec_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/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.158 src/sys/miscfs/specfs/spec_vnops.c:1.159
--- src/sys/miscfs/specfs/spec_vnops.c:1.158	Tue Dec 22 23:54:37 2015
+++ src/sys/miscfs/specfs/spec_vnops.c	Wed Dec 23 00:13:57 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.158 2015/12/22 23:54:37 pgoyette Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.159 2015/12/23 00:13:57 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.158 2015/12/22 23:54:37 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.159 2015/12/23 00:13:57 pgoyette Exp $");
 
 #include 
 #include 
@@ -573,12 +573,7 @@ spec_open(void *v)
 break;
 			
 			/* Try to autoload device module */
-			error = module_autoload(name, MODULE_CLASS_DRIVER);
-			if (error != 0) {
-error = ENXIO;
-break;
-			}
-
+			(void) module_autoload(name, MODULE_CLASS_DRIVER);
 		} while (gen != module_gen);
 
 		vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
@@ -629,15 +624,9 @@ spec_open(void *v)
 			VOP_UNLOCK(vp);
 
 /* Try to autoload device module */
-			error = module_autoload(name, MODULE_CLASS_DRIVER);
-
-			vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
-
-			if (error != 0) {
-error = ENXIO;
-break;
-			}
+			(void) module_autoload(name, MODULE_CLASS_DRIVER);
 			
+			vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 		} while (gen != module_gen);
 
 		break;



CVS commit: src/sys/miscfs/specfs

2015-12-22 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Tue Dec 22 23:54:37 UTC 2015

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
If we attempt to autoload a driver module, make sure we return an error
if it fails.  Otherwise we might end up calling a builtin-but-disabled
driver module and that can generate all sorts of issues...


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/sys/miscfs/specfs/spec_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/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.157 src/sys/miscfs/specfs/spec_vnops.c:1.158
--- src/sys/miscfs/specfs/spec_vnops.c:1.157	Tue Dec  8 20:36:15 2015
+++ src/sys/miscfs/specfs/spec_vnops.c	Tue Dec 22 23:54:37 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.157 2015/12/08 20:36:15 christos Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.158 2015/12/22 23:54:37 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.157 2015/12/08 20:36:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.158 2015/12/22 23:54:37 pgoyette Exp $");
 
 #include 
 #include 
@@ -573,7 +573,12 @@ spec_open(void *v)
 break;
 			
 			/* Try to autoload device module */
-			(void) module_autoload(name, MODULE_CLASS_DRIVER);
+			error = module_autoload(name, MODULE_CLASS_DRIVER);
+			if (error != 0) {
+error = ENXIO;
+break;
+			}
+
 		} while (gen != module_gen);
 
 		vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
@@ -624,9 +629,15 @@ spec_open(void *v)
 			VOP_UNLOCK(vp);
 
 /* Try to autoload device module */
-			(void) module_autoload(name, MODULE_CLASS_DRIVER);
-			
+			error = module_autoload(name, MODULE_CLASS_DRIVER);
+
 			vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+
+			if (error != 0) {
+error = ENXIO;
+break;
+			}
+			
 		} while (gen != module_gen);
 
 		break;



CVS commit: src/sys/miscfs/specfs

2015-12-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec  8 01:57:14 UTC 2015

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
unfortunately it is not that easy to get rid of DIOCGPART. DTRT for the
raw partition and print a warning if we overflowed. I guess the right solution
for this is to create yet another version of disklabel that is 64 bit friendly.


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 src/sys/miscfs/specfs/spec_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/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.155 src/sys/miscfs/specfs/spec_vnops.c:1.156
--- src/sys/miscfs/specfs/spec_vnops.c:1.155	Sat Dec  5 02:59:34 2015
+++ src/sys/miscfs/specfs/spec_vnops.c	Mon Dec  7 20:57:13 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.155 2015/12/05 07:59:34 jnemeth Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.156 2015/12/08 01:57:13 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.155 2015/12/05 07:59:34 jnemeth Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.156 2015/12/08 01:57:13 christos Exp $");
 
 #include 
 #include 
@@ -661,15 +661,24 @@ spec_open(void *v)
 	
 	ioctl = vp->v_type == VCHR ? cdev_ioctl : bdev_ioctl;
 
-	error = (*ioctl)(vp->v_rdev, DIOCGMEDIASIZE, &off, FREAD, curlwp);
+	// XXX: DIOCGPART is not 64 bit friendly so we avoid it fot the
+	// raw partition
+	if (DISKPART(vp->v_rdev) == RAW_PART)
+		error = (*ioctl)(vp->v_rdev, DIOCGMEDIASIZE,
+		&off, FREAD, curlwp);
+	else
+		error = EINVAL;
 	if (error) {
 		struct partinfo pi;
-#ifdef DIAGNOSTIC
-		printf("ioctl DIOCGMEDIASIZE failed %d\n", error);
-#endif
 		error = (*ioctl)(vp->v_rdev, DIOCGPART, &pi, FREAD, curlwp);
-		if (error == 0)
+		if (error == 0) {
 			off = (off_t)pi.disklab->d_secsize * pi.part->p_size;
+#ifdef DIAGNOSTIC
+			if (pi.disklab->d_secsize == UINT_MAX)
+printf("overflow in DIOCGPART dev=%jx\n",
+(uintmax_t)vp->v_rdev);
+#endif
+		}
 	}
 
 	if (error == 0)



CVS commit: src/sys/miscfs/specfs

2015-12-05 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Sat Dec  5 07:59:34 UTC 2015

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
messing with uninitialized structs is a bad thing


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/sys/miscfs/specfs/spec_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/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.154 src/sys/miscfs/specfs/spec_vnops.c:1.155
--- src/sys/miscfs/specfs/spec_vnops.c:1.154	Fri Dec  4 23:54:06 2015
+++ src/sys/miscfs/specfs/spec_vnops.c	Sat Dec  5 07:59:34 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.154 2015/12/04 23:54:06 christos Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.155 2015/12/05 07:59:34 jnemeth Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.154 2015/12/04 23:54:06 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.155 2015/12/05 07:59:34 jnemeth Exp $");
 
 #include 
 #include 
@@ -668,7 +668,8 @@ spec_open(void *v)
 		printf("ioctl DIOCGMEDIASIZE failed %d\n", error);
 #endif
 		error = (*ioctl)(vp->v_rdev, DIOCGPART, &pi, FREAD, curlwp);
-		off = (off_t)pi.disklab->d_secsize * pi.part->p_size;
+		if (error == 0)
+			off = (off_t)pi.disklab->d_secsize * pi.part->p_size;
 	}
 
 	if (error == 0)



CVS commit: src/sys/miscfs/specfs

2015-12-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec  4 23:54:06 UTC 2015

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
Use DIOCGMEDIASIZE instead of DIOCGPART so that we are not limited to 2G.
XXX: All DIOCGPART code needs to be removed...
XXX: pullup-7


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/sys/miscfs/specfs/spec_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/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.153 src/sys/miscfs/specfs/spec_vnops.c:1.154
--- src/sys/miscfs/specfs/spec_vnops.c:1.153	Wed Jul  1 04:13:52 2015
+++ src/sys/miscfs/specfs/spec_vnops.c	Fri Dec  4 18:54:06 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.153 2015/07/01 08:13:52 hannken Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.154 2015/12/04 23:54:06 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.153 2015/07/01 08:13:52 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.154 2015/12/04 23:54:06 christos Exp $");
 
 #include 
 #include 
@@ -480,6 +480,8 @@ spec_lookup(void *v)
 	return (ENOTDIR);
 }
 
+typedef int (*spec_ioctl_t)(dev_t, u_long, void *, int, struct lwp *);
+
 /*
  * Open a special file.
  */
@@ -496,11 +498,11 @@ spec_open(void *v)
 	struct vnode *vp;
 	dev_t dev;
 	int error;
-	struct partinfo pi;
 	enum kauth_device_req req;
 	specnode_t *sn;
 	specdev_t *sd;
-
+	spec_ioctl_t ioctl;
+	off_t off;
 	u_int gen;
 	const char *name;
 	
@@ -656,13 +658,22 @@ spec_open(void *v)
 	if (cdev_type(dev) != D_DISK || error != 0)
 		return error;
 
-	if (vp->v_type == VCHR)
-		error = cdev_ioctl(vp->v_rdev, DIOCGPART, &pi, FREAD, curlwp);
-	else
-		error = bdev_ioctl(vp->v_rdev, DIOCGPART, &pi, FREAD, curlwp);
+	
+	ioctl = vp->v_type == VCHR ? cdev_ioctl : bdev_ioctl;
+
+	error = (*ioctl)(vp->v_rdev, DIOCGMEDIASIZE, &off, FREAD, curlwp);
+	if (error) {
+		struct partinfo pi;
+#ifdef DIAGNOSTIC
+		printf("ioctl DIOCGMEDIASIZE failed %d\n", error);
+#endif
+		error = (*ioctl)(vp->v_rdev, DIOCGPART, &pi, FREAD, curlwp);
+		off = (off_t)pi.disklab->d_secsize * pi.part->p_size;
+	}
+
 	if (error == 0)
-		uvm_vnp_setsize(vp,
-		(voff_t)pi.disklab->d_secsize * pi.part->p_size);
+		uvm_vnp_setsize(vp, (voff_t)off);
+
 	return 0;
 }
 



CVS commit: src/sys/miscfs

2015-07-01 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jul  1 08:13:53 UTC 2015

Modified Files:
src/sys/miscfs/deadfs: dead_vfsops.c
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
Unfortunately MFS uses v_data of its anonymous device vnode so
it cannot be used as vcache key.  Use v_interlock as key ...


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/miscfs/deadfs/dead_vfsops.c
cvs rdiff -u -r1.152 -r1.153 src/sys/miscfs/specfs/spec_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/deadfs/dead_vfsops.c
diff -u src/sys/miscfs/deadfs/dead_vfsops.c:1.6 src/sys/miscfs/deadfs/dead_vfsops.c:1.7
--- src/sys/miscfs/deadfs/dead_vfsops.c:1.6	Tue Jun 30 06:19:22 2015
+++ src/sys/miscfs/deadfs/dead_vfsops.c	Wed Jul  1 08:13:53 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: dead_vfsops.c,v 1.6 2015/06/30 06:19:22 hannken Exp $	*/
+/*	$NetBSD: dead_vfsops.c,v 1.7 2015/07/01 08:13:53 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dead_vfsops.c,v 1.6 2015/06/30 06:19:22 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dead_vfsops.c,v 1.7 2015/07/01 08:13:53 hannken Exp $");
 
 #include 
 #include 
@@ -108,9 +108,8 @@ dead_newvnode(struct mount *mp, struct v
 	uvm_vnp_setsize(vp, 0);
 	spec_node_init(vp, vap->va_rdev);
 
-	vp->v_data = vp;
-	*key_len = sizeof(vp->v_data);
-	*new_key = &vp->v_data;
+	*key_len = sizeof(vp->v_interlock);
+	*new_key = &vp->v_interlock;
 
 	return 0;
 }

Index: src/sys/miscfs/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.152 src/sys/miscfs/specfs/spec_vnops.c:1.153
--- src/sys/miscfs/specfs/spec_vnops.c:1.152	Tue Jun 30 06:19:21 2015
+++ src/sys/miscfs/specfs/spec_vnops.c	Wed Jul  1 08:13:52 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.152 2015/06/30 06:19:21 hannken Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.153 2015/07/01 08:13:52 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.152 2015/06/30 06:19:21 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.153 2015/07/01 08:13:52 hannken Exp $");
 
 #include 
 #include 
@@ -1097,8 +1097,7 @@ spec_reclaim(void *v)
 	struct vnode *vp = ap->a_vp;
 
 	KASSERT(vp->v_mount == dead_rootmount);
-	vcache_remove(vp->v_mount, &vp->v_data, sizeof(vp->v_data));
-	vp->v_data = NULL;
+	vcache_remove(vp->v_mount, &vp->v_interlock, sizeof(vp->v_interlock));
 	return 0;
 }
 



CVS commit: src/sys/miscfs

2015-06-29 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jun 30 06:19:22 UTC 2015

Modified Files:
src/sys/miscfs/deadfs: dead_vfsops.c
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
Redo previous again, v_specnode is invariant but not unique.

Set "vp->v_data = vp" and use v_data as key.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/miscfs/deadfs/dead_vfsops.c
cvs rdiff -u -r1.151 -r1.152 src/sys/miscfs/specfs/spec_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/deadfs/dead_vfsops.c
diff -u src/sys/miscfs/deadfs/dead_vfsops.c:1.5 src/sys/miscfs/deadfs/dead_vfsops.c:1.6
--- src/sys/miscfs/deadfs/dead_vfsops.c:1.5	Mon Jun 29 16:48:20 2015
+++ src/sys/miscfs/deadfs/dead_vfsops.c	Tue Jun 30 06:19:22 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: dead_vfsops.c,v 1.5 2015/06/29 16:48:20 hannken Exp $	*/
+/*	$NetBSD: dead_vfsops.c,v 1.6 2015/06/30 06:19:22 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dead_vfsops.c,v 1.5 2015/06/29 16:48:20 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dead_vfsops.c,v 1.6 2015/06/30 06:19:22 hannken Exp $");
 
 #include 
 #include 
@@ -108,8 +108,9 @@ dead_newvnode(struct mount *mp, struct v
 	uvm_vnp_setsize(vp, 0);
 	spec_node_init(vp, vap->va_rdev);
 
-	*key_len = sizeof(vp->v_specnode);
-	*new_key = &vp->v_specnode;
+	vp->v_data = vp;
+	*key_len = sizeof(vp->v_data);
+	*new_key = &vp->v_data;
 
 	return 0;
 }

Index: src/sys/miscfs/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.151 src/sys/miscfs/specfs/spec_vnops.c:1.152
--- src/sys/miscfs/specfs/spec_vnops.c:1.151	Mon Jun 29 16:48:20 2015
+++ src/sys/miscfs/specfs/spec_vnops.c	Tue Jun 30 06:19:21 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.151 2015/06/29 16:48:20 hannken Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.152 2015/06/30 06:19:21 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.151 2015/06/29 16:48:20 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.152 2015/06/30 06:19:21 hannken Exp $");
 
 #include 
 #include 
@@ -1097,7 +1097,8 @@ spec_reclaim(void *v)
 	struct vnode *vp = ap->a_vp;
 
 	KASSERT(vp->v_mount == dead_rootmount);
-	vcache_remove(vp->v_mount, &vp->v_specnode, sizeof(vp->v_specnode));
+	vcache_remove(vp->v_mount, &vp->v_data, sizeof(vp->v_data));
+	vp->v_data = NULL;
 	return 0;
 }
 



CVS commit: src/sys/miscfs

2015-06-29 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Jun 29 16:48:20 UTC 2015

Modified Files:
src/sys/miscfs/deadfs: dead_vfsops.c
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
Use the address of vp->v_specnode as vcache key.  It is invariant
over the lifetime of the vnode.

The previous worked by luck, it took the first sizeof(void *) bytes
of struct vnode as key.

Resolves CID 1308957: wrong sizeof()


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/miscfs/deadfs/dead_vfsops.c
cvs rdiff -u -r1.150 -r1.151 src/sys/miscfs/specfs/spec_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/deadfs/dead_vfsops.c
diff -u src/sys/miscfs/deadfs/dead_vfsops.c:1.4 src/sys/miscfs/deadfs/dead_vfsops.c:1.5
--- src/sys/miscfs/deadfs/dead_vfsops.c:1.4	Tue Jun 23 10:42:34 2015
+++ src/sys/miscfs/deadfs/dead_vfsops.c	Mon Jun 29 16:48:20 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: dead_vfsops.c,v 1.4 2015/06/23 10:42:34 hannken Exp $	*/
+/*	$NetBSD: dead_vfsops.c,v 1.5 2015/06/29 16:48:20 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dead_vfsops.c,v 1.4 2015/06/23 10:42:34 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dead_vfsops.c,v 1.5 2015/06/29 16:48:20 hannken Exp $");
 
 #include 
 #include 
@@ -108,8 +108,8 @@ dead_newvnode(struct mount *mp, struct v
 	uvm_vnp_setsize(vp, 0);
 	spec_node_init(vp, vap->va_rdev);
 
-	*key_len = sizeof(struct vnode *);
-	*new_key = vp;
+	*key_len = sizeof(vp->v_specnode);
+	*new_key = &vp->v_specnode;
 
 	return 0;
 }

Index: src/sys/miscfs/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.150 src/sys/miscfs/specfs/spec_vnops.c:1.151
--- src/sys/miscfs/specfs/spec_vnops.c:1.150	Mon Jun 29 16:25:49 2015
+++ src/sys/miscfs/specfs/spec_vnops.c	Mon Jun 29 16:48:20 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.150 2015/06/29 16:25:49 christos Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.151 2015/06/29 16:48:20 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.150 2015/06/29 16:25:49 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.151 2015/06/29 16:48:20 hannken Exp $");
 
 #include 
 #include 
@@ -1097,12 +1097,7 @@ spec_reclaim(void *v)
 	struct vnode *vp = ap->a_vp;
 
 	KASSERT(vp->v_mount == dead_rootmount);
-	/*
-	 * The key is the pointer itself, see:
-	 * miscfs/deadfs/dead_vfsops::dead_newvnode()
-	 * coverity[sizeof_mismatch]
-	 */
-	vcache_remove(vp->v_mount, vp, sizeof(struct vnode *));
+	vcache_remove(vp->v_mount, &vp->v_specnode, sizeof(vp->v_specnode));
 	return 0;
 }
 



CVS commit: src/sys/miscfs/specfs

2015-06-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 29 16:25:49 UTC 2015

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
Revert previous, and explain why.


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/sys/miscfs/specfs/spec_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/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.149 src/sys/miscfs/specfs/spec_vnops.c:1.150
--- src/sys/miscfs/specfs/spec_vnops.c:1.149	Mon Jun 29 11:39:40 2015
+++ src/sys/miscfs/specfs/spec_vnops.c	Mon Jun 29 12:25:49 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.149 2015/06/29 15:39:40 christos Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.150 2015/06/29 16:25:49 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.149 2015/06/29 15:39:40 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.150 2015/06/29 16:25:49 christos Exp $");
 
 #include 
 #include 
@@ -1097,7 +1097,12 @@ spec_reclaim(void *v)
 	struct vnode *vp = ap->a_vp;
 
 	KASSERT(vp->v_mount == dead_rootmount);
-	vcache_remove(vp->v_mount, vp, sizeof(*vp));
+	/*
+	 * The key is the pointer itself, see:
+	 * miscfs/deadfs/dead_vfsops::dead_newvnode()
+	 * coverity[sizeof_mismatch]
+	 */
+	vcache_remove(vp->v_mount, vp, sizeof(struct vnode *));
 	return 0;
 }
 



CVS commit: src/sys/miscfs/specfs

2015-06-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 29 15:39:40 UTC 2015

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c

Log Message:
CID 1308957: Fix wrong sizeof()


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 src/sys/miscfs/specfs/spec_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/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.148 src/sys/miscfs/specfs/spec_vnops.c:1.149
--- src/sys/miscfs/specfs/spec_vnops.c:1.148	Tue Jun 23 06:42:34 2015
+++ src/sys/miscfs/specfs/spec_vnops.c	Mon Jun 29 11:39:40 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.148 2015/06/23 10:42:34 hannken Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.149 2015/06/29 15:39:40 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.148 2015/06/23 10:42:34 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.149 2015/06/29 15:39:40 christos Exp $");
 
 #include 
 #include 
@@ -1097,7 +1097,7 @@ spec_reclaim(void *v)
 	struct vnode *vp = ap->a_vp;
 
 	KASSERT(vp->v_mount == dead_rootmount);
-	vcache_remove(vp->v_mount, vp, sizeof(vp));
+	vcache_remove(vp->v_mount, vp, sizeof(*vp));
 	return 0;
 }
 



CVS commit: src/sys/miscfs/deadfs

2015-04-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Apr 20 23:30:58 UTC 2015

Modified Files:
src/sys/miscfs/deadfs: dead_vnops.c

Log Message:
Uncomment the argument struct declarations in deadfs.

We don't actually use them, but this is the only way the vop
versioning mechanism flags code that needs changing.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/miscfs/deadfs/dead_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/deadfs/dead_vnops.c
diff -u src/sys/miscfs/deadfs/dead_vnops.c:1.58 src/sys/miscfs/deadfs/dead_vnops.c:1.59
--- src/sys/miscfs/deadfs/dead_vnops.c:1.58	Mon Apr 20 23:03:08 2015
+++ src/sys/miscfs/deadfs/dead_vnops.c	Mon Apr 20 23:30:58 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: dead_vnops.c,v 1.58 2015/04/20 23:03:08 riastradh Exp $	*/
+/*	$NetBSD: dead_vnops.c,v 1.59 2015/04/20 23:30:58 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dead_vnops.c,v 1.58 2015/04/20 23:03:08 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dead_vnops.c,v 1.59 2015/04/20 23:30:58 riastradh Exp $");
 
 #include 
 #include 
@@ -122,17 +122,18 @@ dead_default_error(void *v)
 	return EBADF;
 }
 
-/* ARGSUSED */
 int
 dead_bmap(void *v)
 {
-	/* struct vop_bmap_args {
+	struct vop_bmap_args /* {
 		struct vnode *a_vp;
 		daddr_t  a_bn;
 		struct vnode **a_vpp;
 		daddr_t *a_bnp;
 		int *a_runp;
-	} *ap = v; */
+	} */ *ap = v;
+
+	(void)ap;
 
 	return (EIO);
 }
@@ -151,15 +152,16 @@ dead_lookup(void *v)
 	return ENOENT;
 }
 
-/* ARGSUSED */
 int
 dead_open(void *v)
 {
-	/* struct vop_open_args {
+	struct vop_open_args /* {
 		struct vnode *a_vp;
 		int a_mode;
 		kauth_cred_t a_cred;
-	} *ap = v; */
+	} */ *ap = v;
+
+	(void)ap;
 
 	return (ENXIO);
 }
@@ -182,32 +184,34 @@ dead_read(void *v)
 	return (0);
 }
 
-/* ARGSUSED */
 int
 dead_write(void *v)
 {
-	/* struct vop_write_args {
+	struct vop_write_args /* {
 		struct vnode *a_vp;
 		struct uio *a_uio;
 		int  a_ioflag;
 		kauth_cred_t a_cred;
-	} *ap = v; */
+	} */ *ap = v;
+
+	(void)ap;
 
 	return (EIO);
 }
 
-/* ARGSUSED */
 int
 dead_ioctl(void *v)
 {
-	/* struct vop_ioctl_args {
+	struct vop_ioctl_args /* {
 		struct vnode *a_vp;
 		u_long a_command;
 		void *a_data;
 		int  a_fflag;
 		kauth_cred_t a_cred;
 		struct lwp *a_l;
-	} *ap = v; */
+	} */ *ap = v;
+
+	(void)ap;
 
 	return (EBADF);
 }
@@ -356,7 +360,7 @@ int
 dead_putpages(void *v)
 {
 struct vop_putpages_args /* {
-	struct vnode *a_vp;
+		struct vnode *a_vp;
 		voff_t a_offlo;
 		voff_t a_offhi;
 		int a_flags;



CVS commit: src/sys/miscfs/genfs

2015-04-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Apr 12 14:44:06 UTC 2015

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
Fix UVMHIST build.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/miscfs/genfs/genfs_io.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/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.59 src/sys/miscfs/genfs/genfs_io.c:1.60
--- src/sys/miscfs/genfs/genfs_io.c:1.59	Fri Apr 10 13:02:15 2015
+++ src/sys/miscfs/genfs/genfs_io.c	Sun Apr 12 14:44:06 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.59 2015/04/10 13:02:15 riastradh Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.60 2015/04/12 14:44:06 skrll Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.59 2015/04/10 13:02:15 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.60 2015/04/12 14:44:06 skrll Exp $");
 
 #include 
 #include 
@@ -521,6 +521,8 @@ genfs_getpages_read(struct vnode *vp, st
 	int i;
 	int error = 0;
 
+	UVMHIST_FUNC(__func__); UVMHIST_CALLED(ubchist);
+
 	/*
 	 * read the desired page(s).
 	 */



CVS commit: src/sys/miscfs

2014-11-09 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Nov  9 18:08:07 UTC 2014

Modified Files:
src/sys/miscfs/fdesc: fdesc_vfsops.c
src/sys/miscfs/genfs: layer_subr.c layer_vfsops.c
src/sys/miscfs/nullfs: null_vfsops.c
src/sys/miscfs/umapfs: umap_subr.c umap_vfsops.c umap_vnops.c

Log Message:
Do not uselessly include .


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/miscfs/fdesc/fdesc_vfsops.c
cvs rdiff -u -r1.36 -r1.37 src/sys/miscfs/genfs/layer_subr.c
cvs rdiff -u -r1.44 -r1.45 src/sys/miscfs/genfs/layer_vfsops.c
cvs rdiff -u -r1.89 -r1.90 src/sys/miscfs/nullfs/null_vfsops.c
cvs rdiff -u -r1.28 -r1.29 src/sys/miscfs/umapfs/umap_subr.c
cvs rdiff -u -r1.94 -r1.95 src/sys/miscfs/umapfs/umap_vfsops.c
cvs rdiff -u -r1.56 -r1.57 src/sys/miscfs/umapfs/umap_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/fdesc/fdesc_vfsops.c
diff -u src/sys/miscfs/fdesc/fdesc_vfsops.c:1.90 src/sys/miscfs/fdesc/fdesc_vfsops.c:1.91
--- src/sys/miscfs/fdesc/fdesc_vfsops.c:1.90	Thu Sep  4 00:30:25 2014
+++ src/sys/miscfs/fdesc/fdesc_vfsops.c	Sun Nov  9 18:08:06 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdesc_vfsops.c,v 1.90 2014/09/04 00:30:25 christos Exp $	*/
+/*	$NetBSD: fdesc_vfsops.c,v 1.91 2014/11/09 18:08:06 maxv Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993, 1995
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdesc_vfsops.c,v 1.90 2014/09/04 00:30:25 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdesc_vfsops.c,v 1.91 2014/11/09 18:08:06 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -58,7 +58,6 @@ __KERNEL_RCSID(0, "$NetBSD: fdesc_vfsops
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 

Index: src/sys/miscfs/genfs/layer_subr.c
diff -u src/sys/miscfs/genfs/layer_subr.c:1.36 src/sys/miscfs/genfs/layer_subr.c:1.37
--- src/sys/miscfs/genfs/layer_subr.c:1.36	Sun May 25 13:51:25 2014
+++ src/sys/miscfs/genfs/layer_subr.c	Sun Nov  9 18:08:07 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: layer_subr.c,v 1.36 2014/05/25 13:51:25 hannken Exp $	*/
+/*	$NetBSD: layer_subr.c,v 1.37 2014/11/09 18:08:07 maxv Exp $	*/
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: layer_subr.c,v 1.36 2014/05/25 13:51:25 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: layer_subr.c,v 1.37 2014/11/09 18:08:07 maxv Exp $");
 
 #include 
 #include 
@@ -79,7 +79,6 @@ __KERNEL_RCSID(0, "$NetBSD: layer_subr.c
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 

Index: src/sys/miscfs/genfs/layer_vfsops.c
diff -u src/sys/miscfs/genfs/layer_vfsops.c:1.44 src/sys/miscfs/genfs/layer_vfsops.c:1.45
--- src/sys/miscfs/genfs/layer_vfsops.c:1.44	Sun May 25 13:51:25 2014
+++ src/sys/miscfs/genfs/layer_vfsops.c	Sun Nov  9 18:08:07 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: layer_vfsops.c,v 1.44 2014/05/25 13:51:25 hannken Exp $	*/
+/*	$NetBSD: layer_vfsops.c,v 1.45 2014/11/09 18:08:07 maxv Exp $	*/
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -74,7 +74,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.44 2014/05/25 13:51:25 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.45 2014/11/09 18:08:07 maxv Exp $");
 
 #include 
 #include 
@@ -82,7 +82,6 @@ __KERNEL_RCSID(0, "$NetBSD: layer_vfsops
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 

Index: src/sys/miscfs/nullfs/null_vfsops.c
diff -u src/sys/miscfs/nullfs/null_vfsops.c:1.89 src/sys/miscfs/nullfs/null_vfsops.c:1.90
--- src/sys/miscfs/nullfs/null_vfsops.c:1.89	Sun May 25 13:51:25 2014
+++ src/sys/miscfs/nullfs/null_vfsops.c	Sun Nov  9 18:08:07 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: null_vfsops.c,v 1.89 2014/05/25 13:51:25 hannken Exp $	*/
+/*	$NetBSD: null_vfsops.c,v 1.90 2014/11/09 18:08:07 maxv Exp $	*/
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: null_vfsops.c,v 1.89 2014/05/25 13:51:25 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: null_vfsops.c,v 1.90 2014/11/09 18:08:07 maxv Exp $");
 
 #include 
 #include 
@@ -84,7 +84,6 @@ __KERNEL_RCSID(0, "$NetBSD: null_vfsops.
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 

Index: src/sys/miscfs/umapfs/umap_subr.c
diff -u src/sys/miscfs/umapfs/umap_subr.c:1.28 src/sys/miscfs/umapfs/umap_subr.c:1.29
--- src/sys/miscfs/umapfs/umap_subr.c:1.28	Sun Mar 15 17:22:38 2009
+++ src/sys/miscfs/umapfs/umap_subr.c	Sun Nov  9 18:08:07 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: umap_subr.c,v 1.28 2009/03/15 17:22:38 cegger Exp $	*/
+/*	$NetBSD: umap_subr.c,v 1.29 2014/11/09 18:08:07 maxv Exp $	*/
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: umap_subr.c,v 1.28 2009/03/15 17:22:38 cegger Exp $");
+__KERNEL_RCS

CVS commit: src/sys/miscfs/procfs

2014-10-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct 17 20:49:22 UTC 2014

Modified Files:
src/sys/miscfs/procfs: procfs_map.c

Log Message:
Maps don't change that frequently between reads, so don't give up and
do what linux does (support reading from an offset).


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/miscfs/procfs/procfs_map.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/procfs/procfs_map.c
diff -u src/sys/miscfs/procfs/procfs_map.c:1.44 src/sys/miscfs/procfs/procfs_map.c:1.45
--- src/sys/miscfs/procfs/procfs_map.c:1.44	Tue Mar 18 14:20:43 2014
+++ src/sys/miscfs/procfs/procfs_map.c	Fri Oct 17 16:49:22 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_map.c,v 1.44 2014/03/18 18:20:43 riastradh Exp $	*/
+/*	$NetBSD: procfs_map.c,v 1.45 2014/10/17 20:49:22 christos Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_map.c,v 1.44 2014/03/18 18:20:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_map.c,v 1.45 2014/10/17 20:49:22 christos Exp $");
 
 #include 
 #include 
@@ -126,15 +126,6 @@ procfs_domap(struct lwp *curl, struct pr
 	if (uio->uio_rw != UIO_READ)
 		return EOPNOTSUPP;
 
-	if (uio->uio_offset != 0) {
-		/*
-		 * we return 0 here, so that the second read returns EOF
-		 * we don't support reading from an offset because the
-		 * map could have changed between the two reads.
-		 */
-		return 0;
-	}
-
 	error = 0;
 
 	if (linuxmode != 0)
@@ -220,7 +211,16 @@ again:
 	vm_map_unlock_read(map);
 	uvmspace_free(vm);
 
-	error = uiomove(buffer, pos, uio);
+	/*
+	 * We support reading from an offset, because linux does.
+	 * The map could have changed between the two reads, and
+	 * that could result in junk, but typically it does not.
+	 */
+	if (uio->uio_offset < pos)
+		error = uiomove(buffer + uio->uio_offset,
+		pos - uio->uio_offset, uio);
+	else
+		error = 0;
 out:
 	if (path != NULL)
 		free(path, M_TEMP);



CVS commit: src/sys/miscfs/fdesc

2014-09-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep  5 10:43:26 UTC 2014

Modified Files:
src/sys/miscfs/fdesc: fdesc_vnops.c

Log Message:
The comment about toxicity was correct, restore VNON setting code and
then set the proper type in lookup.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/sys/miscfs/fdesc/fdesc_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/fdesc/fdesc_vnops.c
diff -u src/sys/miscfs/fdesc/fdesc_vnops.c:1.124 src/sys/miscfs/fdesc/fdesc_vnops.c:1.125
--- src/sys/miscfs/fdesc/fdesc_vnops.c:1.124	Fri Sep  5 05:26:16 2014
+++ src/sys/miscfs/fdesc/fdesc_vnops.c	Fri Sep  5 06:43:26 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdesc_vnops.c,v 1.124 2014/09/05 09:26:16 matt Exp $	*/
+/*	$NetBSD: fdesc_vnops.c,v 1.125 2014/09/05 10:43:26 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.124 2014/09/05 09:26:16 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.125 2014/09/05 10:43:26 christos Exp $");
 
 #include 
 #include 
@@ -295,6 +295,8 @@ bad:
 good:
 	KASSERT(ix != -1);
 	error = vcache_get(dvp->v_mount, &ix, sizeof(ix), vpp);
+	if (error == 0 && ix == FD_CTTY)
+		(*vpp)->v_type = VCHR;
 	return error;
 }
 
@@ -838,7 +840,6 @@ fdesc_inactive(void *v)
 		struct vnode *a_vp;
 	} */ *ap = v;
 	struct vnode *vp = ap->a_vp;
-#if 0
 	struct fdescnode *fd = VTOFDESC(vp);
 
 	/*
@@ -847,7 +848,6 @@ fdesc_inactive(void *v)
 	 */
 	if (fd->fd_type == Fctty || fd->fd_type == Fdesc)
 		vp->v_type = VNON;
-#endif
 	VOP_UNLOCK(vp);
 	return (0);
 }



CVS commit: src/sys/miscfs/fdesc

2014-09-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Sep  4 13:29:50 UTC 2014

Modified Files:
src/sys/miscfs/fdesc: fdesc_vnops.c

Log Message:
remove debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/miscfs/fdesc/fdesc_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/fdesc/fdesc_vnops.c
diff -u src/sys/miscfs/fdesc/fdesc_vnops.c:1.122 src/sys/miscfs/fdesc/fdesc_vnops.c:1.123
--- src/sys/miscfs/fdesc/fdesc_vnops.c:1.122	Thu Sep  4 09:28:54 2014
+++ src/sys/miscfs/fdesc/fdesc_vnops.c	Thu Sep  4 09:29:50 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdesc_vnops.c,v 1.122 2014/09/04 13:28:54 christos Exp $	*/
+/*	$NetBSD: fdesc_vnops.c,v 1.123 2014/09/04 13:29:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.122 2014/09/04 13:28:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.123 2014/09/04 13:29:50 christos Exp $");
 
 #include 
 #include 
@@ -295,7 +295,6 @@ bad:
 good:
 	KASSERT(ix != -1);
 	error = vcache_get(dvp->v_mount, &ix, sizeof(ix), vpp);
-printf("%s, %d: %d %d %p\n", __FILE__, __LINE__, error, ix, vpp);
 	return error;
 }
 
@@ -355,7 +354,6 @@ fdesc_attr(int fd, struct vattr *vap, ka
 			 */
 			vap->va_mode &= ~(S_IXUSR|S_IXGRP|S_IXOTH);
 		}
-printf("%s, %d: %d %d\n", __FILE__, __LINE__, error, vap->va_type);
 		break;
 
 	default:
@@ -392,7 +390,6 @@ printf("%s, %d: %d %d\n", __FILE__, __LI
 		vap->va_flags = stb.st_flags;
 		vap->va_rdev = stb.st_rdev;
 		vap->va_bytes = stb.st_blocks * stb.st_blksize;
-printf("%s, %d: %d %lld\n", __FILE__, __LINE__, error, (long long)vap->va_rdev);
 		break;
 	}
 
@@ -767,12 +764,10 @@ fdesc_ioctl(void *v)
 	} */ *ap = v;
 	int error = EOPNOTSUPP;
 
-printf("%s, %d: ioctl %d\n", __FILE__, __LINE__, VTOFDESC(ap->a_vp)->fd_type);
 	switch (VTOFDESC(ap->a_vp)->fd_type) {
 	case Fctty:
 		error = cdev_ioctl(devctty, ap->a_command, ap->a_data,
 		ap->a_fflag, curlwp);
-printf("%s, %d: ioctl error %d\n", __FILE__, __LINE__, error);
 		break;
 
 	default:



CVS commit: src/sys/miscfs/fdesc

2014-09-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Sep  4 13:28:54 UTC 2014

Modified Files:
src/sys/miscfs/fdesc: fdesc_vnops.c

Log Message:
Well, nasty thing happen if you set /dev/tty to VNON too. Disable for now.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/sys/miscfs/fdesc/fdesc_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/fdesc/fdesc_vnops.c
diff -u src/sys/miscfs/fdesc/fdesc_vnops.c:1.121 src/sys/miscfs/fdesc/fdesc_vnops.c:1.122
--- src/sys/miscfs/fdesc/fdesc_vnops.c:1.121	Fri Jul 25 04:20:52 2014
+++ src/sys/miscfs/fdesc/fdesc_vnops.c	Thu Sep  4 09:28:54 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdesc_vnops.c,v 1.121 2014/07/25 08:20:52 dholland Exp $	*/
+/*	$NetBSD: fdesc_vnops.c,v 1.122 2014/09/04 13:28:54 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.121 2014/07/25 08:20:52 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.122 2014/09/04 13:28:54 christos Exp $");
 
 #include 
 #include 
@@ -295,6 +295,7 @@ bad:
 good:
 	KASSERT(ix != -1);
 	error = vcache_get(dvp->v_mount, &ix, sizeof(ix), vpp);
+printf("%s, %d: %d %d %p\n", __FILE__, __LINE__, error, ix, vpp);
 	return error;
 }
 
@@ -354,6 +355,7 @@ fdesc_attr(int fd, struct vattr *vap, ka
 			 */
 			vap->va_mode &= ~(S_IXUSR|S_IXGRP|S_IXOTH);
 		}
+printf("%s, %d: %d %d\n", __FILE__, __LINE__, error, vap->va_type);
 		break;
 
 	default:
@@ -390,6 +392,7 @@ fdesc_attr(int fd, struct vattr *vap, ka
 		vap->va_flags = stb.st_flags;
 		vap->va_rdev = stb.st_rdev;
 		vap->va_bytes = stb.st_blocks * stb.st_blksize;
+printf("%s, %d: %d %lld\n", __FILE__, __LINE__, error, (long long)vap->va_rdev);
 		break;
 	}
 
@@ -764,10 +767,12 @@ fdesc_ioctl(void *v)
 	} */ *ap = v;
 	int error = EOPNOTSUPP;
 
+printf("%s, %d: ioctl %d\n", __FILE__, __LINE__, VTOFDESC(ap->a_vp)->fd_type);
 	switch (VTOFDESC(ap->a_vp)->fd_type) {
 	case Fctty:
 		error = cdev_ioctl(devctty, ap->a_command, ap->a_data,
 		ap->a_fflag, curlwp);
+printf("%s, %d: ioctl error %d\n", __FILE__, __LINE__, error);
 		break;
 
 	default:
@@ -838,6 +843,7 @@ fdesc_inactive(void *v)
 		struct vnode *a_vp;
 	} */ *ap = v;
 	struct vnode *vp = ap->a_vp;
+#if 0
 	struct fdescnode *fd = VTOFDESC(vp);
 
 	/*
@@ -846,6 +852,7 @@ fdesc_inactive(void *v)
 	 */
 	if (fd->fd_type == Fctty || fd->fd_type == Fdesc)
 		vp->v_type = VNON;
+#endif
 	VOP_UNLOCK(vp);
 	return (0);
 }



CVS commit: src/sys/miscfs/fdesc

2014-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Sep  4 00:30:25 UTC 2014

Modified Files:
src/sys/miscfs/fdesc: fdesc_vfsops.c

Log Message:
Fix type of /dev/tty


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/miscfs/fdesc/fdesc_vfsops.c

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

Modified files:

Index: src/sys/miscfs/fdesc/fdesc_vfsops.c
diff -u src/sys/miscfs/fdesc/fdesc_vfsops.c:1.89 src/sys/miscfs/fdesc/fdesc_vfsops.c:1.90
--- src/sys/miscfs/fdesc/fdesc_vfsops.c:1.89	Sun Jul 13 07:23:01 2014
+++ src/sys/miscfs/fdesc/fdesc_vfsops.c	Wed Sep  3 20:30:25 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdesc_vfsops.c,v 1.89 2014/07/13 11:23:01 hannken Exp $	*/
+/*	$NetBSD: fdesc_vfsops.c,v 1.90 2014/09/04 00:30:25 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993, 1995
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdesc_vfsops.c,v 1.89 2014/07/13 11:23:01 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdesc_vfsops.c,v 1.90 2014/09/04 00:30:25 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -202,7 +202,7 @@ fdesc_loadvnode(struct mount *mp, struct
 		break;
 	case FD_CTTY:
 		fd->fd_type = Fctty;
-		vp->v_type = VNON;
+		vp->v_type = VCHR;
 		break;
 	case FD_STDIN:
 		fd->fd_type = Flink;



CVS commit: src/sys/miscfs/umapfs

2014-08-11 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Aug 11 14:02:14 UTC 2014

Modified Files:
src/sys/miscfs/umapfs: umap_vfsops.c

Log Message:
1) 'error' is returned while it does not even hold an error code. Which
   means that zero is returned, and the kernel keeps mounting (and it
   probably ends up in a deadlock/memory corruption somewhere).
2) 'nentries' and 'gnentries' are int and user-controlled, and there's no
   check to ensure they are greater than zero. Since they are used to
   compute the size of two copyin's, a user can control the copied size
   by giving a negative value (like 128-2^29), and thus overwrite kernel
   memory.

Both triggerable from root only.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/miscfs/umapfs/umap_vfsops.c

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

Modified files:

Index: src/sys/miscfs/umapfs/umap_vfsops.c
diff -u src/sys/miscfs/umapfs/umap_vfsops.c:1.93 src/sys/miscfs/umapfs/umap_vfsops.c:1.94
--- src/sys/miscfs/umapfs/umap_vfsops.c:1.93	Sun May 25 13:51:25 2014
+++ src/sys/miscfs/umapfs/umap_vfsops.c	Mon Aug 11 14:02:14 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: umap_vfsops.c,v 1.93 2014/05/25 13:51:25 hannken Exp $	*/
+/*	$NetBSD: umap_vfsops.c,v 1.94 2014/08/11 14:02:14 maxv Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: umap_vfsops.c,v 1.93 2014/05/25 13:51:25 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umap_vfsops.c,v 1.94 2014/08/11 14:02:14 maxv Exp $");
 
 #include 
 #include 
@@ -153,9 +153,10 @@ umapfs_mount(struct mount *mp, const cha
 	/*
 	 * Now copy in the number of entries and maps for umap mapping.
 	 */
-	if (args->nentries > MAPFILEENTRIES || args->gnentries > GMAPFILEENTRIES) {
+	if (args->nentries < 0 || args->nentries > MAPFILEENTRIES ||
+	args->gnentries < 0 || args->gnentries > GMAPFILEENTRIES) {
 		vput(lowerrootvp);
-		return (error);
+		return (EINVAL);
 	}
 
 	amp->info_nentries = args->nentries;



CVS commit: src/sys/miscfs/procfs

2014-08-09 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sun Aug 10 06:22:06 UTC 2014

Modified Files:
src/sys/miscfs/procfs: procfs_linux.c

Log Message:
#include 


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/miscfs/procfs/procfs_linux.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/procfs/procfs_linux.c
diff -u src/sys/miscfs/procfs/procfs_linux.c:1.69 src/sys/miscfs/procfs/procfs_linux.c:1.70
--- src/sys/miscfs/procfs/procfs_linux.c:1.69	Sat Jul 12 09:58:39 2014
+++ src/sys/miscfs/procfs/procfs_linux.c	Sun Aug 10 06:22:06 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: procfs_linux.c,v 1.69 2014/07/12 09:58:39 njoly Exp $  */
+/*  $NetBSD: procfs_linux.c,v 1.70 2014/08/10 06:22:06 matt Exp $  */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,11 +36,12 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.69 2014/07/12 09:58:39 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.70 2014/08/10 06:22:06 matt Exp $");
 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 



CVS commit: src/sys/miscfs/procfs

2014-07-27 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Jul 27 16:47:26 UTC 2014

Modified Files:
src/sys/miscfs/procfs: procfs.h procfs_subr.c procfs_vfsops.c
procfs_vnops.c

Log Message:
Change procfs from hashlist to vcache.
- Key is (type, pid, fd)
- Remove argument "p" from procfs_allocvp().  It is only used
  when "type == PFSfd".  Lookup the proc with proc_find() when
  procfs_loadvnode() needs it.
- Use a vfs_vnode_iterator for procfs_revoke_vnodes().


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/miscfs/procfs/procfs.h
cvs rdiff -u -r1.104 -r1.105 src/sys/miscfs/procfs/procfs_subr.c
cvs rdiff -u -r1.91 -r1.92 src/sys/miscfs/procfs/procfs_vfsops.c
cvs rdiff -u -r1.190 -r1.191 src/sys/miscfs/procfs/procfs_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/procfs/procfs.h
diff -u src/sys/miscfs/procfs/procfs.h:1.69 src/sys/miscfs/procfs/procfs.h:1.70
--- src/sys/miscfs/procfs/procfs.h:1.69	Sat Apr  5 18:42:32 2014
+++ src/sys/miscfs/procfs/procfs.h	Sun Jul 27 16:47:26 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs.h,v 1.69 2014/04/05 18:42:32 christos Exp $	*/
+/*	$NetBSD: procfs.h,v 1.70 2014/07/27 16:47:26 hannken Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -118,12 +118,17 @@ typedef enum {
 /*
  * control data for the proc file system.
  */
+struct pfskey {
+	pfstype		pk_type;	/* type of procfs node */
+	pid_t		pk_pid;		/* associated process */
+	int		pk_fd;		/* associated fd if not -1 */
+};
 struct pfsnode {
-	LIST_ENTRY(pfsnode) pfs_hash;	/* hash chain */
 	struct vnode	*pfs_vnode;	/* vnode associated with this pfsnode */
-	pfstype		pfs_type;	/* type of procfs node */
-	pid_t		pfs_pid;	/* associated process */
-	int		pfs_fd;		/* associated fd if not -1 */
+	struct pfskey	pfs_key;
+#define pfs_type pfs_key.pk_type
+#define pfs_pid pfs_key.pk_pid
+#define pfs_fd pfs_key.pk_fd
 	mode_t		pfs_mode;	/* mode bits for stat() */
 	u_long		pfs_flags;	/* open flags */
 	u_long		pfs_fileno;	/* unique file id */
@@ -187,9 +192,7 @@ const vfs_namemap_t *vfs_findname(const 
 
 int procfs_proc_lock(int, struct proc **, int);
 void procfs_proc_unlock(struct proc *);
-int procfs_freevp(struct vnode *);
-int procfs_allocvp(struct mount *, struct vnode **, pid_t, pfstype, int,
-struct proc *);
+int procfs_allocvp(struct mount *, struct vnode **, pid_t, pfstype, int);
 int procfs_donote(struct lwp *, struct proc *, struct pfsnode *,
 struct uio *);
 int procfs_doregs(struct lwp *, struct lwp *, struct pfsnode *,
@@ -232,9 +235,6 @@ int procfs_doversion(struct lwp *, struc
 struct uio *);
 
 void procfs_revoke_vnodes(struct proc *, void *);
-void procfs_hashinit(void);
-void procfs_hashreinit(void);
-void procfs_hashdone(void);
 int procfs_getfp(struct pfsnode *, struct proc *, struct file **);
 
 /* functions to check whether or not files should be displayed */

Index: src/sys/miscfs/procfs/procfs_subr.c
diff -u src/sys/miscfs/procfs/procfs_subr.c:1.104 src/sys/miscfs/procfs/procfs_subr.c:1.105
--- src/sys/miscfs/procfs/procfs_subr.c:1.104	Fri Feb  7 15:29:22 2014
+++ src/sys/miscfs/procfs/procfs_subr.c	Sun Jul 27 16:47:26 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_subr.c,v 1.104 2014/02/07 15:29:22 hannken Exp $	*/
+/*	$NetBSD: procfs_subr.c,v 1.105 2014/07/27 16:47:26 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -102,7 +102,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.104 2014/02/07 15:29:22 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.105 2014/07/27 16:47:26 hannken Exp $");
 
 #include 
 #include 
@@ -118,224 +118,22 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_subr.
 
 #include 
 
-void procfs_hashins(struct pfsnode *);
-void procfs_hashrem(struct pfsnode *);
-struct vnode *procfs_hashget(pid_t, pfstype, int, struct mount *);
-
-LIST_HEAD(pfs_hashhead, pfsnode) *pfs_hashtbl;
-u_long	pfs_ihash;	/* size of hash table - 1 */
-#define PFSPIDHASH(pid)	((pid) & pfs_ihash)
-
-kmutex_t pfs_hashlock;
-kmutex_t pfs_ihash_lock;
-
-#define	ISSET(t, f)	((t) & (f))
-
 /*
- * allocate a pfsnode/vnode pair.  the vnode is
- * referenced, and locked.
- *
- * the pid, pfs_type, and mount point uniquely
- * identify a pfsnode.  the mount point is needed
- * because someone might mount this filesystem
- * twice.
- *
- * all pfsnodes are maintained on a singly-linked
- * list.  new nodes are only allocated when they cannot
- * be found on this list.  entries on the list are
- * removed when the vfs reclaim entry is called.
- *
- * a single lock is kept for the entire list.  this is
- * needed because the getnewvnode() function can block
- * waiting for a vnode to become free, in which case there
- * may be more than one process trying to get the same
- * vnode.  this lock is only taken if we are going to
- * call getnewvnode, since the kernel itself is single-threaded.
- *
- * if an entry is

CVS commit: src/sys/miscfs/specfs

2014-07-25 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Jul 25 08:19:19 UTC 2014

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c specdev.h

Log Message:
Implement spec_fdiscard() using bdev_discard() and cdev_discard().
Also define spec_fallocate() to genfs_eopnotsupp().


To generate a diff of this commit:
cvs rdiff -u -r1.143 -r1.144 src/sys/miscfs/specfs/spec_vnops.c
cvs rdiff -u -r1.42 -r1.43 src/sys/miscfs/specfs/specdev.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/miscfs/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.143 src/sys/miscfs/specfs/spec_vnops.c:1.144
--- src/sys/miscfs/specfs/spec_vnops.c:1.143	Mon Mar 24 13:42:40 2014
+++ src/sys/miscfs/specfs/spec_vnops.c	Fri Jul 25 08:19:19 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.143 2014/03/24 13:42:40 hannken Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.144 2014/07/25 08:19:19 dholland Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.143 2014/03/24 13:42:40 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.144 2014/07/25 08:19:19 dholland Exp $");
 
 #include 
 #include 
@@ -838,6 +838,46 @@ spec_write(void *v)
 }
 
 /*
+ * fdiscard, which on disk devices becomes TRIM.
+ */
+int
+spec_fdiscard(void *v)
+{
+	struct vop_fdiscard_args /* {
+		struct vnode *a_vp;
+		off_t a_pos;
+		off_t a_len;
+	} */ *ap = v;
+	struct vnode *vp;
+	dev_t dev;
+
+	vp = ap->a_vp;
+	dev = NODEV;
+
+	mutex_enter(vp->v_interlock);
+	if (vdead_check(vp, VDEAD_NOWAIT) == 0 && vp->v_specnode != NULL) {
+		dev = vp->v_rdev;
+	}
+	mutex_exit(vp->v_interlock);
+
+	if (dev == NODEV) {
+		return ENXIO;
+	}
+
+	switch (vp->v_type) {
+	case VCHR:
+		// this is not stored for character devices
+		//KASSERT(vp == vp->v_specnode->sn_dev->sd_cdevvp);
+		return cdev_discard(dev, ap->a_pos, ap->a_len);
+	case VBLK:
+		KASSERT(vp == vp->v_specnode->sn_dev->sd_bdevvp);
+		return bdev_discard(dev, ap->a_pos, ap->a_len);
+	default:
+		panic("spec_fdiscard: not a device\n");
+	}
+}
+
+/*
  * Device ioctl operation.
  */
 /* ARGSUSED */

Index: src/sys/miscfs/specfs/specdev.h
diff -u src/sys/miscfs/specfs/specdev.h:1.42 src/sys/miscfs/specfs/specdev.h:1.43
--- src/sys/miscfs/specfs/specdev.h:1.42	Mon Sep 30 18:58:00 2013
+++ src/sys/miscfs/specfs/specdev.h	Fri Jul 25 08:19:19 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: specdev.h,v 1.42 2013/09/30 18:58:00 hannken Exp $	*/
+/*	$NetBSD: specdev.h,v 1.43 2014/07/25 08:19:19 dholland Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -119,6 +119,8 @@ int	spec_close(void *);
 #define	spec_setattr	genfs_ebadf
 int	spec_read(void *);
 int	spec_write(void *);
+#define spec_fallocate	genfs_eopnotsupp
+int	spec_fdiscard(void *);
 #define spec_fcntl	genfs_fcntl
 int	spec_ioctl(void *);
 int	spec_poll(void *);



CVS commit: src/sys/miscfs/kernfs

2014-07-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Jul 20 13:17:37 UTC 2014

Modified Files:
src/sys/miscfs/kernfs: kernfs.h

Log Message:
Remove another KAME IPSEC residue, "struct secasvar" and "struct secpolicy".


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/miscfs/kernfs/kernfs.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/miscfs/kernfs/kernfs.h
diff -u src/sys/miscfs/kernfs/kernfs.h:1.38 src/sys/miscfs/kernfs/kernfs.h:1.39
--- src/sys/miscfs/kernfs/kernfs.h:1.38	Thu Jul 17 08:21:34 2014
+++ src/sys/miscfs/kernfs/kernfs.h	Sun Jul 20 13:17:37 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernfs.h,v 1.38 2014/07/17 08:21:34 hannken Exp $	*/
+/*	$NetBSD: kernfs.h,v 1.39 2014/07/20 13:17:37 hannken Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -123,9 +123,6 @@ extern int (**kernfs_vnodeop_p)(void *);
 extern struct vfsops kernfs_vfsops;
 extern dev_t rrootdev;
 
-struct secasvar;
-struct secpolicy;
-
 int kernfs_root(struct mount *, struct vnode **);
 
 void kernfs_hashinit(void);



CVS commit: src/sys/miscfs/kernfs

2014-07-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Jul 17 08:21:34 UTC 2014

Modified Files:
src/sys/miscfs/kernfs: kernfs.h kernfs_subr.c kernfs_vfsops.c
kernfs_vnops.c

Log Message:
Finish KAME IPSEC removal:
- Remove field kfs_value, it is always zero. Compute the hash from kt_tag.
- Remove stray definitions kernfs_revoke_sa and kernfs_revoke_sp.

While here, remove kfs_type from allocvp(), it is always kt->kt_tag.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/miscfs/kernfs/kernfs.h
cvs rdiff -u -r1.27 -r1.28 src/sys/miscfs/kernfs/kernfs_subr.c
cvs rdiff -u -r1.93 -r1.94 src/sys/miscfs/kernfs/kernfs_vfsops.c
cvs rdiff -u -r1.151 -r1.152 src/sys/miscfs/kernfs/kernfs_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/kernfs/kernfs.h
diff -u src/sys/miscfs/kernfs/kernfs.h:1.37 src/sys/miscfs/kernfs/kernfs.h:1.38
--- src/sys/miscfs/kernfs/kernfs.h:1.37	Thu Mar 22 20:34:38 2012
+++ src/sys/miscfs/kernfs/kernfs.h	Thu Jul 17 08:21:34 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernfs.h,v 1.37 2012/03/22 20:34:38 drochner Exp $	*/
+/*	$NetBSD: kernfs.h,v 1.38 2014/07/17 08:21:34 hannken Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -91,9 +91,8 @@ struct kernfs_node {
 	kfstype		kfs_type;	/* type of kernfs node */
 	mode_t		kfs_mode;	/* mode bits for stat() */
 	long		kfs_fileno;	/* unique file id */
-	u_int32_t	kfs_value;	/* SA id or SP id (KFSint) */
 	const struct kern_target *kfs_kt;
-	void		*kfs_v;		/* pointer to secasvar/secpolicy/mbuf */
+	void		*kfs_v;		/* dynamic node private data */
 	long		kfs_cookie;	/* fileno cookie */
 };
 
@@ -133,11 +132,7 @@ void kernfs_hashinit(void);
 void kernfs_hashreinit(void);
 void kernfs_hashdone(void);
 int kernfs_freevp(struct vnode *);
-int kernfs_allocvp(struct mount *, struct vnode **, kfstype,
-	const struct kern_target *, u_int32_t);
-
-void kernfs_revoke_sa(struct secasvar *);
-void kernfs_revoke_sp(struct secpolicy *);
+int kernfs_allocvp(struct mount *, struct vnode **, const struct kern_target *);
 
 /*
  * Data types for the kernfs file operations.

Index: src/sys/miscfs/kernfs/kernfs_subr.c
diff -u src/sys/miscfs/kernfs/kernfs_subr.c:1.27 src/sys/miscfs/kernfs/kernfs_subr.c:1.28
--- src/sys/miscfs/kernfs/kernfs_subr.c:1.27	Tue Apr  8 17:56:10 2014
+++ src/sys/miscfs/kernfs/kernfs_subr.c	Thu Jul 17 08:21:34 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernfs_subr.c,v 1.27 2014/04/08 17:56:10 christos Exp $	*/
+/*	$NetBSD: kernfs_subr.c,v 1.28 2014/07/17 08:21:34 hannken Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kernfs_subr.c,v 1.27 2014/04/08 17:56:10 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kernfs_subr.c,v 1.28 2014/07/17 08:21:34 hannken Exp $");
 
 #include 
 #include 
@@ -93,11 +93,11 @@ __KERNEL_RCSID(0, "$NetBSD: kernfs_subr.
 void kernfs_hashins(struct kernfs_node *);
 void kernfs_hashrem(struct kernfs_node *);
 struct vnode *kernfs_hashget(kfstype, struct mount *,
-const struct kern_target *, u_int32_t);
+const struct kern_target *);
 
 static LIST_HEAD(kfs_hashhead, kernfs_node) *kfs_hashtbl;
 static u_long	kfs_ihash;	/* size of hash table - 1 */
-#define KFSVALUEHASH(v)	((v) & kfs_ihash)
+#define KFSHASH(v)	((v) & kfs_ihash)
 
 static kmutex_t kfs_hashlock;
 static kmutex_t kfs_ihash_lock;
@@ -108,7 +108,7 @@ static kmutex_t kfs_ihash_lock;
  * allocate a kfsnode/vnode pair.  the vnode is
  * referenced, and locked.
  *
- * the kfs_type, kfs_value and mount point uniquely
+ * the kfs_type and mount point uniquely
  * identify a kfsnode.  the mount point is needed
  * because someone might mount this filesystem
  * twice.
@@ -131,19 +131,19 @@ static kmutex_t kfs_ihash_lock;
  * the vnode free list.
  */
 int
-kernfs_allocvp(struct mount *mp, struct vnode **vpp, kfstype kfs_type,
-const struct kern_target *kt, u_int32_t value)
+kernfs_allocvp(struct mount *mp, struct vnode **vpp,
+const struct kern_target *kt)
 {
 	struct kernfs_node *kfs = NULL, *kfsp;
 	struct vnode *vp = NULL;
 	int error;
 	long *cookie;
 
-	if ((*vpp = kernfs_hashget(kfs_type, mp, kt, value)) != NULL)
+	if ((*vpp = kernfs_hashget(kt->kt_tag, mp, kt)) != NULL)
 		return (0);
 
 	mutex_enter(&kfs_hashlock);
-	if ((*vpp = kernfs_hashget(kfs_type, mp, kt, value)) != NULL) {
+	if ((*vpp = kernfs_hashget(kt->kt_tag, mp, kt)) != NULL) {
 		mutex_exit(&kfs_hashlock);
 		return (0);
 	}
@@ -184,18 +184,17 @@ again:
 	else
 		TAILQ_INSERT_TAIL(&VFSTOKERNFS(mp)->nodelist, kfs, kfs_list);
 
-	kfs->kfs_type = kfs_type;
+	kfs->kfs_type = kt->kt_tag;
 	kfs->kfs_vnode = vp;
-	kfs->kfs_fileno = KERNFS_FILENO(kt, kfs_type, kfs->kfs_cookie);
-	kfs->kfs_value = value;
+	kfs->kfs_fileno = KERNFS_FILENO(kt, kt->kt_tag, kfs->kfs_cookie);
 	kfs->kfs_kt = kt;
 	kfs->kfs_mode = kt->kt_mode;
 	vp->v_type = kt->kt_vtype;
 
-	if (kfs_type == KFSkern)
+	if (kt->kt_tag == KFSkern)
 

CVS commit: src/sys/miscfs/fdesc

2014-07-13 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Jul 13 11:23:01 UTC 2014

Modified Files:
src/sys/miscfs/fdesc: fdesc.h fdesc_vfsops.c fdesc_vnops.c

Log Message:
Change fdesc from hashlist to vcache.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/miscfs/fdesc/fdesc.h
cvs rdiff -u -r1.88 -r1.89 src/sys/miscfs/fdesc/fdesc_vfsops.c
cvs rdiff -u -r1.119 -r1.120 src/sys/miscfs/fdesc/fdesc_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/fdesc/fdesc.h
diff -u src/sys/miscfs/fdesc/fdesc.h:1.21 src/sys/miscfs/fdesc/fdesc.h:1.22
--- src/sys/miscfs/fdesc/fdesc.h:1.21	Tue Sep 27 01:22:12 2011
+++ src/sys/miscfs/fdesc/fdesc.h	Sun Jul 13 11:23:01 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdesc.h,v 1.21 2011/09/27 01:22:12 christos Exp $	*/
+/*	$NetBSD: fdesc.h,v 1.22 2014/07/13 11:23:01 hannken Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -56,11 +56,10 @@ typedef enum {
 } fdntype;
 
 struct fdescnode {
-	LIST_ENTRY(fdescnode) fd_hash;	/* Hash list */
 	struct vnode	*fd_vnode;	/* Back ptr to vnode */
 	fdntype		fd_type;	/* Type of this node */
 	unsigned	fd_fd;		/* Fd to be dup'ed */
-	char		*fd_link;	/* Link to fd/n */
+	const char	*fd_link;	/* Link to fd/n */
 	int		fd_ix;		/* filesystem index */
 };
 

Index: src/sys/miscfs/fdesc/fdesc_vfsops.c
diff -u src/sys/miscfs/fdesc/fdesc_vfsops.c:1.88 src/sys/miscfs/fdesc/fdesc_vfsops.c:1.89
--- src/sys/miscfs/fdesc/fdesc_vfsops.c:1.88	Sun Mar 23 15:21:16 2014
+++ src/sys/miscfs/fdesc/fdesc_vfsops.c	Sun Jul 13 11:23:01 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdesc_vfsops.c,v 1.88 2014/03/23 15:21:16 hannken Exp $	*/
+/*	$NetBSD: fdesc_vfsops.c,v 1.89 2014/07/13 11:23:01 hannken Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993, 1995
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdesc_vfsops.c,v 1.88 2014/03/23 15:21:16 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdesc_vfsops.c,v 1.89 2014/07/13 11:23:01 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -78,7 +78,7 @@ int
 fdesc_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
 {
 	struct lwp *l = curlwp;
-	int error = 0;
+	int error = 0, ix;
 	struct vnode *rvp;
 
 	if (mp->mnt_flag & MNT_GETARGS) {
@@ -91,12 +91,11 @@ fdesc_mount(struct mount *mp, const char
 	if (mp->mnt_flag & MNT_UPDATE)
 		return (EOPNOTSUPP);
 
-	error = fdesc_allocvp(Froot, FD_ROOT, mp, &rvp);
+	ix = FD_ROOT;
+	error = vcache_get(mp, &ix, sizeof(ix), &rvp);
 	if (error)
-		return (error);
+		return error;
 
-	rvp->v_type = VDIR;
-	rvp->v_vflag |= VV_ROOT;
 	mp->mnt_stat.f_namemax = FDESC_MAXNAMLEN;
 	mp->mnt_flag |= MNT_LOCAL;
 	mp->mnt_data = rvp;
@@ -104,7 +103,6 @@ fdesc_mount(struct mount *mp, const char
 
 	error = set_statvfs_info(path, UIO_USERSPACE, "fdesc", UIO_SYSSPACE,
 	mp->mnt_op->vfs_name, mp, l);
-	VOP_UNLOCK(rvp);
 	return error;
 }
 
@@ -174,6 +172,66 @@ fdesc_vget(struct mount *mp, ino_t ino,
 	return (EOPNOTSUPP);
 }
 
+int
+fdesc_loadvnode(struct mount *mp, struct vnode *vp,
+const void *key, size_t key_len, const void **new_key)
+{
+	int ix;
+	struct fdescnode *fd;
+
+	KASSERT(key_len == sizeof(ix));
+	memcpy(&ix, key, key_len);
+
+	fd = kmem_alloc(sizeof(struct fdescnode), KM_SLEEP);
+	fd->fd_fd = -1;
+	fd->fd_link = NULL;
+	fd->fd_ix = ix;
+	fd->fd_vnode = vp;
+	vp->v_tag = VT_FDESC;
+	vp->v_op = fdesc_vnodeop_p;
+	vp->v_data = fd;
+	switch (ix) {
+	case FD_ROOT:
+		fd->fd_type = Froot;
+		vp->v_type = VDIR;
+		vp->v_vflag |= VV_ROOT;
+		break;
+	case FD_DEVFD:
+		fd->fd_type = Fdevfd;
+		vp->v_type = VDIR;
+		break;
+	case FD_CTTY:
+		fd->fd_type = Fctty;
+		vp->v_type = VNON;
+		break;
+	case FD_STDIN:
+		fd->fd_type = Flink;
+		fd->fd_link = "fd/0";
+		vp->v_type = VLNK;
+		break;
+	case FD_STDOUT:
+		fd->fd_type = Flink;
+		fd->fd_link = "fd/1";
+		vp->v_type = VLNK;
+		break;
+	case FD_STDERR:
+		fd->fd_type = Flink;
+		fd->fd_link = "fd/2";
+		vp->v_type = VLNK;
+		break;
+	default:
+		KASSERT(ix >= FD_DESC);
+		fd->fd_type = Fdesc;
+		fd->fd_fd = ix - FD_DESC;
+		vp->v_type = VNON;
+		break;
+	}
+	uvm_vnp_setsize(vp, 0);
+	*new_key = &fd->fd_ix;
+
+	return 0;
+}
+
 extern const struct vnodeopv_desc fdesc_vnodeop_opv_desc;
 
 const struct vnodeopv_desc * const fdesc_vnodeopv_descs[] = {
@@ -192,6 +250,7 @@ struct vfsops fdesc_vfsops = {
 	.vfs_statvfs = genfs_statvfs,
 	.vfs_sync = fdesc_sync,
 	.vfs_vget = fdesc_vget,
+	.vfs_loadvnode = fdesc_loadvnode,
 	.vfs_fhtovp = (void *)eopnotsupp,
 	.vfs_vptofh = (void *)eopnotsupp,
 	.vfs_init = fdesc_init,

Index: src/sys/miscfs/fdesc/fdesc_vnops.c
diff -u src/sys/miscfs/fdesc/fdesc_vnops.c:1.119 src/sys/miscfs/fdesc/fdesc_vnops.c:1.120
--- src/sys/miscfs/fdesc/fdesc_vnops.c:1.119	Thu Mar 20 18:04:05 2014
+++ src/sys/miscfs/fdesc/fdesc_vnops.c	Sun Jul 13 11:23:01 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdesc_vnops.c,v 1.119 2014/03/20 18:04:05 christos Exp $	*/
+/

CVS commit: src/sys/miscfs/procfs

2014-07-12 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Sat Jul 12 09:58:39 UTC 2014

Modified Files:
src/sys/miscfs/procfs: procfs_linux.c

Log Message:
Use kproc2 to provide sensible informations for /proc//stat.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/miscfs/procfs/procfs_linux.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/procfs/procfs_linux.c
diff -u src/sys/miscfs/procfs/procfs_linux.c:1.68 src/sys/miscfs/procfs/procfs_linux.c:1.69
--- src/sys/miscfs/procfs/procfs_linux.c:1.68	Mon Jun 30 14:58:59 2014
+++ src/sys/miscfs/procfs/procfs_linux.c	Sat Jul 12 09:58:39 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: procfs_linux.c,v 1.68 2014/06/30 14:58:59 njoly Exp $  */
+/*  $NetBSD: procfs_linux.c,v 1.69 2014/07/12 09:58:39 njoly Exp $  */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.68 2014/06/30 14:58:59 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.69 2014/07/12 09:58:39 njoly Exp $");
 
 #include 
 #include 
@@ -400,7 +400,7 @@ out:
 	return error;
 }
 
-#define USEC_2_TICKS(x)		((x) / 1)
+#define UTIME2TICKS(s,u)	(((uint64_t)(s) * 100 + (u)) / 1)
 
 /*
  * Linux compatible /proc//stat. Only active when the -o linux
@@ -413,12 +413,11 @@ procfs_do_pid_stat(struct lwp *curl, str
 	char *bf;
 	struct proc *p = l->l_proc;
 	int len;
-	struct tty *tty = p->p_session->s_ttyp;
-	struct rusage *ru = &p->p_stats->p_ru;
 	struct rusage *cru = &p->p_stats->p_cru;
 	unsigned long stext = 0, etext = 0, sstack = 0;
 	struct timeval rt;
 	struct vmspace	*vm;
+	struct kinfo_proc2 ki;
 	int error = 0;
 
 	bf = malloc(LBFSZ, M_TEMP, M_WAITOK);
@@ -432,65 +431,67 @@ procfs_do_pid_stat(struct lwp *curl, str
 	mutex_enter(proc_lock);
 	mutex_enter(p->p_lock);
 
+	fill_kproc2(p, &ki, false);
 	calcru(p, NULL, NULL, NULL, &rt);
 
 	len = snprintf(bf, LBFSZ,
-	"%d (%s) %c %d %d %d %lld %d "
+	"%d (%s) %c %d %d %d %u %d "
 	"%u "
-	"%lu %lu %lu %lu %lu %lu %lu %lu "
-	"%d %d %d "
-	"%lld %lld %lu %lu %" PRIu64 " "
+	"%"PRIu64" %lu %"PRIu64" %lu %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64" "
+	"%d %d %"PRIu64" "
+	"%lld %"PRIu64" %"PRId64" %lu %"PRIu64" "
 	"%lu %lu %lu "
 	"%u %u "
 	"%u %u %u %u "
-	"%lu %lu %lu %d %d\n",
+	"%"PRIu64" %"PRIu64" %"PRIu64" %d %"PRIu64"\n",
 
-	p->p_pid,
-	p->p_comm,
-	"0IR3SZD"[(p->p_stat > 6) ? 0 : (int)p->p_stat],
-	(p->p_pptr != NULL) ? p->p_pptr->p_pid : 0,
+	ki.p_pid,		/* 1 pid */
+	ki.p_comm,		/* 2 tcomm */
+	"0RRSTZXR8"[(ki.p_stat > 8) ? 0 : (int)ki.p_stat],	/* 3 state */
+	ki.p_ppid,		/* 4 ppid */
+	ki.p__pgid,		/* 5 pgrp */
+	ki.p_sid,		/* 6 sid */
+	(ki.p_tdev != (uint32_t)NODEV) ? ki.p_tdev : 0,	/* 7 tty_nr */
+	ki.p_tpgid,		/* 8 tty_pgrp */
 
-	p->p_pgid,
-	p->p_session->s_sid,
-	(unsigned long long)(tty ? tty->t_dev : 0),
-	(tty && tty->t_pgrp) ? tty->t_pgrp->pg_id : 0,
+	ki.p_flag,		/* 9 flags */
 
-	p->p_flag,
-
-	ru->ru_minflt,
+	ki.p_uru_minflt,	/* 10 min_flt */
 	cru->ru_minflt,
-	ru->ru_majflt,
+	ki.p_uru_majflt,	/* 12 maj_flt */
 	cru->ru_majflt,
-	(long)USEC_2_TICKS(ru->ru_utime.tv_usec),
-	(long)USEC_2_TICKS(ru->ru_stime.tv_usec),
-	(long)USEC_2_TICKS(cru->ru_utime.tv_usec),
-	(long)USEC_2_TICKS(cru->ru_stime.tv_usec),
-
-	l->l_priority,/* XXX: priority */
-	p->p_nice - NZERO,
-	0,
+	UTIME2TICKS(ki.p_uutime_sec, ki.p_uutime_usec),	/* 14 utime */
+	UTIME2TICKS(ki.p_ustime_sec, ki.p_ustime_usec),	/* 15 stime */
+	UTIME2TICKS(cru->ru_utime.tv_sec, cru->ru_utime.tv_usec), /* 16 cutime */
+	UTIME2TICKS(cru->ru_stime.tv_sec, cru->ru_stime.tv_usec), /* 17 cstime */
+
+	ki.p_priority,/* XXX: 18 priority */
+	ki.p_nice - NZERO,/* 19 nice */
+	ki.p_nlwps,	/* 20 num_threads */
 
 	(long long)rt.tv_sec,
-	(long long)p->p_stats->p_start.tv_sec,
-	(unsigned long)(vm->vm_tsize + vm->vm_dsize + vm->vm_ssize), /* size */
-	(unsigned long)(vm->vm_rssize),	/* resident */
-	p->p_rlimit[RLIMIT_RSS].rlim_cur,
-
-	stext,	/* start code */
-	etext,	/* end code */
-	sstack,	/* mm start stack */
-	0,		/* XXX: pc */
-	0,		/* XXX: sp */
-	p->p_sigpend.sp_set.__bits[0],		/* XXX: pending */
-	0,		/* XXX: held */
-	p->p_sigctx.ps_sigignore.__bits[0],		/* ignored */
-	p->p_sigctx.ps_sigcatch.__bits[0],		/* caught */
-
-	(unsigned long)(intptr_t)l->l_wchan,
-	ru->ru_nvcsw,
-	ru->ru_nivcsw,
-	p->p_exitsig,
-	0);		/* XXX: processor */
+	UTIME2TICKS(ki.p_ustart_sec, ki.p_ustart_usec), /* 22 start_time */
+	ki.p_vm_msize,/* 23 vsize */
+	PGTOKB(ki.p_vm_rssize),			/* 24 rss 

CVS commit: src/sys/miscfs/procfs

2014-06-30 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Mon Jun 30 14:58:59 UTC 2014

Modified Files:
src/sys/miscfs/procfs: procfs_linux.c

Log Message:
Use NZERO instead of hard-coded "20" value.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/miscfs/procfs/procfs_linux.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/procfs/procfs_linux.c
diff -u src/sys/miscfs/procfs/procfs_linux.c:1.67 src/sys/miscfs/procfs/procfs_linux.c:1.68
--- src/sys/miscfs/procfs/procfs_linux.c:1.67	Sat Apr  5 18:42:32 2014
+++ src/sys/miscfs/procfs/procfs_linux.c	Mon Jun 30 14:58:59 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: procfs_linux.c,v 1.67 2014/04/05 18:42:32 christos Exp $  */
+/*  $NetBSD: procfs_linux.c,v 1.68 2014/06/30 14:58:59 njoly Exp $  */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.67 2014/04/05 18:42:32 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.68 2014/06/30 14:58:59 njoly Exp $");
 
 #include 
 #include 
@@ -467,7 +467,7 @@ procfs_do_pid_stat(struct lwp *curl, str
 	(long)USEC_2_TICKS(cru->ru_stime.tv_usec),
 
 	l->l_priority,/* XXX: priority */
-	p->p_nice - 20,
+	p->p_nice - NZERO,
 	0,
 
 	(long long)rt.tv_sec,



  1   2   >