Module Name:    src
Committed By:   joerg
Date:           Sat Mar 12 08:51:13 UTC 2016

Modified Files:
        src/sys/fs/tmpfs: tmpfs_vfsops.c tmpfs_vnops.c

Log Message:
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.66 -r1.67 src/sys/fs/tmpfs/tmpfs_vfsops.c
cvs rdiff -u -r1.123 -r1.124 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.66 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.67
--- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.66	Sat Mar 12 08:45:23 2016
+++ src/sys/fs/tmpfs/tmpfs_vfsops.c	Sat Mar 12 08:51:13 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: tmpfs_vfsops.c,v 1.66 2016/03/12 08:45:23 joerg Exp $	*/
+/*	$NetBSD: tmpfs_vfsops.c,v 1.67 2016/03/12 08:51:13 joerg Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.66 2016/03/12 08:45:23 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.67 2016/03/12 08:51:13 joerg Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -210,7 +210,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.123 src/sys/fs/tmpfs/tmpfs_vnops.c:1.124
--- src/sys/fs/tmpfs/tmpfs_vnops.c:1.123	Mon Jul  6 10:07:12 2015
+++ src/sys/fs/tmpfs/tmpfs_vnops.c	Sat Mar 12 08:51:13 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: tmpfs_vnops.c,v 1.123 2015/07/06 10:07:12 hannken Exp $	*/
+/*	$NetBSD: tmpfs_vnops.c,v 1.124 2016/03/12 08:51:13 joerg 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.123 2015/07/06 10:07:12 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.124 2016/03/12 08:51:13 joerg Exp $");
 
 #include <sys/param.h>
 #include <sys/dirent.h>
@@ -572,6 +572,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;
 
@@ -1242,6 +1247,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;
 

Reply via email to