Deleted Added
full compact
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed
6 * to Berkeley by John Heidemann of the UCLA Ficus project.
7 *
8 * Source: * @(#)i405_init.c 2.10 92/04/27 UCLA Ficus project

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)vfs_init.c 8.3 (Berkeley) 1/4/94
39 * $Id: vfs_init.c,v 1.3 1994/08/02 07:43:22 davidg Exp $
40 */
41
42
43#include <sys/param.h>
44#include <sys/systm.h>
45#include <sys/mount.h>
46#include <sys/time.h>
47#include <sys/vnode.h>
48#include <sys/stat.h>
49#include <sys/namei.h>
50#include <sys/ucred.h>
51#include <sys/buf.h>
52#include <sys/errno.h>
53#include <sys/malloc.h>
54
55/*
56 * Sigh, such primitive tools are these...
57 */
58#if 0
59#define DODEBUG(A) A
60#else
61#define DODEBUG(A)
62#endif
63
64extern struct vnodeopv_desc *vfs_opv_descs[];
65 /* a list of lists of vnodeops defns */
66extern struct vnodeop_desc *vfs_op_descs[];
67 /* and the operations they perform */
68/*
69 * This code doesn't work if the defn is **vnodop_defns with cc.
70 * The problem is because of the compiler sometimes putting in an
71 * extra level of indirection for arrays. It's an interesting
72 * "feature" of C.
73 */
74int vfs_opv_numops;
75
76typedef (*PFI)(); /* the standard Pointer to a Function returning an Int */
77
78/*
79 * A miscellaneous routine.
80 * A generic "default" routine that just returns an error.
81 */
82int
83vn_default_error()
84{

--- 13 unchanged lines hidden (view full) ---

98 * assume that NFS needed to be modified to support Ficus. NFS has an entry
99 * (probably nfs_vnopdeop_decls) declaring all the operations NFS supports by
100 * default. Ficus could add another entry (ficus_nfs_vnodeop_decl_entensions)
101 * listing those new operations Ficus adds to NFS, all without modifying the
102 * NFS code. (Of couse, the OTW NFS protocol still needs to be munged, but
103 * that is a(whole)nother story.) This is a feature.
104 */
105void
106vfs_opv_init()
107{
108 int i, j, k;
109 int (***opv_desc_vector_p)();
110 int (**opv_desc_vector)();
111 struct vnodeopv_entry_desc *opve_descp;
112
113 /*
114 * Allocate the dynamic vectors and fill them in.
115 */
116 for (i=0; vfs_opv_descs[i]; i++) {
117 opv_desc_vector_p = vfs_opv_descs[i]->opv_desc_vector_p;
118 /*
119 * Allocate and init the vector, if it needs it.
120 * Also handle backwards compatibility.
121 */
122 if (*opv_desc_vector_p == NULL) {
123 /* XXX - shouldn't be M_VNODE */
124 MALLOC(*opv_desc_vector_p, PFI*,
125 vfs_opv_numops*sizeof(PFI), M_VNODE, M_WAITOK);
126 bzero (*opv_desc_vector_p, vfs_opv_numops*sizeof(PFI));
127 DODEBUG(printf("vector at %x allocated\n",
128 opv_desc_vector_p));
129 }
130 opv_desc_vector = *opv_desc_vector_p;
131 for (j=0; vfs_opv_descs[i]->opv_desc_ops[j].opve_op; j++) {
132 opve_descp = &(vfs_opv_descs[i]->opv_desc_ops[j]);
133
134 /*
135 * Sanity check: is this operation listed
136 * in the list of operations? We check this
137 * by seeing if its offest is zero. Since
138 * the default routine should always be listed
139 * first, it should be the only one with a zero
140 * offset. Any other operation with a zero

--- 22 unchanged lines hidden (view full) ---

163 opve_descp->opve_impl;
164 }
165 }
166 /*
167 * Finally, go back and replace unfilled routines
168 * with their default. (Sigh, an O(n^3) algorithm. I
169 * could make it better, but that'd be work, and n is small.)
170 */
171 for (i = 0; vfs_opv_descs[i]; i++) {
172 opv_desc_vector = *(vfs_opv_descs[i]->opv_desc_vector_p);
173 /*
174 * Force every operations vector to have a default routine.
175 */
176 if (opv_desc_vector[VOFFSET(vop_default)]==NULL) {
177 panic("vfs_opv_init: operation vector without default routine.");
178 }
179 for (k = 0; k<vfs_opv_numops; k++)
180 if (opv_desc_vector[k] == NULL)

--- 37 unchanged lines hidden (view full) ---

218
219/*
220 * Initialize the vnode structures and initialize each file system type.
221 */
222void
223vfsinit()
224{
225 struct vfsops **vfsp;
226
227 /*
228 * Initialize the vnode table
229 */
230 vntblinit();
231 /*
232 * Initialize the vnode name cache
233 */
234 nchinit();
235 /*
236 * Build vnode operation vectors.
237 */
238 vfs_op_init();
239 vfs_opv_init(); /* finish the job */
240 /*
241 * Initialize each file system type.
242 */
243 vattr_null(&va_null);
244 for (vfsp = &vfssw[0]; vfsp <= &vfssw[MOUNT_MAXTYPE]; vfsp++) {
245 if (*vfsp == NULL)
246 continue;
247 (*(*vfsp)->vfs_init)();
248 }
249}