Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin Add mount_overlay.
details: https://anonhg.NetBSD.org/src/rev/fead67bdd317
branches: trunk
changeset: 480811:fead67bdd317
user: wrstuden <wrstuden%NetBSD.org@localhost>
date: Thu Jan 20 19:22:08 2000 +0000
description:
Add mount_overlay.
diffstat:
sbin/Makefile | 3 +-
sbin/mount_overlay/Makefile | 12 +++
sbin/mount_overlay/mount_overlay.8 | 90 +++++++++++++++++++++++++
sbin/mount_overlay/mount_overlay.c | 132 +++++++++++++++++++++++++++++++++++++
4 files changed, 236 insertions(+), 1 deletions(-)
diffs (263 lines):
diff -r e6f081448690 -r fead67bdd317 sbin/Makefile
--- a/sbin/Makefile Thu Jan 20 19:12:28 2000 +0000
+++ b/sbin/Makefile Thu Jan 20 19:22:08 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.65 2000/01/17 02:36:31 itojun Exp $
+# $NetBSD: Makefile,v 1.66 2000/01/20 19:22:08 wrstuden Exp $
# @(#)Makefile 8.5 (Berkeley) 3/31/94
# Not ported: XNSrouted enpload scsiformat startslip
@@ -24,6 +24,7 @@
SUBDIR+= mount_nfs
SUBDIR+= mount_ntfs
SUBDIR+= mount_null
+SUBDIR+= mount_overlay
SUBDIR+= mount_portal
SUBDIR+= mount_procfs
SUBDIR+= mount_umap
diff -r e6f081448690 -r fead67bdd317 sbin/mount_overlay/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/mount_overlay/Makefile Thu Jan 20 19:22:08 2000 +0000
@@ -0,0 +1,12 @@
+# $NetBSD: Makefile,v 1.1 2000/01/20 19:22:10 wrstuden Exp $
+# @(#)Makefile 8.3 (Berkeley) 3/27/94
+
+PROG= mount_overlay
+SRCS= mount_overlay.c getmntopts.c
+MAN= mount_overlay.8
+
+MOUNT= ${.CURDIR}/../mount
+CPPFLAGS+= -I${.CURDIR}/../../sys -I${MOUNT}
+.PATH: ${MOUNT}
+
+.include <bsd.prog.mk>
diff -r e6f081448690 -r fead67bdd317 sbin/mount_overlay/mount_overlay.8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/mount_overlay/mount_overlay.8 Thu Jan 20 19:22:08 2000 +0000
@@ -0,0 +1,90 @@
+.\" $NetBSD: mount_overlay.8,v 1.1 2000/01/20 19:22:10 wrstuden Exp $
+.\"
+.\" Copyright (c) 1992, 1993, 1994
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" This code is derived from software donated to Berkeley by
+.\" John Heidemann of the UCLA Ficus project.
+.\"
+.\" 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.
+.\"
+.\" @(#)mount_null.8 8.6 (Berkeley) 5/1/95
+.\"
+.\"
+.Dd January 18, 2000
+.Dt MOUNT_OVERLAY 8
+.Os NetBSD 1.5
+.Sh NAME
+.Nm mount_overlay
+.Nd mount an overlay filesystem;
+demonstrate the use of an overlay file system layer
+.Sh SYNOPSIS
+.Nm ""
+.Op Fl o Ar options
+.Ar /overlay
+.Ar mount-point
+.Sh DESCRIPTION
+The
+.Nm
+command creates an
+overlay layer, interposing the overlay filesystem between the over-mounted
+file store and future pathname lookups.
+.Pp
+A different device number for the virtual copy is returned by
+.Xr stat 2 ,
+but in other respects it is indistinguishable from the original.
+.Pp
+The
+.Nm
+filesystem differs from the null filesystem in that the
+.Nm
+filesystem does not replicate the sub-tree, it places itself between
+the sub-tree and all future access.
+.Pp
+The overlay layer has two purposes.
+First, it serves as a demonstration of layering by proving a layer
+which does nothing.
+Second, the overlay layer can serve as a prototype layer.
+Since it provides all necessary layer framework,
+new file system layers can be created very easily be starting
+with an overlay layer.
+.Pp
+The internal operation of the overlay layer is identical to that of the
+null layer. See its documentation for details.
+.Sh SEE ALSO
+.Xr mount 8
+.Xr mount_null 8
+.sp
+UCLA Technical Report CSD-910056,
+.Em "Stackable Layers: an Architecture for File System Development" .
+.Sh HISTORY
+The
+.Nm
+utility first appeared in
+.Nx 1.5 .
diff -r e6f081448690 -r fead67bdd317 sbin/mount_overlay/mount_overlay.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/mount_overlay/mount_overlay.c Thu Jan 20 19:22:08 2000 +0000
@@ -0,0 +1,132 @@
+/* $NetBSD: mount_overlay.c,v 1.1 2000/01/20 19:22:11 wrstuden Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993, 1994
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\n\
+ The Regents of the University of California. All rights reserved.\n");
+#endif /* not lint */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)mount_null.c 8.6 (Berkeley) 4/26/95";
+#else
+__RCSID("$NetBSD: mount_overlay.c,v 1.1 2000/01/20 19:22:11 wrstuden Exp $");
+#endif
+#endif /* not lint */
+
+#include <sys/param.h>
+#include <sys/mount.h>
+#include <miscfs/overlay/overlay.h>
+
+#include <err.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "mntopts.h"
+
+const struct mntopt mopts[] = {
+ MOPT_STDOPTS,
+ { NULL }
+};
+
+int main __P((int, char *[]));
+int subdir __P((const char *, const char *));
+void usage __P((void));
+
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ struct overlay_args args;
+ int ch, mntflags;
+ char target[MAXPATHLEN];
+
+ mntflags = 0;
+ while ((ch = getopt(argc, argv, "o:")) != -1)
+ switch(ch) {
+ case 'o':
+ getmntopts(optarg, mopts, &mntflags, 0);
+ break;
+ case '?':
+ default:
+ usage();
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (argc != 2)
+ usage();
+
+ if (realpath(argv[0], target) == 0)
+ err(1, "%s", target);
+
+ args.la.target = target;
+
+ if (mount(MOUNT_OVERLAY, argv[1], mntflags, &args))
+ err(1, "%s on %s", target, argv[1]);
+ exit(0);
+}
+
+int
+subdir(p, dir)
+ const char *p;
+ const char *dir;
+{
+ int l;
+
+ l = strlen(dir);
+ if (l <= 1)
+ return (1);
+
+ if ((strncmp(p, dir, l) == 0) && (p[l] == '/' || p[l] == '\0'))
+ return (1);
+
+ return (0);
+}
+
+void
+usage()
+{
+ (void)fprintf(stderr,
+ "usage: mount_overlay [-o options] /overlay mount_point\n");
+ exit(1);
+}
Home |
Main Index |
Thread Index |
Old Index