]> git.saurik.com Git - apple/xnu.git/blame - bsd/miscfs/synthfs/synthfs.h
xnu-517.tar.gz
[apple/xnu.git] / bsd / miscfs / synthfs / synthfs.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 *
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 synthfs data structures
28 *
29 * Change History:
30 *
31 * 17-Aug-1999 Pat Dirks New today.
32 *
33 */
34
35#ifndef __SYNTHFS_H__
36#define __SYNTHFS_H__
37
9bccf70c
A
38#include <sys/appleapiopts.h>
39
40#ifdef __APPLE_API_PRIVATE
1c79356b
A
41#include <sys/param.h>
42#include <sys/lock.h>
43#include <sys/queue.h>
44#include <sys/attr.h>
45
46
47#if DEBUG
48extern void Debugger(const char *message); /* Private to pexpert... */
49#endif
50__END_DECLS
51
52/* XXX Get rid of this as soon as sys/malloc.h can be updated to define a real M_SYNTHFS */
53#define M_SYNTHFS M_TEMP
54
55/* XXX Get rid of this as soon as sys/vnode.h can be updated to define a real VT_SYNTHFS */
56#define VT_SYNTHFS (VT_OTHER+1)
57
58
59struct synthfs_mntdata
60{
61 struct mount *synthfs_mp; /* filesystem vfs structure */
62 struct vnode *synthfs_rootvp;
63 dev_t synthfs_mounteddev;
64 unsigned long synthfs_nextid;
65 unsigned long synthfs_filecount;
66 unsigned long synthfs_dircount;
67 unsigned long synthfs_encodingsused;
68 LIST_HEAD(synthfs_fsvnodelist, vnode) synthfs_fsvnodes;
69};
70
71/*
72 * Various sorts of synthfs vnodes:
73 */
74enum synthfsnodetype {
75 SYNTHFS_DIRECTORY = 1,
76 SYNTHFS_FILE,
77 SYNTHFS_SYMLINK
78};
79
80struct synthfs_dir_node {
81 unsigned long d_entrycount;
82 TAILQ_HEAD(synthfs_d_subnodelist, synthfsnode) d_subnodes;
83
84};
85
86struct synthfs_file_node {
87 off_t f_size;
88};
89
90struct synthfs_symlink_node {
91 int s_length;
92 char *s_symlinktarget; /* Dynamically allocated */
93};
94
95
96struct synthfsnode
97{
98 TAILQ_ENTRY(synthfsnode) s_sibling; /* synthfsnodes in a given directory */
99 enum synthfsnodetype s_type;
100 struct synthfsnode *s_parent;
101 struct vnode *s_vp;
102 char *s_name;
103 struct lock__bsd__ s_lock;
104 unsigned long s_nodeflags; /* Internal synthfs flags: IN_CHANGED, IN_MODIFIED, etc. */
105 unsigned long s_pflags; /* File system flags: IMMUTABLE, etc. */
106 unsigned long s_nodeid;
107 unsigned long s_generation;
108 mode_t s_mode;
109 short s_linkcount;
110 uid_t s_uid;
111 gid_t s_gid;
112 dev_t s_rdev;
113 struct timeval s_createtime;
114 struct timeval s_accesstime;
115 struct timeval s_modificationtime;
116 struct timeval s_changetime;
117 struct timeval s_backuptime;
118 unsigned long s_flags; /* inode flags: IMMUTABLE, APPEND, etc. */
119 unsigned long s_script;
120 unsigned long s_finderInfo[8];
121 union {
122 struct synthfs_dir_node d;
123 struct synthfs_file_node f;
124 struct synthfs_symlink_node s;
125 } s_u;
126};
127
128#define ROOT_DIRID 2
129#define FIRST_SYNTHFS_ID 0x10
130
131/* These flags are kept in flags. */
132#define IN_ACCESS 0x0001 /* Access time update request. */
133#define IN_CHANGE 0x0002 /* Change time update request. */
134#define IN_UPDATE 0x0004 /* Modification time update request. */
135#define IN_MODIFIED 0x0008 /* Node has been modified. */
136#define IN_RENAME 0x0010 /* Node is being renamed. */
137//#define IN_SHLOCK 0x0020 /* File has shared lock. */
138//#define IN_EXLOCK 0x0040 /* File has exclusive lock. */
139//#define IN_ALLOCATING 0x1000 /* vnode is in transit, wait or ignore */
140//#define IN_WANT 0x2000 /* Its being waited for */
141
142#define SYNTHFSTIMES(sp, t1, t2) { \
143 if ((sp)->s_nodeflags & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \
144 (sp)->s_nodeflags |= IN_MODIFIED; \
145 if ((sp)->s_nodeflags & IN_ACCESS) { \
146 (sp)->s_accesstime = *(t1); \
147 }; \
148 if ((sp)->s_nodeflags & IN_UPDATE) { \
149 (sp)->s_modificationtime = *(t2); \
150 } \
151 if ((sp)->s_nodeflags & IN_CHANGE) { \
152 (sp)->s_changetime = time; \
153 }; \
154 (sp)->s_nodeflags &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \
155 } \
156}
157
158#define ATTR_REF_DATA(attrrefptr) (((char *)(attrrefptr)) + ((attrrefptr)->attr_dataoffset))
159
160#define STOV(SP) ((SP)->s_vp)
161
162#define VTOS(VP) ((struct synthfsnode *)((VP)->v_data))
163
164#define VTOVFS(VP) ((VP)->v_mount)
165#define STOVFS(HP) ((SP)->s_vp->v_mount)
166#define SFSTOVFS(SFSMP) ((SFSMP)->sfs_mp)
167
168#define VTOSFS(VP) ((struct synthfs_mntdata *)((VP)->v_mount->mnt_data))
169#define STOTFS(SP) ((struct synthfs_mntdata *)(SP)->s_vp->v_mount->mnt_data)
170#define VFSTOSFS(MP) ((struct synthfs_mntdata *)(MP)->mnt_data)
171
172#if DEBUG
173#define DBG_TRACE(P) printf P;
174#define DBG_INIT(P) printf P;
175#define DBG_VOP(P) printf P;
176//#define DBG_ASSERT(a) { if (!(a)) { panic("File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); } }
177 #define DBG_ASSERT(a) { if (!(a)) { Debugger("Oops - File __FILE__ , line __LINE__: assertion '"#a"' failed."); } }
178#else
179#define DBG_TRACE(P)
180#define DBG_INIT(P)
181#define DBG_VOP(P)
182#define DBG_ASSERT(a)
183#endif
184
185extern int (**synthfs_vnodeop_p)(void *);
186
187__BEGIN_DECLS
188int synthfs_mount __P((struct mount *, char *, caddr_t, struct nameidata *, struct proc *));
189int synthfs_start __P((struct mount *, int, struct proc *));
190int synthfs_unmount __P((struct mount *, int, struct proc *));
191int synthfs_root __P((struct mount *, struct vnode **));
192int synthfs_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *));
193int synthfs_statfs __P((struct mount *, struct statfs *, struct proc *));
194int synthfs_sync __P((struct mount *, int, struct ucred *, struct proc *));
195int synthfs_vget __P((struct mount *, void *ino, struct vnode **));
196int synthfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *, struct vnode **, int *, struct ucred **));
197int synthfs_vptofh __P((struct vnode *, struct fid *));
198int synthfs_init __P((struct vfsconf *));
199int synthfs_sysctl __P((int *, u_int, void *, size_t *, void *, size_t, struct proc *));
200
201int synthfs_create __P((struct vop_create_args *));
202int synthfs_open __P((struct vop_open_args *));
203int synthfs_mmap __P((struct vop_mmap_args *));
204int synthfs_access __P((struct vop_access_args *));
205int synthfs_getattr __P((struct vop_getattr_args *));
206int synthfs_setattr __P((struct vop_setattr_args *));
207int synthfs_rename __P((struct vop_rename_args *));
208int synthfs_select __P((struct vop_select_args *));
209int synthfs_remove __P((struct vop_remove_args *));
210int synthfs_mkdir __P((struct vop_mkdir_args *));
211int synthfs_rmdir __P((struct vop_rmdir_args *));
212int synthfs_symlink __P((struct vop_symlink_args *));
213int synthfs_readlink __P((struct vop_readlink_args *));
214int synthfs_readdir __P((struct vop_readdir_args *));
215int synthfs_cached_lookup __P((struct vop_cachedlookup_args *));
216int synthfs_lookup __P((struct vop_cachedlookup_args *));
217int synthfs_pathconf __P((struct vop_pathconf_args *));
218int synthfs_update __P((struct vop_update_args *));
219
220int synthfs_lock __P((struct vop_lock_args *));
221int synthfs_unlock __P((struct vop_unlock_args *));
222int synthfs_islocked __P((struct vop_islocked_args *));
223
224int synthfs_inactive __P((struct vop_inactive_args*));
225int synthfs_reclaim __P((struct vop_reclaim_args*));
226
227void synthfs_setupuio __P((struct iovec *iov, struct uio *uio, void *buffer, size_t bufsize, enum uio_seg space, enum uio_rw direction, struct proc *p));
228int synthfs_new_directory __P((struct mount *mp, struct vnode *dp, const char *name, unsigned long nodeid, mode_t mode, struct proc *p, struct vnode **vpp));
229int synthfs_new_symlink __P((struct mount *mp, struct vnode *dp, const char *name, unsigned long nodeid, char *targetstring, struct proc *p, struct vnode **vpp));
230long synthfs_adddirentry __P((u_int32_t fileno, u_int8_t type, const char *name, struct uio *uio));
231int synthfs_remove_entry __P((struct vnode *vp));
232int synthfs_remove_directory __P((struct vnode *vp));
233int synthfs_remove_symlink __P((struct vnode *vp));
234int synthfs_move_rename_entry __P((struct vnode *source_vp, struct vnode *newparent_vp, char *newname));
235int synthfs_derive_vnode_path __P((struct vnode *vp, char *vnpath, size_t pathbuffersize));
236
9bccf70c 237#endif /* __APPLE_API_PRIVATE */
1c79356b 238#endif /* __SYNTHFS_H__ */