Source-Changes-HG archive

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

[src/trunk]: src/sys/fs/tmpfs handle MNT_UPDATE



details:   https://anonhg.NetBSD.org/src/rev/83933a891007
branches:  trunk
changeset: 795797:83933a891007
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Apr 30 01:33:51 2014 +0000

description:
handle MNT_UPDATE

diffstat:

 sys/fs/tmpfs/tmpfs.h        |   3 ++-
 sys/fs/tmpfs/tmpfs_mem.c    |  22 ++++++++++++++++++++--
 sys/fs/tmpfs/tmpfs_vfsops.c |  22 ++++++++++++++++------
 3 files changed, 38 insertions(+), 9 deletions(-)

diffs (110 lines):

diff -r 0a5148b98202 -r 83933a891007 sys/fs/tmpfs/tmpfs.h
--- a/sys/fs/tmpfs/tmpfs.h      Wed Apr 30 01:33:11 2014 +0000
+++ b/sys/fs/tmpfs/tmpfs.h      Wed Apr 30 01:33:51 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tmpfs.h,v 1.48 2013/11/23 16:35:32 rmind Exp $ */
+/*     $NetBSD: tmpfs.h,v 1.49 2014/04/30 01:33:51 christos Exp $      */
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -279,6 +279,7 @@
 
 void           tmpfs_mntmem_init(tmpfs_mount_t *, uint64_t);
 void           tmpfs_mntmem_destroy(tmpfs_mount_t *);
+int            tmpfs_mntmem_set(tmpfs_mount_t *, uint64_t);
 
 size_t         tmpfs_mem_info(bool);
 uint64_t       tmpfs_bytes_max(tmpfs_mount_t *);
diff -r 0a5148b98202 -r 83933a891007 sys/fs/tmpfs/tmpfs_mem.c
--- a/sys/fs/tmpfs/tmpfs_mem.c  Wed Apr 30 01:33:11 2014 +0000
+++ b/sys/fs/tmpfs/tmpfs_mem.c  Wed Apr 30 01:33:51 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tmpfs_mem.c,v 1.4 2011/05/24 01:09:47 rmind Exp $      */
+/*     $NetBSD: tmpfs_mem.c,v 1.5 2014/04/30 01:33:51 christos Exp $   */
 
 /*
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_mem.c,v 1.4 2011/05/24 01:09:47 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_mem.c,v 1.5 2014/04/30 01:33:51 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -65,6 +65,24 @@
        mutex_destroy(&mp->tm_acc_lock);
 }
 
+int
+tmpfs_mntmem_set(struct tmpfs_mount *mp, uint64_t memlimit)
+{
+       int error;
+
+       mutex_enter(&mp->tm_acc_lock);
+       if (round_page(mp->tm_bytes_used) >= memlimit)
+               error = EBUSY;
+       else {
+               error = 0;
+               mp->tm_mem_limit = memlimit;
+       }
+       mutex_exit(&mp->tm_acc_lock);
+       return error;
+}
+
+       
+
 /*
  * tmpfs_mem_info: return the number of available memory pages.
  *
diff -r 0a5148b98202 -r 83933a891007 sys/fs/tmpfs/tmpfs_vfsops.c
--- a/sys/fs/tmpfs/tmpfs_vfsops.c       Wed Apr 30 01:33:11 2014 +0000
+++ b/sys/fs/tmpfs/tmpfs_vfsops.c       Wed Apr 30 01:33:51 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tmpfs_vfsops.c,v 1.59 2014/04/16 18:55:19 maxv Exp $   */
+/*     $NetBSD: tmpfs_vfsops.c,v 1.60 2014/04/30 01:33:51 christos 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.59 2014/04/16 18:55:19 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.60 2014/04/30 01:33:51 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -130,10 +130,6 @@
                return 0;
        }
 
-       if (mp->mnt_flag & MNT_UPDATE) {
-               /* TODO */
-               return EOPNOTSUPP;
-       }
 
        /* Prohibit mounts if there is not enough memory. */
        if (tmpfs_mem_info(true) < TMPFS_PAGES_RESERVED)
@@ -155,6 +151,20 @@
        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)
+                       return EBUSY;
+               if ((error = tmpfs_mntmem_set(tmp, memlimit)) != 0)
+                       return error;
+               tmp->tm_nodes_max = nodes;
+               root = tmp->tm_rooto
+               root->tn_uid = args->ta_root_uid;
+               root->tn_gid = args->ta_root_gid;
+               root->tn_mode = args->ta_root_mode;
+               return 0;
+       }
+
        /* Allocate the tmpfs mount structure and fill it. */
        tmp = kmem_zalloc(sizeof(tmpfs_mount_t), KM_SLEEP);
        if (tmp == NULL)



Home | Main Index | Thread Index | Old Index