diff options
author | Pedro Martelletto <pedro@cvs.openbsd.org> | 2005-05-26 01:30:49 +0000 |
---|---|---|
committer | Pedro Martelletto <pedro@cvs.openbsd.org> | 2005-05-26 01:30:49 +0000 |
commit | ddb658afc5c9fb7d87648d1f4882eee9837d27b8 (patch) | |
tree | 971aa2a6c7f4bed0f3bb1370a55af859fed445e3 | |
parent | 16c626faa1f2b90318b59f0882ee7bb4429f9658 (diff) |
bye bye
-rw-r--r-- | sbin/mount_null/Makefile | 11 | ||||
-rw-r--r-- | sbin/mount_null/mount_null.8 | 223 | ||||
-rw-r--r-- | sbin/mount_null/mount_null.c | 134 | ||||
-rw-r--r-- | sbin/mount_umap/Makefile | 11 | ||||
-rw-r--r-- | sbin/mount_umap/mount_umap.8 | 134 | ||||
-rw-r--r-- | sbin/mount_umap/mount_umap.c | 245 | ||||
-rw-r--r-- | sbin/mount_umap/sample.group.mapfile | 2 | ||||
-rw-r--r-- | sbin/mount_umap/sample.user.mapfile | 3 | ||||
-rw-r--r-- | sbin/mount_umap/umap_manual | 177 | ||||
-rw-r--r-- | sbin/mount_union/Makefile | 11 | ||||
-rw-r--r-- | sbin/mount_union/mount_union.8 | 200 | ||||
-rw-r--r-- | sbin/mount_union/mount_union.c | 145 |
12 files changed, 0 insertions, 1296 deletions
diff --git a/sbin/mount_null/Makefile b/sbin/mount_null/Makefile deleted file mode 100644 index e836513c428..00000000000 --- a/sbin/mount_null/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# $OpenBSD: Makefile,v 1.3 1997/09/21 11:37:26 deraadt Exp $ - -PROG= mount_null -SRCS= mount_null.c getmntopts.c -MAN= mount_null.8 - -MOUNT= ${.CURDIR}/../mount -CFLAGS+= -I${.CURDIR}/../../sys -I${MOUNT} -.PATH: ${MOUNT} - -.include <bsd.prog.mk> diff --git a/sbin/mount_null/mount_null.8 b/sbin/mount_null/mount_null.8 deleted file mode 100644 index 2894a37ee41..00000000000 --- a/sbin/mount_null/mount_null.8 +++ /dev/null @@ -1,223 +0,0 @@ -.\" $OpenBSD: mount_null.8,v 1.21 2005/02/27 14:53:51 pedro Exp $ -.\" $NetBSD: mount_null.8,v 1.4 1996/04/10 20:57:19 thorpej 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. 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.4 (Berkeley) 4/19/94 -.\" -.Dd April 19, 1994 -.Dt MOUNT_NULL 8 -.Os -.Sh NAME -.Nm mount_null -.Nd demonstrate the use of a null file system layer -.Sh SYNOPSIS -.Nm mount_null -.Op Fl o Ar options -.Ar target -.Ar mount_point -.Sh DESCRIPTION -The -.Nm -command creates a -null layer, duplicating a sub-tree of the file system -namespace under another part of the global file system namespace. -It is implemented using a stackable layers technique, and its -.Do -null-nodes -.Dc -stack above -all lower-layer vnodes (not just above directory vnodes). -.Pp -The options are as follows: -.Bl -tag -width Ds -.It Fl o Ar options -Options are specified with a -.Fl o -flag followed by a comma separated string of options. -See the -.Xr mount 8 -man page for possible options and their meanings. -.El -.Pp -The null layer has two purposes. -First, it serves as a demonstration of layering by proving a layer -which does nothing. -Second, the null layer can serve as a prototype layer. -Since it provides all necessary layer framework, -new file system layers can be created very easily by starting -with a null layer. -.Pp -The remainder of this man page examines the null layer as a basis -for constructing new layers. -.\" -.\" -.Sh INSTANTIATING NEW NULL LAYERS -New null layers are created with -.Nm mount_null . -.Nm -takes two arguments: the pathname -of the lower vfs (target-pn) and the pathname where the null -layer will appear in the namespace (mount-point-pn). -After the null layer is put into place, the contents -of target-pn subtree will be aliased under mount-point-pn. -.\" -.\" -.Sh OPERATION OF A NULL LAYER -The null layer is the minimum file system layer, -simply bypassing all possible operations to the lower layer -for processing there. -The majority of its activity centers -on the bypass routine, through which nearly all vnode operations -pass. -.Pp -The bypass routine accepts arbitrary vnode operations for -handling by the lower layer. -It begins by examining vnode -operation arguments and replacing any null-nodes by their -lower-layer equivalents. -It then invokes the operation on the lower layer. -Finally, it replaces the null-nodes -in the arguments and, if a vnode is returned by the operation, -stacks a null-node on top of the returned vnode. -.Pp -Although bypass handles most operations, -.Em vop_getattr , -.Em vop_inactive , -.Em vop_reclaim , -and -.Em vop_print -are not bypassed. -.Em vop_getattr -must change the fsid being returned. -.Em vop_inactive -and -.Em vop_reclaim -are not bypassed so that -they can handle freeing null-layer specific data. -.Em vop_print -is not bypassed to avoid excessive debugging -information. -.\" -.\" -.Sh INSTANTIATING VNODE STACKS -Mounting associates the null layer with a lower layer, -in effect stacking two VFSes. -Vnode stacks are instead created on demand as files are accessed. -.Pp -The initial mount creates a single vnode stack for the -root of the new null layer. -All other vnode stacks are created as a result of vnode operations on -null vnode stacks. -.Pp -New vnode stacks come into existence as a result of -an operation which returns a vnode. -The bypass routine stacks a null-node above the new -vnode before returning it to the caller. -.Pp -For example, imagine mounting a null layer with -.Bd -literal -offset indent -# mount_null /usr/include /dev/layer/null -.Ed -.Pp -Changing directory to -.Pa /dev/layer/null -will assign -the root null-node (which was created when the null layer was mounted). -Now consider opening -.Pa sys . -A -.Em vop_lookup -would be -done on the root null-node. -This operation would bypass through -to the lower layer which would return a vnode representing -the UFS -.Pa sys . -Null_bypass then builds a null-node -aliasing the UFS -.Pa sys -and returns this to the caller. -Later operations on the null-node -.Pa sys -will repeat this -process when constructing other vnode stacks. -.\" -.\" -.Sh CREATING OTHER FILE SYSTEM LAYERS -One of the easiest ways to construct new file system layers is to make -a copy of the null layer, rename all files and variables, and -then begin modifying the copy. -.Xr sed 1 -can be used to easily rename -all variables. -.Pp -The umap layer is an example of a layer descended from the -null layer. -.\" -.\" -.Sh INVOKING OPERATIONS ON LOWER LAYERS -There are two techniques to invoke operations on a lower layer -when the operation cannot be completely bypassed. -Each method is appropriate in different situations. -In both cases, it is the responsibility of the aliasing layer to make -the operation arguments "correct" for the lower layer -by mapping any vnode arguments to the lower layer. -.Pp -The first approach is to call the aliasing layer's bypass routine. -This method is most suitable when you wish to invoke the operation -currently being handled on the lower layer. -It has the advantage that the bypass routine already must do argument mapping. -An example of this is -.Em null_getattrs -in the null layer. -.Pp -A second approach is to directly invoke vnode operations on -the lower layer with the -.Em VOP_OPERATIONNAME -interface. -The advantage of this method is that it is easy to invoke -arbitrary operations on the lower layer. -The disadvantage is that vnodes arguments must be manually mapped. -.\" -.\" -.Sh SEE ALSO -.Xr mount 2 , -.Xr mount 8 , -.Xr umount 8 -.Pp -UCLA Technical Report CSD-910056, -.Em "Stackable Layers: an Architecture for File System Development" . -.Sh HISTORY -The -.Nm -utility first appeared in -.Bx 4.4 . diff --git a/sbin/mount_null/mount_null.c b/sbin/mount_null/mount_null.c deleted file mode 100644 index e2ebdd28492..00000000000 --- a/sbin/mount_null/mount_null.c +++ /dev/null @@ -1,134 +0,0 @@ -/* $OpenBSD: mount_null.c,v 1.12 2005/04/08 20:09:37 jaredy Exp $ */ -/* $NetBSD: mount_null.c,v 1.3 1996/04/13 01:31:49 jtc 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. 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. - */ - -#ifndef lint -char 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.5 (Berkeley) 3/27/94"; -#else -static char rcsid[] = "$OpenBSD: mount_null.c,v 1.12 2005/04/08 20:09:37 jaredy Exp $"; -#endif -#endif /* not lint */ - -#include <sys/param.h> -#include <sys/mount.h> -#include <miscfs/nullfs/null.h> - -#include <err.h> -#include <errno.h> -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> - -#include "mntopts.h" - -const struct mntopt mopts[] = { - MOPT_STDOPTS, - { NULL } -}; - -int subdir(const char *, const char *); -void usage(void); - -int -main(int argc, char *argv[]) -{ - struct null_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); - break; - case '?': - default: - usage(); - } - argc -= optind; - argv += optind; - - if (argc != 2) - usage(); - - if (realpath(argv[0], target) == 0) - err(1, "realpath %s", argv[0]); - - if (subdir(target, argv[1]) || subdir(argv[1], target)) - errx(1, "%s (%s) and %s are not distinct paths", - argv[0], target, argv[1]); - - args.la.target = target; - - if (mount(MOUNT_NULL, argv[1], mntflags, &args)) { - if (errno == EOPNOTSUPP) - errx(1, "%s: Filesystem not supported by kernel", - argv[1]); - else - err(1, "%s", argv[1]); - } - exit(0); -} - -int -subdir(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) -{ - (void)fprintf(stderr, - "usage: mount_null [-o options] target_fs mount_point\n"); - exit(1); -} diff --git a/sbin/mount_umap/Makefile b/sbin/mount_umap/Makefile deleted file mode 100644 index ce16cf7063b..00000000000 --- a/sbin/mount_umap/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# $OpenBSD: Makefile,v 1.3 1997/09/21 11:37:33 deraadt Exp $ - -PROG= mount_umap -SRCS= mount_umap.c getmntopts.c -MAN= mount_umap.8 - -MOUNT= ${.CURDIR}/../mount -CFLAGS+= -I${.CURDIR}/../../sys -I${MOUNT} -.PATH: ${MOUNT} - -.include <bsd.prog.mk> diff --git a/sbin/mount_umap/mount_umap.8 b/sbin/mount_umap/mount_umap.8 deleted file mode 100644 index 8122c2482ca..00000000000 --- a/sbin/mount_umap/mount_umap.8 +++ /dev/null @@ -1,134 +0,0 @@ -.\" $OpenBSD: mount_umap.8,v 1.19 2003/06/03 13:16:08 jmc Exp $ -.\" $NetBSD: mount_umap.8,v 1.4 1996/03/05 02:36:42 thorpej Exp $ -.\" -.\" Copyright (c) 1992, 1993, 1994 -.\" The Regents of the University of California. All rights reserved. -.\" All rights reserved. -.\" -.\" This code is derived from software donated to Berkeley by -.\" Jan-Simon Pendry and from 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. 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_umap.8 8.3 (Berkeley) 3/27/94 -.\" -.Dd March 27, 1994 -.Dt MOUNT_UMAP 8 -.Os -.Sh NAME -.Nm mount_umap -.Nd sample file system layer -.Sh SYNOPSIS -.Nm mount_umap -.Op Fl o Ar options --u -.Ar uid-mapfile --g -.Ar gid-mapfile -.Ar target -.Ar mount_point -.Sh DESCRIPTION -The -.Nm -command is used to mount a subtree of an existing file system -that uses a different set of UIDs and GIDs than the local system. -Such a file system could be mounted from a remote site via NFS or -it could be a file system on removable media brought from some -foreign location that uses a different password file. -.Pp -The options are as follows: -.Bl -tag -width Ds -.It Fl o Ar options -Options are specified with a -.Fl o -flag followed by a comma separated string of options. -See the -.Xr mount 8 -man page for possible options and their meanings. -.It Fl g Ar gid-mapfile -Use the group ID mapping specified in -.Ar gid-mapfile . -This flag is required. -.It Fl u Ar uid-mapfile -Use the user ID mapping specified in -.Ar uid-mapfile . -This flag is required. -.El -.Pp -The -.Nm -command uses a set of files provided by the user to make correspondences -between UIDs and GIDs in the subtree's original environment and -some other set of IDs in the local environment. -For instance, user -smith might have UID 1000 in the original environment, while having -UID 2000 in the local environment. -The -.Nm -command allows the subtree from smith's original environment to be -mapped in such a way that all files with owner UID 1000 look like -they are actually owned by UID 2000. -.Pp -.Em target -should be the current location of the subtree in the -local system's name space. -.Ar mount_point -should be a directory -where the mapped subtree is to be placed. -.Em uid-mapfile -and -.Em gid-mapfile -describe the mappings to be made between identifiers. -.Pp -The format of these files is very simple. -The first line is a count of the number of mappings. -Each subsequent line contains two numbers. -The first is the ID in the mapped subtree, and the second -is the ID in the original subtree. -IDs in the original subtree for which no mapping exists will -be mapped to -.Dq nobody . -At most 64 UIDs can be mapped for a given subtree, and -at most 16 groups can be mapped by a given subtree. -.Pp -The mapfiles can be located anywhere in the file hierarchy, but they -must be owned by root, and they must be writable only by root. -.Nm -will refuse to map the subtree if the ownership or permissions on -these files are improper. -It will also balk if the count of mappings -in the first line of the map files is not correct. -.Sh SEE ALSO -.Xr mount 2 , -.Xr mount 8 , -.Xr mount_null 8 -.Sh HISTORY -The -.Nm -utility first appeared in -.Bx 4.4 . -.Sh BUGS -It is not meant for production use. -The implementation is not very sophisticated. diff --git a/sbin/mount_umap/mount_umap.c b/sbin/mount_umap/mount_umap.c deleted file mode 100644 index 8fb4382f893..00000000000 --- a/sbin/mount_umap/mount_umap.c +++ /dev/null @@ -1,245 +0,0 @@ -/* $OpenBSD: mount_umap.c,v 1.15 2005/04/08 20:09:38 jaredy Exp $ */ -/* $NetBSD: mount_umap.c,v 1.5 1996/04/13 01:32:05 jtc 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. 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. - */ - -#ifndef lint -char 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_umap.c 8.3 (Berkeley) 3/27/94"; -#else -static char rcsid[] = "$OpenBSD: mount_umap.c,v 1.15 2005/04/08 20:09:38 jaredy Exp $"; -#endif -#endif /* not lint */ - -#include <sys/param.h> -#include <sys/mount.h> -#include <sys/stat.h> - -#include <miscfs/umapfs/umap.h> - -#include <err.h> -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "mntopts.h" - -#define ROOTUSER 0 -/* - * This define controls whether any user but the superuser can own and - * write mapfiles. If other users can, system security can be gravely - * compromised. If this is not a concern, undefine SECURITY. - */ -#define MAPSECURITY 1 - -/* - * This routine provides the user interface to mounting a umap layer. - * It takes 4 mandatory parameters. The mandatory arguments are the place - * where the next lower level is mounted, the place where the umap layer is to - * be mounted, the name of the user mapfile, and the name of the group - * mapfile. The routine checks the ownerships and permissions on the - * mapfiles, then opens and reads them. Then it calls mount(), which - * will, in turn, call the umap version of mount. - */ - -const struct mntopt mopts[] = { - MOPT_STDOPTS, - { NULL } -}; - -void usage(void); - -int -main(int argc, char *argv[]) -{ - static char not[] = "; not mounted."; - struct stat statbuf; - struct umap_args args; - FILE *fp, *gfp; - long d1, d2; - u_long umapdata[UMAPFILEENTRIES][2]; - u_long gmapdata[GMAPFILEENTRIES][2]; - int ch, count, gnentries, mntflags, unentries; - char *gmapfile, *umapfile, *source, target[MAXPATHLEN], buf[20]; - - mntflags = 0; - umapfile = gmapfile = NULL; - while ((ch = getopt(argc, argv, "g:o:u:")) != -1) - switch (ch) { - case 'g': - gmapfile = optarg; - break; - case 'o': - getmntopts(optarg, mopts, &mntflags); - break; - case 'u': - umapfile = optarg; - break; - case '?': - default: - usage(); - } - argc -= optind; - argv += optind; - - if (argc != 2 || umapfile == NULL || gmapfile == NULL) - usage(); - - source = argv[0]; - if (realpath(argv[1], target) == NULL) - err(1, "realpath %s", argv[1]); - - /* Read in uid mapping data. */ - if ((fp = fopen(umapfile, "r")) == NULL) - err(1, "%s%s", umapfile, not); - -#ifdef MAPSECURITY - /* - * Check that group and other don't have write permissions on - * this umapfile, and that the umapfile belongs to root. - */ - if (fstat(fileno(fp), &statbuf)) - err(1, "%s%s", umapfile, not); - if (statbuf.st_mode & S_IWGRP || statbuf.st_mode & S_IWOTH) { - strmode(statbuf.st_mode, buf); - err(1, "%s: improper write permissions (%s)%s", - umapfile, buf, not); - } - if (statbuf.st_uid != ROOTUSER) - errx(1, "%s does not belong to root%s", umapfile, not); -#endif /* MAPSECURITY */ - - if ((fscanf(fp, "%d\n", &unentries)) != 1) - errx(1, "%s: nentries not found%s", umapfile, not); - if (unentries > UMAPFILEENTRIES) - errx(1, - "maximum number of entries is %d%s", UMAPFILEENTRIES, not); -#if 0 - (void)printf("reading %d entries\n", unentries); -#endif - for (count = 0; count < unentries; ++count) { - if ((fscanf(fp, "%lu %lu\n", &d1, &d2)) != 2) { - if (ferror(fp)) - err(1, "%s%s", umapfile, not); - if (feof(fp)) - errx(1, "%s: unexpected end-of-file%s", - umapfile, not); - errx(1, "%s: illegal format (line %d)%s", - umapfile, count + 2, not); - } - umapdata[count][0] = d1; - umapdata[count][1] = d2; -#if 0 - /* Fix a security hole. */ - if (umapdata[count][1] == 0) - errx(1, "mapping id 0 not permitted (line %d)%s", - count + 2, not); -#endif - } - - /* Read in gid mapping data. */ - if ((gfp = fopen(gmapfile, "r")) == NULL) - err(1, "%s%s", gmapfile, not); - -#ifdef MAPSECURITY - /* - * Check that group and other don't have write permissions on - * this group mapfile, and that the file belongs to root. - */ - if (fstat(fileno(gfp), &statbuf)) - err(1, "%s%s", gmapfile, not); - if (statbuf.st_mode & S_IWGRP || statbuf.st_mode & S_IWOTH) { - strmode(statbuf.st_mode, buf); - err(1, "%s: improper write permissions (%s)%s", - gmapfile, buf, not); - } - if (statbuf.st_uid != ROOTUSER) - errx(1, "%s does not belong to root%s", gmapfile, not); -#endif /* MAPSECURITY */ - - if ((fscanf(gfp, "%d\n", &gnentries)) != 1) - errx(1, "%s: nentries not found%s", gmapfile, not); - if (gnentries > GMAPFILEENTRIES) - errx(1, - "maximum number of entries is %d%s", GMAPFILEENTRIES, not); -#if 0 - (void)printf("reading %d group entries\n", gnentries); -#endif - - for (count = 0; count < gnentries; ++count) { - if ((fscanf(gfp, "%lu %lu\n", &d1, &d2)) != 2) { - if (ferror(gfp)) - err(1, "%s%s", gmapfile, not); - if (feof(gfp)) - errx(1, "%s: unexpected end-of-file%s", - gmapfile, not); - errx(1, "%s: illegal format (line %d)%s", - gmapfile, count + 2, not); - } - gmapdata[count][0] = d1; - gmapdata[count][1] = d2; - } - - - /* Setup mount call args. */ - args.la.target = source; - args.unentries = unentries; - args.umapdata = umapdata; - args.gnentries = gnentries; - args.gmapdata = gmapdata; - - if (mount(MOUNT_UMAP, target, mntflags, &args)) { - if (errno == EOPNOTSUPP) - errx(1, "%s: Filesystem not supported by kernel", - argv[1]); - else - err(1, "%s", argv[1]); - } - exit(0); -} - -void -usage(void) -{ - (void)fprintf(stderr, -"usage: mount_umap [-o options] -u usermap -g groupmap target_fs mount_point\n"); - exit(1); -} diff --git a/sbin/mount_umap/sample.group.mapfile b/sbin/mount_umap/sample.group.mapfile deleted file mode 100644 index 69d3d77c636..00000000000 --- a/sbin/mount_umap/sample.group.mapfile +++ /dev/null @@ -1,2 +0,0 @@ -1 -1200 1200 diff --git a/sbin/mount_umap/sample.user.mapfile b/sbin/mount_umap/sample.user.mapfile deleted file mode 100644 index 03c59e9e756..00000000000 --- a/sbin/mount_umap/sample.user.mapfile +++ /dev/null @@ -1,3 +0,0 @@ -2 -5217 5217 -3 3 diff --git a/sbin/mount_umap/umap_manual b/sbin/mount_umap/umap_manual deleted file mode 100644 index 4fcae246af2..00000000000 --- a/sbin/mount_umap/umap_manual +++ /dev/null @@ -1,177 +0,0 @@ -% $OpenBSD: umap_manual,v 1.3 2002/06/09 08:13:08 todd Exp $ -% $NetBSD: umap_manual,v 1.2 1995/03/18 14:58:19 cgd Exp $ - -\appendix -\section{The umap Layer} \label{sect:umap} - -\subsection{Introduction} - -Normally, the file system is expected to span a single administrative domain. -An administrative domain, for these purposes, is a machine or set of -machines that share common password file information, usually through -the yellow pages mechanism. File hierarchies that span more -than one domain leads to certain problems, since the same numerical -UID in one domain may correspond to a different user in another domain. -If the system administrator is very careful to ensure that both domains -contain identical user ID information, The umap layer can be used to -run between those domains without changes - -The umap layer is a file system layer that sits on top of the normal -file layer. The umap layer maps Unix-style UIDs from -one domain into the UIDs in the other domain. By setting up the mappings -properly, the same user with different UIDs in two domains can be seen -as the same user, from the system point of view, or, conversely, two -different users with the same UID in the two domains can be distinguished. - -First, we define some terms. ``User'' refers to the human (or daemon) that -has privileges to login, run programs, and access files. ``UID''refers to -the numerical identifier that uniquely identifies the user within a -single domain. ``Login name'' refers to the character string the user -types to log into the system. ``GID'' refers to the numerical group -identifier used by Unix systems to identify groups of users. ``Group -name'' is the character string name attached to a particular GID in the -local {\sf /etc/groups} file or the yellow pages groups file. - -In order for the umap layer to work properly, all users -in either domain must have password file entries in both domains. -They do not, however, have to have the same numerical UID, nor even the -same character string login name (the latter is highly recommended, -if possible, however). Any user not having a UID in one domain will be -treated as the special user NOBODY by the other domain, probably with -undesirable consequences. Any user not owning any files in the shared -sub-trees need not be given a UID in the other domain. - -Groups work similarly. The umap layer can translate group ID's between -domains in the same manner as UID's. Again, any group that wishes to -participate must have a group ID in both domains, -though it need not be the same GID in both. If a group in one domain is not -known in the other domain, that group will be treated as being NULLGROUP. -The umap layer has no provisions for enrolling UID's from other domains -as group members, but, since each user from each domain must have some -UID in every domain, the UID in the local domain can be used to enroll -the user in the local groups. - -NOBODY and NULLGROUP are special reserved UID's and GID's, respectively. -NOBODY is user 32767. NULLGROUP is group 65534. If the system administrator -wants to have an appropriate text string appear when these UID's are -encountered by programs like {\sf ls -l}, he should add these values to -the password and {\sf /etc/groups} file, or to the appropriate yellow pages. -If these IDs are already in use in that domain, different values can be -used for NOBODY and NULLGROUP, but that will require a recompilation of -the umap layer code and, as a result, the entire kernel. These -values are defined in the {\sf umap\_info.h} file, kept with the rest of the -umap source code. - -When the umap layer is in use, one of the participating domains is declared -to be the master. All UID and GID information stored for participating files -will be stored in vnodes using its mappings, no matter what site the copies of -the files are stored at. The master domain therefore need not run a copy -of the umap layer, as it already has all of the correct mappings. All -other domains must run a umap layer on top of any other layers they use. - -\subsection{Setting Up a umap Layer} - -The system administrator of a system needing to use the umap layer -must take several actions. -First, he must create files containing the necessary UID -and GID mappings. There is a separate file for user and group IDs. The -format of the files is the same. The first line contains the total number -of entries in the file. Each subsequent line contains one mapping. A -mapping line consists of two numerical UIDs, separated by white space. -The first is the UID of a user on the local machine. The second is the -UID for the same user on the master machine. The maximum number of users -that can be mapped for a single shared sub-tree is 64. The maximum number of -groups that can be mapped for a single sub-tree is 16. These constants -are set in the {\sf umap\_info.h} file, and can be changed, but changing them -requires recompilation. Separate mapping files can be used for each shared -subtree, or the same mapping files can be shared by several sub-trees. - -Below is a sample UID mapping file. There are four entries. UID 5 is mapped -to 5, 521 to 521, and 7000 to 7000. UID 2002 is mapped to 604. On this -machine, the UID's for users 5, 521, and 7000 are the same as on the master, -but UID 2002 is for a user whose UID on the master machine is 604. All -files in the sub-tree belonging to that user have UID 604 in their inodes, -even on this machine, but the umap layer will ensure that anyone running -under UID 2002 will have all files in this sub-tree owned by 604 treated as if -they were owned by 2002. An {\sf ls -l} on a file owned by 604 in this sub-tree -will show the login name associated with UID 2002 as the owner. - -\noindent4\newline -5 5\newline -521 521\newline -2002 604\newline -7000 7000\newline - -The user and group mapping files should be owned by the root user, and -should be writable only by that user. If they are not owned by root, or -are writable by some other user, the umap mounting command will abort. - -Normally, the sub-treeis grafted directly into the place in -the file hierarchy where the it should appear to users.Using the umap -layer requires that the sub-tree be grafted somewhere else, and -the umap layer be mounted in the desired position in the file hierarchy. -Depending on the situation, the underlying sub-tree can be wherever is -convenient. - -\subsection{Troubleshooting umap Layer Problems} - -The umap layer code was not built with special convenience or -robustness in mind, as it is expected to be superseded with a better -user ID mapping strategy in the near future. As a result, it is not -very forgiving of errors in being set up. Here are some possible -problems, and what to do about them. - -\begin{itemize} - - -\item{Problem: A file belongs to NOBODY, or group NULLGROUP. - -Fixes: The mapping files don't know about this file's real user or group. -Either they are not in the mapping files, or the counts on the number of -entries in the mapping files are too low, so entries at the end (including -these) are being ignored. Add the entries or fix the counts, and either -unmount and remount the sub-tree, or reboot.} - -\item{Problem: A normal operation does not work. - -Fixes: Possibly, some mapping has not been set properly. Check to -see which files are used by the operation and who they appear to be -owned by. If they are owned by NOBODY or some other suspicious user, -there may be a problem in the mapping files. Be sure to check groups, -too. As above, if the counts of mappings in the mapping files are lower -than the actual numbers of pairs, pairs at the end of the file will be -ignored. If any changes are made in the mapping files, you will need to -either unmount and remount or reboot before they will take effect. - -Another possible problem can arise because not all Unix utilities -rely exclusively on numeric UID for identification. For instance, -SCCS saves the login name in files. If a user's login name on two machines -isn't the same, SCCS may veto an operation even though Unix file permissions, -as checked by the umap layer, may say it's OK. There's not much to be -done in such cases, unless the login name can be changed or one fiddles -improperly with SCCS information. There may be other, undiscovered cases -where similar problems arise, some of which may be even harder to handle.} - -\item{Problem: Someone has access permissions he should not have. - -Fixes: This is probably caused by a mistake in the mapping files. Check -both user and group mapping files. If any changes are made in the mapping -files, you will need to unmount and remount the sub-tree or reboot before they -will take effect.} - -\item{Problem: {\sf ls -l} (or a similar program) shows the wrong user for a file. - -Fixes: Probably a mistake in the mapping files. In particular, if -two local UIDs are mapped to a single master UID, stat calls will assign -ownership to the first local UID occurring in the file, which may or may -not be what was intended. (Generally speaking, mapping two local UIDs to -a single master UID is a bad idea, but the software will not prevent it. -Similarly, mapping a single local UID to two master UIDs is a bad idea, -but will not be prevented. In this case, only the first mapping of the -local UID will be done. The second, and all subsequent ones, will be -ignored.) If any changes are made in the mapping files, you will need to -unmount and remount the sub-tree or reboot before they will take effect.} - -\end{itemize} - -\end{document} diff --git a/sbin/mount_union/Makefile b/sbin/mount_union/Makefile deleted file mode 100644 index 39083f5d92e..00000000000 --- a/sbin/mount_union/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# $OpenBSD: Makefile,v 1.3 1997/09/21 11:37:36 deraadt Exp $ - -PROG= mount_union -SRCS= mount_union.c getmntopts.c -MAN= mount_union.8 - -MOUNT= ${.CURDIR}/../mount -CFLAGS+= -I${.CURDIR}/../../sys -I${MOUNT} -.PATH: ${MOUNT} - -.include <bsd.prog.mk> diff --git a/sbin/mount_union/mount_union.8 b/sbin/mount_union/mount_union.8 deleted file mode 100644 index 9aba927063f..00000000000 --- a/sbin/mount_union/mount_union.8 +++ /dev/null @@ -1,200 +0,0 @@ -.\" $OpenBSD: mount_union.8,v 1.14 2003/06/02 20:06:16 millert Exp $ -.\" $NetBSD: mount_union.8,v 1.4 1995/09/29 06:44:02 jtc Exp $ -.\" -.\" Copyright (c) 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. 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_union.8 8.6 (Berkeley) 3/27/94 -.\" -.Dd March 27, 1994 -.Dt MOUNT_UNION 8 -.Os -.Sh NAME -.Nm mount_union -.Nd mount union filesystems -.Sh SYNOPSIS -.Nm mount_union -.Op Fl br -.Op Fl o Ar options -.Ar directory -.Ar uniondir -.Sh DESCRIPTION -The -.Nm -command -attaches -.Ar directory -above -.Ar uniondir -in such a way that the contents of both directory trees remain visible. -By default, -.Ar directory -becomes the -.Em upper -layer and -.Ar uniondir -becomes the -.Em lower -layer. -.Pp -The options are as follows: -.Bl -tag -width Ds -.It Fl b -Invert the default position, so that -.Ar directory -becomes the lower layer and -.Ar uniondir -becomes the upper layer. -However, -.Ar uniondir -remains the mount point. -.It Fl o Ar options -Options are specified with a -.Fl o -flag followed by a comma separated string of options. -See the -.Xr mount 8 -man page for possible options and their meanings. -.It Fl r -Hide the lower layer completely in the same way as mounting with -.Xr mount_null 8 . -.El -.Pp -To enforce filesystem security, the user mounting the filesystem -must be superuser or else have write permission on the mounted-on -directory. -.Pp -Filenames are looked up in the upper layer and then in the -lower layer. -If a directory is found in the lower layer, and there is no entry -in the upper layer, then a -.Em shadow -directory will be created in the upper layer. -It will be owned by the user who originally did the union mount, -with mode -.Dq rwxrwxrwx -(0777) modified by the umask in effect at that time. -.Pp -If a file exists in the upper layer then there is no way to access -a file with the same name in the lower layer. -If necessary, a combination of loopback and union mounts can be made -which will still allow the lower files to be accessed by a different -pathname. -.Pp -Except in the case of a directory, -access to an object is granted via the normal filesystem access checks. -For directories, the current user must have access to both the upper -and lower directories (should they both exist). -.Pp -Requests to create or modify objects in -.Ar uniondir -are passed to the upper layer with the exception of a few special cases. -An attempt to open for writing a file which exists in the lower layer -causes a copy of the -.Em entire -file to be made to the upper layer, and then for the upper layer copy -to be opened. -Similarly, an attempt to truncate a lower layer file to zero length -causes an empty file to be created in the upper layer. -Any other operation which would ultimately require modification to -the lower layer fails with -.Dv EROFS . -.Pp -The union filesystem manipulates the namespace, rather than -individual filesystems. -The union operation applies recursively down the directory tree -now rooted at -.Ar uniondir . -Thus any filesystems which are mounted under -.Ar uniondir -will take part in the union operation. -This differs from the -.Em union -option to -.Xr mount 8 -which only applies the union operation to the mount point itself, -and then only for lookups. -.Sh EXAMPLES -The commands -.Bd -literal -offset indent -# mount -t cd9660 -o ro /dev/cd0a /usr/src -# mount -t union /var/obj /usr/src -.Ed -.Pp -mount the CD-ROM drive -.Pa /dev/cd0a -on -.Pa /usr/src -and then attaches -.Pa /var/obj -on top. -For most purposes the effect of this is to make the -source tree appear writable -even though it is stored on a CD-ROM. -.Pp -The command -.Bd -literal -offset indent -# mount -t union -o -b /sys $HOME/sys -.Ed -.Pp -attaches the system source tree below the -.Pa sys -directory in the user's home directory. -This allows individual users to make private changes -to the source, and build new kernels, without those -changes becoming visible to other users. -Note that the files in the lower layer remain -accessible via -.Pa /sys . -.Sh SEE ALSO -.Xr intro 2 , -.Xr mount 2 , -.Xr fstab 5 , -.Xr mount 8 , -.Xr mount_null 8 , -.Xr umount 8 -.Sh HISTORY -The -.Nm -command first appeared in -.Bx 4.4 . -.Sh BUGS -Without whiteout support from the filesystem backing the upper layer, -there is no way that delete and rename operations on lower layer -objects can be done. -.Dv EROFS -is returned for these kind of operations along with any others -which would make modifications to the lower layer, such as -.Xr chmod 1 . -.Pp -Running -.Xr find 1 -over a union tree has the side-effect of creating -a tree of shadow directories in the upper layer. diff --git a/sbin/mount_union/mount_union.c b/sbin/mount_union/mount_union.c deleted file mode 100644 index a4bff6f6f0c..00000000000 --- a/sbin/mount_union/mount_union.c +++ /dev/null @@ -1,145 +0,0 @@ -/* $OpenBSD: mount_union.c,v 1.11 2005/04/08 20:09:38 jaredy Exp $ */ -/* $NetBSD: mount_union.c,v 1.3 1996/04/13 01:32:11 jtc 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. 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. - */ - -#ifndef lint -char 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_union.c 8.5 (Berkeley) 3/27/94"; -#else -static char rcsid[] = "$OpenBSD: mount_union.c,v 1.11 2005/04/08 20:09:38 jaredy Exp $"; -#endif -#endif /* not lint */ - -#include <sys/param.h> -#include <sys/mount.h> - -#include <miscfs/union/union.h> - -#include <err.h> -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "mntopts.h" - -const struct mntopt mopts[] = { - MOPT_STDOPTS, - { NULL } -}; - -int subdir(const char *, const char *); -void usage(void); - -int -main(int argc, char *argv[]) -{ - struct union_args args; - int ch, mntflags; - char target[MAXPATHLEN]; - - mntflags = 0; - args.mntflags = UNMNT_ABOVE; - while ((ch = getopt(argc, argv, "bo:r")) != -1) - switch (ch) { - case 'b': - args.mntflags &= ~UNMNT_OPMASK; - args.mntflags |= UNMNT_BELOW; - break; - case 'o': - getmntopts(optarg, mopts, &mntflags); - break; - case 'r': - args.mntflags &= ~UNMNT_OPMASK; - args.mntflags |= UNMNT_REPLACE; - break; - case '?': - default: - usage(); - /* NOTREACHED */ - } - argc -= optind; - argv += optind; - - if (argc != 2) - usage(); - - if (realpath(argv[0], target) == 0) - err(1, "realpath %s", argv[0]); - - if (subdir(target, argv[1]) || subdir(argv[1], target)) - errx(1, "%s (%s) and %s are not distinct paths", - argv[0], target, argv[1]); - - args.target = target; - - if (mount(MOUNT_UNION, argv[1], mntflags, &args)) { - if (errno == EOPNOTSUPP) - errx(1, "%s: Filesystem not supported by kernel", - argv[1]); - else - err(1, "%s", argv[1]); - } - exit(0); -} - -int -subdir(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) -{ - (void)fprintf(stderr, - "usage: mount_union [-br] [-o options] target_fs mount_point\n"); - exit(1); -} |