]>
git.saurik.com Git - apple/xnu.git/blob - bsd/miscfs/volfs/volfs.h
86d2aa74f2e837ffd8398cd45e194ce14ede7f90
2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
23 * @APPLE_LICENSE_HEADER_END@
25 /* Copyright (c) 1998, Apple Computer, Inc. All rights reserved. */
27 * Header file for volfs
29 #ifndef __VOLFS_VOLFS_H__
30 #define __VOLFS_VOLFS_H__
32 #include <sys/appleapiopts.h>
34 #ifdef __APPLE_API_PRIVATE
37 struct vnode
*volfs_rootvp
;
38 LIST_HEAD(volfs_fsvnodelist
, vnode
) volfs_fsvnodes
;
42 * Volfs vnodes exist only for the root, which allows for the enumeration
43 * of all volfs accessible filesystems, and for the filesystems which
46 #define VOLFS_ROOT 1 /* This volfs vnode represents root of volfs */
47 #define VOLFS_FSNODE 2 /* This volfs vnode represents a file system */
52 struct lock__bsd__ lock
;
53 unsigned int nodeID
; /* the dev entry of a file system */
54 struct mount
* fs_mount
;
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))
64 extern int (**volfs_vnodeop_p
)(void *);
67 int volfs_mount
__P((struct mount
*, char *, caddr_t
, struct nameidata
*,
69 int volfs_start
__P((struct mount
*, int, struct proc
*));
70 int volfs_unmount
__P((struct mount
*, int, struct proc
*));
71 int volfs_root
__P((struct mount
*, struct vnode
**));
72 int volfs_quotactl
__P((struct mount
*, int, uid_t
, caddr_t
,
74 int volfs_statfs
__P((struct mount
*, struct statfs
*, struct proc
*));
75 int volfs_sync
__P((struct mount
*, int, struct ucred
*, struct proc
*));
76 int volfs_vget
__P((struct mount
*, void *ino_t
, struct vnode
**));
77 int volfs_fhtovp
__P((struct mount
*, struct fid
*, struct mbuf
*,
78 struct vnode
**, int *, struct ucred
**));
79 int volfs_vptofh
__P((struct vnode
*, struct fid
*));
80 int volfs_init
__P((struct vfsconf
*));
81 int volfs_sysctl
__P((int *, u_int
, void *, size_t *, void *, size_t,
84 int volfs_reclaim
__P((struct vop_reclaim_args
*));
85 int volfs_access
__P((struct vop_access_args
*));
86 int volfs_getattr
__P((struct vop_getattr_args
*));
87 int volfs_select
__P((struct vop_select_args
*));
88 int volfs_rmdir
__P((struct vop_rmdir_args
*));
89 int volfs_readdir
__P((struct vop_readdir_args
*));
90 int volfs_lock
__P((struct vop_lock_args
*));
91 int volfs_unlock
__P((struct vop_unlock_args
*));
92 int volfs_islocked
__P((struct vop_islocked_args
*));
93 int volfs_pathconf
__P((struct vop_pathconf_args
*));
94 int volfs_lookup
__P((struct vop_lookup_args
*));
97 #define VTOVL(VP) ((struct volfs_vndata *)((VP)->v_data))
99 #define PRINTIT kprintf
102 #define DBG_VOP_TEST_LOCKS 1
103 #define DBG_FUNC_NAME(FSTR) static char *funcname = FSTR
104 #define DBG_PRINT_FUNC_NAME() PRINTIT("%s\n", funcname);
105 #define DBG_VOP_PRINT_FUNCNAME() PRINTIT("%s: ", funcname);
106 #define DBG_VOP_PRINT_CPN_INFO(CN) PRINTIT("name: %s",(CN)->cn_nameptr);
107 #define DBG_VOP(STR) PRINTIT STR;
108 #define DBG_VOP_PRINT_VNODE_INFO(VP) { if ((VP)) \
109 { if ((VP)->v_tag == VT_NON) \
110 PRINTIT("\tfs:%s id: %d v: 0x%x ", VTOVL(VP)->fs_mount->mnt_stat.f_fstypename, VTOVL(VP)->nodeID, (u_int)(VP)); \
111 else PRINTIT("\t%s v: 0x%x ", (VP)->v_mount->mnt_stat.f_fstypename, (u_int)(VP)); \
112 } else { PRINTIT("*** NULL NODE ***"); } }
114 #else /* VOLFS_DEBUG */
115 #define DBG_VOP_TEST_LOCKS 0
116 #define DBG_FUNC_NAME(FSTR)
117 #define DBG_PRINT_FUNC_NAME()
118 #define DBG_VOP_PRINT_FUNCNAME()
119 #define DBG_VOP_PRINT_CPN_INFO(CN)
121 #define DBG_VOP_PRINT_VNODE_INFO(VP)
122 #endif /* VOLFS_DEBUG */
125 #if DBG_VOP_TEST_LOCKS
127 #define VOPDBG_IGNORE 0
128 #define VOPDBG_LOCKED 1
129 #define VOPDBG_UNLOCKED -1
130 #define VOPDBG_LOCKNOTNIL 2
131 #define VOPDBG_SAME 3
133 #define VOPDBG_ZERO 0
137 #define MAXDBGLOCKS 15
139 typedef struct VopDbgStoreRec
{
150 /* This sets up the test for the lock state of vnodes. The entry paramaters are:
151 * I = index of paramater
152 * VP = pointer to a vnode
153 * ENTRYSTATE = the inState of the lock
154 * EXITSTATE = the outState of the lock
155 * ERRORSTATE = the error state of the lock
156 * It initializes the structure, does some preliminary validity checks, but does nothing
157 * if the instate is set to be ignored.
160 #define DBG_VOP_LOCKS_DECL(I) VopDbgStoreRec VopDbgStore[I];short numOfLockSlots=I
161 #define DBG_VOP_LOCKS_INIT(I,VP,ENTRYSTATE,EXITSTATE,ERRORSTATE,CHECKFLAG) \
162 if (I >= numOfLockSlots) { \
163 PRINTIT("%s: DBG_VOP_LOCKS_INIT: Entry #%d greater than allocated slots!\n", funcname, I); \
165 VopDbgStore[I].id = I; \
166 VopDbgStore[I].vp = (VP); \
167 VopDbgStore[I].inState = ENTRYSTATE; \
168 VopDbgStore[I].outState = EXITSTATE; \
169 VopDbgStore[I].errState = ERRORSTATE; \
170 VopDbgStore[I].inValue = 0; \
171 VopDbgStore[I].outValue = 0; \
172 if ((VopDbgStore[I].inState != VOPDBG_IGNORE)) { \
174 PRINTIT ("%s: DBG_VOP_LOCK on start: Null vnode ptr\n", funcname); \
176 VopDbgStore[I].inValue = lockstatus (&((struct volfs_vndata *)((VP)->v_data))->lock); \
180 if (CHECKFLAG==VOPDBG_POS && (VP)->v_usecount <= 0) \
181 PRINTIT("%s: BAD USECOUNT OF %d !!!!\n", funcname, (VP)->v_usecount); \
182 else if ((VP)->v_usecount < 0) \
183 PRINTIT("%s: BAD USECOUNT OF %d !!!!\n", funcname, (VP)->v_usecount); \
185 #define DBG_VOP_UPDATE_VP(I, VP) \
186 VopDbgStore[I].vp = (VP);
189 #define DBG_VOP_LOCKS_TEST(status) DbgVopTest (numOfLockSlots, status, VopDbgStore, funcname);
191 #else /*DBG_VOP_TEST_LOCKS */
192 #define DBG_VOP_LOCKS_DECL(A)
193 #define DBG_VOP_LOCKS_INIT(A,B,C,D,E,F)
194 #define DBG_VOP_LOCKS_TEST(a)
195 #define DBG_VOP_UPDATE_VP(I, VP)
197 #endif /* DBG_VOP_TEST_LOCKS */
199 #endif /* __APPLE_API_PRIVATE */
200 #endif /* __VOLFS_VOLFS_H__ */