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