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