Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/tmpfs Implement most of mount -ur functionality for t...



details:   https://anonhg.NetBSD.org/src/rev/d4f530201d38
branches:  trunk
changeset: 344080:d4f530201d38
user:      joerg <joerg%NetBSD.org@localhost>
date:      Sat Mar 12 08:51:13 2016 +0000

description:
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.

diffstat:

 sys/fs/tmpfs/tmpfs_vfsops.c |   6 +++---
 sys/fs/tmpfs/tmpfs_vnops.c  |  14 ++++++++++++--
 2 files changed, 15 insertions(+), 5 deletions(-)

diffs (69 lines):

diff -r 46f5803fb764 -r d4f530201d38 sys/fs/tmpfs/tmpfs_vfsops.c
--- a/sys/fs/tmpfs/tmpfs_vfsops.c       Sat Mar 12 08:45:23 2016 +0000
+++ b/sys/fs/tmpfs/tmpfs_vfsops.c       Sat Mar 12 08:51:13 2016 +0000
@@ -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 @@
        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,
diff -r 46f5803fb764 -r d4f530201d38 sys/fs/tmpfs/tmpfs_vnops.c
--- a/sys/fs/tmpfs/tmpfs_vnops.c        Sat Mar 12 08:45:23 2016 +0000
+++ b/sys/fs/tmpfs/tmpfs_vnops.c        Sat Mar 12 08:51:13 2016 +0000
@@ -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 @@
 
        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 @@
                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;
 



Home | Main Index | Thread Index | Old Index