]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * The contents of this file constitute Original Code as defined in and | |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
11 | * | |
12 | * This Original Code and all software distributed under the License are | |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the | |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
19 | * | |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* Copyright (c) 1998, Apple Computer, Inc. All rights reserved. */ | |
23 | /* | |
24 | * Header file for volfs | |
25 | */ | |
26 | ||
27 | struct volfs_mntdata | |
28 | { | |
29 | struct vnode *volfs_rootvp; | |
30 | LIST_HEAD(volfs_fsvnodelist, vnode) volfs_fsvnodes; | |
31 | }; | |
32 | ||
33 | /* | |
34 | * Volfs vnodes exist only for the root, which allows for the enumeration | |
35 | * of all volfs accessible filesystems, and for the filesystems which | |
36 | * volfs handles. | |
37 | */ | |
38 | #define VOLFS_ROOT 1 /* This volfs vnode represents root of volfs */ | |
39 | #define VOLFS_FSNODE 2 /* This volfs vnode represents a file system */ | |
40 | ||
41 | struct volfs_vndata | |
42 | { | |
43 | int vnode_type; | |
44 | struct lock__bsd__ lock; | |
45 | unsigned int nodeID; /* the dev entry of a file system */ | |
46 | struct mount * fs_mount; | |
47 | }; | |
48 | ||
49 | #define MAXVLFSNAMLEN 24 /* max length is really 10, pad to 24 since | |
50 | * some of the math depends on VLFSDIRENTLEN | |
51 | * being a power of 2 */ | |
52 | #define VLFSDIRENTLEN (MAXVLFSNAMLEN + sizeof(u_int32_t) + sizeof(u_int16_t) + sizeof(u_int8_t) + sizeof(u_int8_t)) | |
53 | ||
54 | #define ROOT_DIRID 2 | |
55 | ||
56 | extern int (**volfs_vnodeop_p)(void *); | |
57 | __BEGIN_DECLS | |
58 | ||
59 | int volfs_mount __P((struct mount *, char *, caddr_t, struct nameidata *, | |
60 | struct proc *)); | |
61 | int volfs_start __P((struct mount *, int, struct proc *)); | |
62 | int volfs_unmount __P((struct mount *, int, struct proc *)); | |
63 | int volfs_root __P((struct mount *, struct vnode **)); | |
64 | int volfs_quotactl __P((struct mount *, int, uid_t, caddr_t, | |
65 | struct proc *)); | |
66 | int volfs_statfs __P((struct mount *, struct statfs *, struct proc *)); | |
67 | int volfs_sync __P((struct mount *, int, struct ucred *, struct proc *)); | |
68 | int volfs_vget __P((struct mount *, void *ino_t, struct vnode **)); | |
69 | int volfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *, | |
70 | struct vnode **, int *, struct ucred **)); | |
71 | int volfs_vptofh __P((struct vnode *, struct fid *)); | |
72 | int volfs_init __P((struct vfsconf *)); | |
73 | int volfs_sysctl __P((int *, u_int, void *, size_t *, void *, size_t, | |
74 | struct proc *)); | |
75 | ||
76 | int volfs_reclaim __P((struct vop_reclaim_args*)); | |
77 | int volfs_access __P((struct vop_access_args *)); | |
78 | int volfs_getattr __P((struct vop_getattr_args *)); | |
79 | int volfs_select __P((struct vop_select_args *)); | |
80 | int volfs_rmdir __P((struct vop_rmdir_args *)); | |
81 | int volfs_readdir __P((struct vop_readdir_args *)); | |
82 | int volfs_lock __P((struct vop_lock_args *)); | |
83 | int volfs_unlock __P((struct vop_unlock_args *)); | |
84 | int volfs_islocked __P((struct vop_islocked_args *)); | |
85 | int volfs_pathconf __P((struct vop_pathconf_args *)); | |
86 | int volfs_lookup __P((struct vop_lookup_args *)); | |
87 | __END_DECLS | |
88 | ||
89 | #define VTOVL(VP) ((struct volfs_vndata *)((VP)->v_data)) | |
90 | ||
91 | #define PRINTIT kprintf | |
92 | ||
93 | #if VOLFS_DEBUG | |
94 | #define DBG_VOP_TEST_LOCKS 1 | |
95 | #define DBG_FUNC_NAME(FSTR) static char *funcname = FSTR | |
96 | #define DBG_PRINT_FUNC_NAME() PRINTIT("%s\n", funcname); | |
97 | #define DBG_VOP_PRINT_FUNCNAME() PRINTIT("%s: ", funcname); | |
98 | #define DBG_VOP_PRINT_CPN_INFO(CN) PRINTIT("name: %s",(CN)->cn_nameptr); | |
99 | #define DBG_VOP(STR) PRINTIT STR; | |
100 | #define DBG_VOP_PRINT_VNODE_INFO(VP) { if ((VP)) \ | |
101 | { if ((VP)->v_tag == VT_NON) \ | |
102 | PRINTIT("\tfs:%s id: %d v: 0x%x ", VTOVL(VP)->fs_mount->mnt_stat.f_fstypename, VTOVL(VP)->nodeID, (u_int)(VP)); \ | |
103 | else PRINTIT("\t%s v: 0x%x ", (VP)->v_mount->mnt_stat.f_fstypename, (u_int)(VP)); \ | |
104 | } else { PRINTIT("*** NULL NODE ***"); } } | |
105 | ||
106 | #else /* VOLFS_DEBUG */ | |
107 | #define DBG_VOP_TEST_LOCKS 0 | |
108 | #define DBG_FUNC_NAME(FSTR) | |
109 | #define DBG_PRINT_FUNC_NAME() | |
110 | #define DBG_VOP_PRINT_FUNCNAME() | |
111 | #define DBG_VOP_PRINT_CPN_INFO(CN) | |
112 | #define DBG_VOP(A) | |
113 | #define DBG_VOP_PRINT_VNODE_INFO(VP) | |
114 | #endif /* VOLFS_DEBUG */ | |
115 | ||
116 | ||
117 | #if DBG_VOP_TEST_LOCKS | |
118 | ||
119 | #define VOPDBG_IGNORE 0 | |
120 | #define VOPDBG_LOCKED 1 | |
121 | #define VOPDBG_UNLOCKED -1 | |
122 | #define VOPDBG_LOCKNOTNIL 2 | |
123 | #define VOPDBG_SAME 3 | |
124 | ||
125 | #define VOPDBG_ZERO 0 | |
126 | #define VOPDBG_POS 1 | |
127 | ||
128 | ||
129 | #define MAXDBGLOCKS 15 | |
130 | ||
131 | typedef struct VopDbgStoreRec { | |
132 | short id; | |
133 | struct vnode *vp; | |
134 | short inState; | |
135 | short outState; | |
136 | short errState; | |
137 | int inValue; | |
138 | int outValue; | |
139 | } VopDbgStoreRec; | |
140 | ||
141 | ||
142 | /* This sets up the test for the lock state of vnodes. The entry paramaters are: | |
143 | * I = index of paramater | |
144 | * VP = pointer to a vnode | |
145 | * ENTRYSTATE = the inState of the lock | |
146 | * EXITSTATE = the outState of the lock | |
147 | * ERRORSTATE = the error state of the lock | |
148 | * It initializes the structure, does some preliminary validity checks, but does nothing | |
149 | * if the instate is set to be ignored. | |
150 | */ | |
151 | ||
152 | #define DBG_VOP_LOCKS_DECL(I) VopDbgStoreRec VopDbgStore[I];short numOfLockSlots=I | |
153 | #define DBG_VOP_LOCKS_INIT(I,VP,ENTRYSTATE,EXITSTATE,ERRORSTATE,CHECKFLAG) \ | |
154 | if (I >= numOfLockSlots) { \ | |
155 | PRINTIT("%s: DBG_VOP_LOCKS_INIT: Entry #%d greater than allocated slots!\n", funcname, I); \ | |
156 | }; \ | |
157 | VopDbgStore[I].id = I; \ | |
158 | VopDbgStore[I].vp = (VP); \ | |
159 | VopDbgStore[I].inState = ENTRYSTATE; \ | |
160 | VopDbgStore[I].outState = EXITSTATE; \ | |
161 | VopDbgStore[I].errState = ERRORSTATE; \ | |
162 | VopDbgStore[I].inValue = 0; \ | |
163 | VopDbgStore[I].outValue = 0; \ | |
164 | if ((VopDbgStore[I].inState != VOPDBG_IGNORE)) { \ | |
165 | if ((VP) == NULL) \ | |
166 | PRINTIT ("%s: DBG_VOP_LOCK on start: Null vnode ptr\n", funcname); \ | |
167 | else \ | |
168 | VopDbgStore[I].inValue = lockstatus (&((struct volfs_vndata *)((VP)->v_data))->lock); \ | |
169 | } \ | |
170 | if ((VP) != NULL) \ | |
171 | { \ | |
172 | if (CHECKFLAG==VOPDBG_POS && (VP)->v_usecount <= 0) \ | |
173 | PRINTIT("%s: BAD USECOUNT OF %d !!!!\n", funcname, (VP)->v_usecount); \ | |
174 | else if ((VP)->v_usecount < 0) \ | |
175 | PRINTIT("%s: BAD USECOUNT OF %d !!!!\n", funcname, (VP)->v_usecount); \ | |
176 | } | |
177 | #define DBG_VOP_UPDATE_VP(I, VP) \ | |
178 | VopDbgStore[I].vp = (VP); | |
179 | ||
180 | ||
181 | #define DBG_VOP_LOCKS_TEST(status) DbgVopTest (numOfLockSlots, status, VopDbgStore, funcname); | |
182 | ||
183 | #else /*DBG_VOP_TEST_LOCKS */ | |
184 | #define DBG_VOP_LOCKS_DECL(A) | |
185 | #define DBG_VOP_LOCKS_INIT(A,B,C,D,E,F) | |
186 | #define DBG_VOP_LOCKS_TEST(a) | |
187 | #define DBG_VOP_UPDATE_VP(I, VP) | |
188 | ||
189 | #endif /* DBG_VOP_TEST_LOCKS */ |