Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add overlay, a layered file system which overlays itself on
details: https://anonhg.NetBSD.org/src/rev/6301c32f797a
branches: trunk
changeset: 480809:6301c32f797a
user: wrstuden <wrstuden%NetBSD.org@localhost>
date: Thu Jan 20 19:06:13 2000 +0000
description:
Add overlay, a layered file system which overlays itself on
the underlying fs, rather than exporting it to another part of the
directory name space.
diffstat:
sys/lkm/vfs/miscfs/Makefile | 4 +-
sys/lkm/vfs/miscfs/overlay/Makefile | 14 +
sys/lkm/vfs/miscfs/overlay/lkminit_vfs.c | 70 +++++++
sys/miscfs/Makefile | 5 +-
sys/miscfs/overlay/Makefile | 7 +
sys/miscfs/overlay/overlay.h | 130 ++++++++++++++
sys/miscfs/overlay/overlay_vfsops.c | 287 +++++++++++++++++++++++++++++++
sys/miscfs/overlay/overlay_vnops.c | 174 ++++++++++++++++++
sys/sys/mount.h | 3 +-
sys/sys/vnode.h | 5 +-
10 files changed, 692 insertions(+), 7 deletions(-)
diffs (truncated from 767 to 300 lines):
diff -r 3e7d16d5b5b9 -r 6301c32f797a sys/lkm/vfs/miscfs/Makefile
--- a/sys/lkm/vfs/miscfs/Makefile Thu Jan 20 18:28:33 2000 +0000
+++ b/sys/lkm/vfs/miscfs/Makefile Thu Jan 20 19:06:13 2000 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.3 1997/02/18 06:08:51 scottr Exp $
+# $NetBSD: Makefile,v 1.4 2000/01/20 19:06:15 wrstuden Exp $
-SUBDIR= fdesc kernfs nullfs portal procfs umapfs
+SUBDIR= fdesc kernfs nullfs overlay portal procfs umapfs
#
# XXX the union LKM is currently broken.
diff -r 3e7d16d5b5b9 -r 6301c32f797a sys/lkm/vfs/miscfs/overlay/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/lkm/vfs/miscfs/overlay/Makefile Thu Jan 20 19:06:13 2000 +0000
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile,v 1.1 2000/01/20 19:06:15 wrstuden Exp $
+
+.include "../Makefile.inc"
+
+.PATH: $S/miscfs/overlay $S/miscfs/genfs ${.CURDIR}/../..
+
+MKMAN= no
+
+KMOD= overlay
+
+SRCS= lkminit_vfs.c
+SRCS+= overlay_vfsops.c overlay_vnops.c
+
+.include <bsd.kmod.mk>
diff -r 3e7d16d5b5b9 -r 6301c32f797a sys/lkm/vfs/miscfs/overlay/lkminit_vfs.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/lkm/vfs/miscfs/overlay/lkminit_vfs.c Thu Jan 20 19:06:13 2000 +0000
@@ -0,0 +1,70 @@
+/* $NetBSD: lkminit_vfs.c,v 1.1 2000/01/20 19:06:15 wrstuden Exp $ */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Michael Graff <explorer%flame.com@localhost>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/ioctl.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/mount.h>
+#include <sys/exec.h>
+#include <sys/lkm.h>
+#include <sys/file.h>
+#include <sys/errno.h>
+
+/*
+ * This is the vfsops table for the file system in question
+ */
+extern struct vfsops overlay_vfsops;
+
+/*
+ * declare the filesystem
+ */
+MOD_VFS("overlay", -1, &overlay_vfsops);
+
+/*
+ * entry point
+ */
+int
+overlay_lkmentry(lkmtp, cmd, ver)
+ struct lkm_table *lkmtp;
+ int cmd;
+ int ver;
+{
+
+ DISPATCH(lkmtp, cmd, ver, lkm_nofunc, lkm_nofunc, lkm_nofunc)
+}
diff -r 3e7d16d5b5b9 -r 6301c32f797a sys/miscfs/Makefile
--- a/sys/miscfs/Makefile Thu Jan 20 18:28:33 2000 +0000
+++ b/sys/miscfs/Makefile Thu Jan 20 19:06:13 2000 +0000
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.1 1998/06/12 23:23:00 cgd Exp $
+# $NetBSD: Makefile,v 1.2 2000/01/20 19:06:14 wrstuden Exp $
-SUBDIR= fdesc fifofs genfs kernfs nullfs portal procfs specfs umapfs union
+SUBDIR= fdesc fifofs genfs kernfs nullfs overlay portal
+SUBDIR+= procfs specfs umapfs union
KDIR= /sys/miscfs
INCSDIR= /usr/include/miscfs
diff -r 3e7d16d5b5b9 -r 6301c32f797a sys/miscfs/overlay/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/miscfs/overlay/Makefile Thu Jan 20 19:06:13 2000 +0000
@@ -0,0 +1,7 @@
+# $NetBSD: Makefile,v 1.1 2000/01/20 19:06:15 wrstuden Exp $
+
+INCSDIR= /usr/include/miscfs/overlay
+
+INCS= overlay.h
+
+.include <bsd.kinc.mk>
diff -r 3e7d16d5b5b9 -r 6301c32f797a sys/miscfs/overlay/overlay.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/miscfs/overlay/overlay.h Thu Jan 20 19:06:13 2000 +0000
@@ -0,0 +1,130 @@
+/* $NetBSD: overlay.h,v 1.1 2000/01/20 19:06:15 wrstuden Exp $ */
+
+/*
+ * Copyright (c) 1999 National Aeronautics & Space Administration
+ * All rights reserved.
+ *
+ * This software was written by William Studnemund of the
+ * Numerical Aerospace Similation Facility, NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the the name of the National Aeronautics & Space Administration
+ * nor the names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NATIONAL AERONAUTICS & SPACE ADMINISTRATION
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ADMINISTRATION OR CONTRIB-
+ * UTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software donated to Berkeley by
+ * Jan-Simon Pendry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: Id: lofs.h,v 1.8 1992/05/30 10:05:43 jsp Exp
+ * @(#)null.h 8.2 (Berkeley) 1/21/94
+ */
+
+#include <miscfs/genfs/layer.h>
+
+struct overlay_args {
+ struct layer_args la; /* generic layerfs args */
+};
+/*
+ * We leave ova_target for two reasons. One, We can tell the difference
+ * between a mount_overlay -u and a call from mountd as the former will
+ * pass a pointer to a string while the latter will pass NULL. Two,
+ * filesystems based on the overlay layer might have use for it.
+ */
+#define ova_target la.target
+#define ova_export la.export
+
+#ifdef _KERNEL
+struct overlay_mount {
+ struct layer_mount lm; /* generic layerfs mount stuff */
+};
+#define ovm_vfs lm.layerm_vfs
+#define ovm_rootvp lm.layerm_rootvp
+#define ovm_export lm.layerm_export
+#define ovm_flags lm.layerm_flags
+#define ovm_size lm.layerm_size
+#define ovm_tag lm.layerm_tag
+#define ovm_bypass lm.layerm_bypass
+#define ovm_alloc lm.layerm_alloc
+#define ovm_vnodeop_p lm.layerm_vnodeop_p
+#define ovm_node_hashtbl lm.layerm_node_hashtbl
+#define ovm_node_hash lm.layerm_node_hash
+#define ovm_hashlock lm.layerm_hashlock
+
+/*
+ * A cache of vnode references
+ */
+struct overlay_node {
+ struct layer_node ln;
+};
+#define ov_hash ln.layer_hash
+#define ov_lowervp ln.layer_lowervp
+#define ov_vnode ln.layer_vnode
+#define ov_flags ln.layer_flags
+
+#define MOUNTTOOVERLAYMOUNT(mp) ((struct overlay_mount *)((mp)->mnt_data))
+#define VTOOVERLAY(vp) ((struct overlay_node *)(vp)->v_data)
+#define OVERLAYTOV(xp) ((xp)->ov_vnode)
+#ifdef OVERLAYFS_DIAGNOSTIC
+extern struct vnode *layer_checkvp __P((struct vnode *vp, char *fil, int lno));
+#define OVERLAYVPTOLOWERVP(vp) layer_checkvp((vp), __FILE__, __LINE__)
+#else
+#define OVERLAYVPTOLOWERVP(vp) (VTOOVERLAY(vp)->ov_lowervp)
+#endif
+
+extern int (**overlay_vnodeop_p) __P((void *));
+extern struct vfsops overlay_vfsops;
+
+#endif /* _KERNEL */
diff -r 3e7d16d5b5b9 -r 6301c32f797a sys/miscfs/overlay/overlay_vfsops.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/miscfs/overlay/overlay_vfsops.c Thu Jan 20 19:06:13 2000 +0000
@@ -0,0 +1,287 @@
+/* $NetBSD: overlay_vfsops.c,v 1.1 2000/01/20 19:06:15 wrstuden Exp $ */
+
+/*
+ * Copyright (c) 1999, 2000 National Aeronautics & Space Administration
+ * All rights reserved.
+ *
+ * This software was written by William Studenmund of the
+ * Numerical Aerospace Similation Facility, NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the the name of the National Aeronautics & Space Administration
+ * nor the names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NATIONAL AERONAUTICS & SPACE ADMINISTRATION
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ADMINISTRATION OR CONTRIB-
+ * UTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
Home |
Main Index |
Thread Index |
Old Index