1 /* $NetBSD: overlay_vnops.c,v 1.9.16.4 2005/11/10 14:10:32 skrll Exp $ */
4 * Copyright (c) 1999, 2000 National Aeronautics & Space Administration
7 * This software was written by William Studenmund of the
8 * Numerical Aerospace Simulation Facility, NASA Ames Research Center.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the National Aeronautics & Space Administration
19 * nor the names of its contributors may be used to endorse or promote
20 * products derived from this software without specific prior written
23 * THIS SOFTWARE IS PROVIDED BY THE NATIONAL AERONAUTICS & SPACE ADMINISTRATION
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ADMINISTRATION OR CONTRIB-
27 * UTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
28 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
36 * Copyright (c) 1992, 1993
37 * The Regents of the University of California. All rights reserved.
39 * This code is derived from software contributed to Berkeley by
40 * John Heidemann of the UCLA Ficus project.
42 * Redistribution and use in source and binary forms, with or without
43 * modification, are permitted provided that the following conditions
45 * 1. Redistributions of source code must retain the above copyright
46 * notice, this list of conditions and the following disclaimer.
47 * 2. Redistributions in binary form must reproduce the above copyright
48 * notice, this list of conditions and the following disclaimer in the
49 * documentation and/or other materials provided with the distribution.
50 * 3. Neither the name of the University nor the names of its contributors
51 * may be used to endorse or promote products derived from this software
52 * without specific prior written permission.
54 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66 * @(#)null_vnops.c 8.6 (Berkeley) 5/27/95
69 * @(#)lofs_vnops.c 1.2 (Berkeley) 6/18/92
70 * $Id: overlay_vnops.c,v 1.16 2005/12/11 12:24:51 christos Exp $
72 * @(#)null_vnodeops.c 1.20 92/07/07 UCLA Ficus project
78 * (See mount_overlay(8) for more information.)
80 * The overlay layer has two purposes. First, it serves as a demonstration
81 * of layering by providing a layer which really does nothing (the null
82 * layer makes the underlying files appear elsewhere in the file hierarchy).
83 * Second, the overlay layer can serve as a prototype layer. Since it
84 * provides all necessary layer framework, new file system layers can be
85 * created very easily by starting with an overlay layer.
87 * The remainder of this comment examines the overlay layer as a basis
88 * for constructing new layers.
91 * INSTANTIATING NEW OVERLAY LAYERS
93 * New overlay layers are created with mount_overlay(8).
94 * mount_overlay(8) takes two arguments, an ignored string
95 * and the pathname which the overlay will mount over. After
96 * the overlay layer is put into place, all access to the mount
97 * point path will proceed through the overlay layer.
100 * OPERATION OF AN OVERLAY LAYER
102 * The operation of an overlay layer is identical to that of a null
103 * layer. See the null layer (and layerfs) documentation for more info.
106 * CREATING OTHER FILE SYSTEM LAYERS
108 * One of the easiest ways to construct new file system layers is to make
109 * a copy of either the null layer or the overlay layer, rename all files
110 * and variables, and then begin modifying the copy. sed(1) can be used to
111 * easily rename all variables.
113 * The choice between using a null and an overlay layer depends on
114 * the desirability of retaining access to the underlying filestore.
115 * For instance, the umap filesystem presents both a uid-translated and an
116 * untranslated view of the underlying files, and so it is based off of
117 * the null layer. However a layer implementing Access Control Lists
118 * might prefer to block access to the underlying filestore, for which
119 * the overlay layer is a better basis.
122 * INVOKING OPERATIONS ON LOWER LAYERS
124 * See the null layer documentation.
128 #include <sys/cdefs.h>
129 __KERNEL_RCSID(0, "$NetBSD: overlay_vnops.c,v 1.9.16.4 2005/11/10 14:10:32 skrll Exp $");
131 #include <sys/param.h>
132 #include <sys/systm.h>
133 #include <sys/proc.h>
134 #include <sys/time.h>
135 #include <sys/vnode.h>
136 #include <sys/mount.h>
137 #include <sys/namei.h>
138 #include <sys/malloc.h>
140 #include <miscfs/genfs/genfs.h>
141 #include <miscfs/overlay/overlay.h>
142 #include <miscfs/genfs/layer_extern.h>
145 * Global vfs data structures
147 int (**overlay_vnodeop_p
)(void *);
148 const struct vnodeopv_entry_desc overlay_vnodeop_entries
[] = {
149 { &vop_default_desc
, layer_bypass
},
151 { &vop_lookup_desc
, layer_lookup
},
152 { &vop_setattr_desc
, layer_setattr
},
153 { &vop_getattr_desc
, layer_getattr
},
154 { &vop_access_desc
, layer_access
},
155 { &vop_lock_desc
, layer_lock
},
156 { &vop_unlock_desc
, layer_unlock
},
157 { &vop_islocked_desc
, layer_islocked
},
158 { &vop_fsync_desc
, layer_fsync
},
159 { &vop_inactive_desc
, layer_inactive
},
160 { &vop_reclaim_desc
, layer_reclaim
},
161 { &vop_print_desc
, layer_print
},
162 { &vop_remove_desc
, layer_remove
},
163 { &vop_rename_desc
, layer_rename
},
164 { &vop_rmdir_desc
, layer_rmdir
},
166 { &vop_open_desc
, layer_open
}, /* mount option handling */
168 { &vop_bwrite_desc
, layer_bwrite
},
169 { &vop_bmap_desc
, layer_bmap
},
170 { &vop_getpages_desc
, layer_getpages
},
171 { &vop_putpages_desc
, layer_putpages
},
175 const struct vnodeopv_desc overlay_vnodeop_opv_desc
=
176 { &overlay_vnodeop_p
, overlay_vnodeop_entries
};