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

2016-05-10 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue May 10 19:04:15 UTC 2016

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

Log Message:
Pull up following revision(s) (requested by joerg in ticket #1163):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.125
do not access uninitialized variables in KASSERTs - fixes build


To generate a diff of this commit:
cvs rdiff -u -r1.120.2.2 -r1.120.2.3 src/sys/fs/tmpfs/tmpfs_vnops.c

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

Modified files:

Index: src/sys/fs/tmpfs/tmpfs_vnops.c
diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.120.2.2 src/sys/fs/tmpfs/tmpfs_vnops.c:1.120.2.3
--- src/sys/fs/tmpfs/tmpfs_vnops.c:1.120.2.2	Mon May  9 19:45:00 2016
+++ src/sys/fs/tmpfs/tmpfs_vnops.c	Tue May 10 19:04:15 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: tmpfs_vnops.c,v 1.120.2.2 2016/05/09 19:45:00 snj Exp $	*/
+/*	$NetBSD: tmpfs_vnops.c,v 1.120.2.3 2016/05/10 19:04:15 snj Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.120.2.2 2016/05/09 19:45:00 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.120.2.3 2016/05/10 19:04:15 snj Exp $");
 
 #include 
 #include 
@@ -589,14 +589,14 @@ tmpfs_write(void *v)
 
 	KASSERT(VOP_ISLOCKED(vp));
 
+	node = VP_TO_TMPFS_NODE(vp);
+	oldsize = node->tn_size;
+
 	if ((vp->v_mount->mnt_flag & MNT_RDONLY) != 0) {
 		error = EROFS;
 		goto out;
 	}
 
-	node = VP_TO_TMPFS_NODE(vp);
-	oldsize = node->tn_size;
-
 	if (uio->uio_offset < 0 || vp->v_type != VREG) {
 		error = EINVAL;
 		goto out;



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

2016-05-09 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon May  9 19:45:00 UTC 2016

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

Log Message:
Pull up following revision(s) (requested by joerg in ticket #1163):
sys/fs/tmpfs/tmpfs_vfsops.c: revision 1.66, 1.67
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.124
Only recheck size/node limits on update mounts, if there actually have
been specified.
--
Implement most of mount -ur functionality for tmpfs. Remaining issue is
the question who is responsible for syncing pending writes, but the
functionality is good enough for serving as read-only chroot base in
bulk builds.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.63.2.1 src/sys/fs/tmpfs/tmpfs_vfsops.c
cvs rdiff -u -r1.120.2.1 -r1.120.2.2 src/sys/fs/tmpfs/tmpfs_vnops.c

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

Modified files:

Index: src/sys/fs/tmpfs/tmpfs_vfsops.c
diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.63 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.63.2.1
--- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.63	Tue Jun 10 16:10:59 2014
+++ src/sys/fs/tmpfs/tmpfs_vfsops.c	Mon May  9 19:45:00 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: tmpfs_vfsops.c,v 1.63 2014/06/10 16:10:59 martin Exp $	*/
+/*	$NetBSD: tmpfs_vfsops.c,v 1.63.2.1 2016/05/09 19:45:00 snj Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.63 2014/06/10 16:10:59 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.63.2.1 2016/05/09 19:45:00 snj Exp $");
 
 #include 
 #include 
@@ -102,6 +102,8 @@ tmpfs_mount(struct mount *mp, const char
 	uint64_t memlimit;
 	ino_t nodes;
 	int error;
+	bool set_memlimit;
+	bool set_nodes;
 
 	if (args == NULL)
 		return EINVAL;
@@ -146,26 +148,33 @@ tmpfs_mount(struct mount *mp, const char
 	/* Get the memory usage limit for this file-system. */
 	if (args->ta_size_max < PAGE_SIZE) {
 		memlimit = UINT64_MAX;
+		set_memlimit = false;
 	} else {
 		memlimit = args->ta_size_max;
+		set_memlimit = true;
 	}
 	KASSERT(memlimit > 0);
 
 	if (args->ta_nodes_max <= 3) {
 		nodes = 3 + (memlimit / 1024);
+		set_nodes = false;
 	} else {
 		nodes = args->ta_nodes_max;
+		set_nodes = true;
 	}
 	nodes = MIN(nodes, INT_MAX);
 	KASSERT(nodes >= 3);
 
 	if (mp->mnt_flag & MNT_UPDATE) {
 		tmp = VFS_TO_TMPFS(mp);
-		if (nodes < tmp->tm_nodes_cnt)
+		if (set_nodes && nodes < tmp->tm_nodes_cnt)
 			return EBUSY;
-		if ((error = tmpfs_mntmem_set(tmp, memlimit)) != 0)
-			return error;
-		tmp->tm_nodes_max = nodes;
+		if (set_memlimit) {
+			if ((error = tmpfs_mntmem_set(tmp, memlimit)) != 0)
+return error;
+		}
+		if (set_nodes)
+			tmp->tm_nodes_max = nodes;
 		root = tmp->tm_root;
 		root->tn_uid = args->ta_root_uid;
 		root->tn_gid = args->ta_root_gid;
@@ -205,7 +214,7 @@ tmpfs_mount(struct mount *mp, const char
 	mp->mnt_stat.f_namemax = TMPFS_MAXNAMLEN;
 	mp->mnt_fs_bshift = PAGE_SHIFT;
 	mp->mnt_dev_bshift = DEV_BSHIFT;
-	mp->mnt_iflag |= IMNT_MPSAFE;
+	mp->mnt_iflag |= IMNT_MPSAFE | IMNT_CAN_RWTORO;
 	vfs_getnewfsid(mp);
 
 	error = set_statvfs_info(path, UIO_USERSPACE, "tmpfs", UIO_SYSSPACE,

Index: src/sys/fs/tmpfs/tmpfs_vnops.c
diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.120.2.1 src/sys/fs/tmpfs/tmpfs_vnops.c:1.120.2.2
--- src/sys/fs/tmpfs/tmpfs_vnops.c:1.120.2.1	Mon Dec 22 02:05:08 2014
+++ src/sys/fs/tmpfs/tmpfs_vnops.c	Mon May  9 19:45:00 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: tmpfs_vnops.c,v 1.120.2.1 2014/12/22 02:05:08 msaitoh Exp $	*/
+/*	$NetBSD: tmpfs_vnops.c,v 1.120.2.2 2016/05/09 19:45:00 snj Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.120.2.1 2014/12/22 02:05:08 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.120.2.2 2016/05/09 19:45:00 snj Exp $");
 
 #include 
 #include 
@@ -589,6 +589,11 @@ tmpfs_write(void *v)
 
 	KASSERT(VOP_ISLOCKED(vp));
 
+	if ((vp->v_mount->mnt_flag & MNT_RDONLY) != 0) {
+		error = EROFS;
+		goto out;
+	}
+
 	node = VP_TO_TMPFS_NODE(vp);
 	oldsize = node->tn_size;
 
@@ -1267,6 +1272,11 @@ tmpfs_putpages(void *v)
 		return 0;
 	}
 
+	if ((vp->v_mount->mnt_flag & MNT_RDONLY) != 0) {
+		mutex_exit(vp->v_interlock);
+		return EROFS;
+	}
+
 	node = VP_TO_TMPFS_NODE(vp);
 	uobj = node->tn_spec.tn_reg.tn_aobj;
 



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

2015-11-07 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sun Nov  8 01:26:56 UTC 2015

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

Log Message:
Pull up following revision(s) (requested by leot in ticket #1023):
sys/fs/tmpfs/tmpfs_subr.c: revision 1.101
Make sure that nde->td_node is NULL for asserts.
Thanks and from Mindaugas Rasiukevicius.
Fixes PR kern/50381.


To generate a diff of this commit:
cvs rdiff -u -r1.96.4.1 -r1.96.4.2 src/sys/fs/tmpfs/tmpfs_subr.c

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

Modified files:

Index: src/sys/fs/tmpfs/tmpfs_subr.c
diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.96.4.1 src/sys/fs/tmpfs/tmpfs_subr.c:1.96.4.2
--- src/sys/fs/tmpfs/tmpfs_subr.c:1.96.4.1	Mon Dec 22 02:05:08 2014
+++ src/sys/fs/tmpfs/tmpfs_subr.c	Sun Nov  8 01:26:56 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: tmpfs_subr.c,v 1.96.4.1 2014/12/22 02:05:08 msaitoh Exp $	*/
+/*	$NetBSD: tmpfs_subr.c,v 1.96.4.2 2015/11/08 01:26:56 riz Exp $	*/
 
 /*
  * Copyright (c) 2005-2013 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.96.4.1 2014/12/22 02:05:08 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.96.4.2 2015/11/08 01:26:56 riz Exp $");
 
 #include 
 #include 
@@ -451,6 +451,7 @@ tmpfs_alloc_dirent(tmpfs_mount_t *tmp, c
 	nde->td_namelen = len;
 	memcpy(nde->td_name, name, len);
 	nde->td_seq = TMPFS_DIRSEQ_NONE;
+	nde->td_node = NULL; /* for asserts */
 
 	*de = nde;
 	return 0;



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

2014-12-21 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Dec 22 02:05:08 UTC 2014

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

Log Message:
Pull up following revision(s) (requested by gson in ticket #344):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.121
sys/fs/tmpfs/tmpfs_subr.c: revision 1.97
Store symlinks without a NUL terminator so that lstat(2) returns the
correct length.  Fixes the tmpfs part of PR kern/48864.


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.96.4.1 src/sys/fs/tmpfs/tmpfs_subr.c
cvs rdiff -u -r1.120 -r1.120.2.1 src/sys/fs/tmpfs/tmpfs_vnops.c

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

Modified files:

Index: src/sys/fs/tmpfs/tmpfs_subr.c
diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.96 src/sys/fs/tmpfs/tmpfs_subr.c:1.96.4.1
--- src/sys/fs/tmpfs/tmpfs_subr.c:1.96	Thu Jan 23 10:13:56 2014
+++ src/sys/fs/tmpfs/tmpfs_subr.c	Mon Dec 22 02:05:08 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: tmpfs_subr.c,v 1.96 2014/01/23 10:13:56 hannken Exp $	*/
+/*	$NetBSD: tmpfs_subr.c,v 1.96.4.1 2014/12/22 02:05:08 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2005-2013 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: tmpfs_subr.c,v 1.96 2014/01/23 10:13:56 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: tmpfs_subr.c,v 1.96.4.1 2014/12/22 02:05:08 msaitoh Exp $);
 
 #include sys/param.h
 #include sys/cprng.h
@@ -185,7 +185,6 @@ tmpfs_alloc_node(tmpfs_mount_t *tmp, enu
 		}
 
 		KASSERT(nnode-tn_size  MAXPATHLEN);
-		nnode-tn_size++; /* include the NUL terminator */
 
 		nnode-tn_spec.tn_lnk.tn_link =
 		tmpfs_strname_alloc(tmp, nnode-tn_size);

Index: src/sys/fs/tmpfs/tmpfs_vnops.c
diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.120 src/sys/fs/tmpfs/tmpfs_vnops.c:1.120.2.1
--- src/sys/fs/tmpfs/tmpfs_vnops.c:1.120	Fri Jul 25 08:20:52 2014
+++ src/sys/fs/tmpfs/tmpfs_vnops.c	Mon Dec 22 02:05:08 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: tmpfs_vnops.c,v 1.120 2014/07/25 08:20:52 dholland Exp $	*/
+/*	$NetBSD: tmpfs_vnops.c,v 1.120.2.1 2014/12/22 02:05:08 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: tmpfs_vnops.c,v 1.120 2014/07/25 08:20:52 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: tmpfs_vnops.c,v 1.120.2.1 2014/12/22 02:05:08 msaitoh Exp $);
 
 #include sys/param.h
 #include sys/dirent.h
@@ -1036,7 +1036,7 @@ tmpfs_readlink(void *v)
 	/* Note: readlink(2) returns the path without NUL terminator. */
 	if (node-tn_size  0) {
 		error = uiomove(node-tn_spec.tn_lnk.tn_link,
-		MIN(node-tn_size - 1, uio-uio_resid), uio);
+		MIN(node-tn_size, uio-uio_resid), uio);
 	} else {
 		error = 0;
 	}