]> git.saurik.com Git - apple/xnu.git/blob - bsd/miscfs/synthfs/synthfs.h
xnu-792.12.6.tar.gz
[apple/xnu.git] / bsd / miscfs / synthfs / synthfs.h
1 /*
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /* Copyright (c) 1998, Apple Computer, Inc. All rights reserved. */
31 /*
32 * Header file for synthfs data structures
33 *
34 * Change History:
35 *
36 * 17-Aug-1999 Pat Dirks New today.
37 *
38 */
39
40 #ifndef __SYNTHFS_H__
41 #define __SYNTHFS_H__
42
43 #include <sys/appleapiopts.h>
44
45 #ifdef __APPLE_API_PRIVATE
46 #include <sys/param.h>
47 #include <sys/lock.h>
48 #include <sys/queue.h>
49 #include <sys/attr.h>
50
51
52 #if DEBUG
53 extern void Debugger(const char *message); /* Private to pexpert... */
54 #endif
55 __END_DECLS
56
57 /* XXX Get rid of this as soon as sys/malloc.h can be updated to define a real M_SYNTHFS */
58 #define M_SYNTHFS M_TEMP
59
60 /* XXX Get rid of this as soon as sys/vnode.h can be updated to define a real VT_SYNTHFS */
61 #define VT_SYNTHFS (VT_OTHER+1)
62
63
64 struct synthfs_mntdata
65 {
66 struct mount *synthfs_mp; /* filesystem vfs structure */
67 struct vnode *synthfs_rootvp;
68 dev_t synthfs_mounteddev;
69 unsigned long synthfs_nextid;
70 unsigned long synthfs_filecount;
71 unsigned long synthfs_dircount;
72 unsigned long synthfs_encodingsused;
73 LIST_HEAD(synthfs_fsvnodelist, vnode) synthfs_fsvnodes;
74 };
75
76 /*
77 * Various sorts of synthfs vnodes:
78 */
79 enum synthfsnodetype {
80 SYNTHFS_DIRECTORY = 1,
81 SYNTHFS_FILE,
82 SYNTHFS_SYMLINK
83 };
84
85 struct synthfs_dir_node {
86 unsigned long d_entrycount;
87 TAILQ_HEAD(synthfs_d_subnodelist, synthfsnode) d_subnodes;
88
89 };
90
91 struct synthfs_file_node {
92 off_t f_size;
93 };
94
95 struct synthfs_symlink_node {
96 int s_length;
97 char *s_symlinktarget; /* Dynamically allocated */
98 };
99
100
101 struct synthfsnode
102 {
103 TAILQ_ENTRY(synthfsnode) s_sibling; /* synthfsnodes in a given directory */
104 enum synthfsnodetype s_type;
105 struct synthfsnode *s_parent;
106 struct vnode *s_vp;
107 char *s_name;
108 unsigned long s_nodeflags; /* Internal synthfs flags: IN_CHANGED, IN_MODIFIED, etc. */
109 unsigned long s_pflags; /* File system flags: IMMUTABLE, etc. */
110 unsigned long s_nodeid;
111 unsigned long s_generation;
112 mode_t s_mode;
113 short s_linkcount;
114 uid_t s_uid;
115 gid_t s_gid;
116 dev_t s_rdev;
117 struct timeval s_createtime;
118 struct timeval s_accesstime;
119 struct timeval s_modificationtime;
120 struct timeval s_changetime;
121 struct timeval s_backuptime;
122 unsigned long s_flags; /* inode flags: IMMUTABLE, APPEND, etc. */
123 unsigned long s_script;
124 unsigned long s_finderInfo[8];
125 union {
126 struct synthfs_dir_node d;
127 struct synthfs_file_node f;
128 struct synthfs_symlink_node s;
129 } s_u;
130 };
131
132 #define ROOT_DIRID 2
133 #define FIRST_SYNTHFS_ID 0x10
134
135 /* These flags are kept in flags. */
136 #define IN_ACCESS 0x0001 /* Access time update request. */
137 #define IN_CHANGE 0x0002 /* Change time update request. */
138 #define IN_UPDATE 0x0004 /* Modification time update request. */
139 #define IN_MODIFIED 0x0008 /* Node has been modified. */
140 #define IN_RENAME 0x0010 /* Node is being renamed. */
141 //#define IN_SHLOCK 0x0020 /* File has shared lock. */
142 //#define IN_EXLOCK 0x0040 /* File has exclusive lock. */
143 //#define IN_ALLOCATING 0x1000 /* vnode is in transit, wait or ignore */
144 //#define IN_WANT 0x2000 /* Its being waited for */
145
146 #define SYNTHFSTIMES(sp, t1, t2) { \
147 if ((sp)->s_nodeflags & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \
148 (sp)->s_nodeflags |= IN_MODIFIED; \
149 if ((sp)->s_nodeflags & IN_ACCESS) { \
150 (sp)->s_accesstime = *(t1); \
151 }; \
152 if ((sp)->s_nodeflags & IN_UPDATE) { \
153 (sp)->s_modificationtime = *(t2); \
154 } \
155 if ((sp)->s_nodeflags & IN_CHANGE) { \
156 struct timeval _tv; \
157 \
158 microtime(&_tv); \
159 (sp)->s_changetime = _tv; \
160 }; \
161 (sp)->s_nodeflags &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \
162 } \
163 }
164
165 #define ATTR_REF_DATA(attrrefptr) (((char *)(attrrefptr)) + ((attrrefptr)->attr_dataoffset))
166
167 #define STOV(SP) ((SP)->s_vp)
168
169 #define VTOS(VP) ((struct synthfsnode *)((VP)->v_data))
170
171 #define VTOVFS(VP) ((VP)->v_mount)
172 #define STOVFS(HP) ((SP)->s_vp->v_mount)
173 #define SFSTOVFS(SFSMP) ((SFSMP)->sfs_mp)
174
175 #define VTOSFS(VP) ((struct synthfs_mntdata *)((VP)->v_mount->mnt_data))
176 #define STOTFS(SP) ((struct synthfs_mntdata *)(SP)->s_vp->v_mount->mnt_data)
177 #define VFSTOSFS(MP) ((struct synthfs_mntdata *)(MP)->mnt_data)
178
179 #if DEBUG
180 #define DBG_TRACE(P) printf P;
181 #define DBG_INIT(P) printf P;
182 #define DBG_VOP(P) printf P;
183 //#define DBG_ASSERT(a) { if (!(a)) { panic("File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); } }
184 #define DBG_ASSERT(a) { if (!(a)) { Debugger("Oops - File __FILE__ , line __LINE__: assertion '"#a"' failed."); } }
185 #else
186 #define DBG_TRACE(P)
187 #define DBG_INIT(P)
188 #define DBG_VOP(P)
189 #define DBG_ASSERT(a)
190 #endif
191
192 extern int (**synthfs_vnodeop_p)(void *);
193
194 __BEGIN_DECLS
195 int synthfs_mount (struct mount *, vnode_t, user_addr_t, vfs_context_t context);
196 int synthfs_start (struct mount *, int, vfs_context_t context);
197 int synthfs_unmount (struct mount *, int, vfs_context_t context);
198 int synthfs_root (struct mount *, struct vnode **, vfs_context_t context);
199 int synthfs_vfs_getattr (mount_t mp, struct vfs_attr *fsap, vfs_context_t context);
200 int synthfs_sync (struct mount *, int, vfs_context_t context);
201 int synthfs_vget (struct mount *, ino64_t ino, struct vnode **, vfs_context_t context);
202 int synthfs_fhtovp (struct mount *, int, unsigned char *, struct vnode **, vfs_context_t context);
203 int synthfs_vptofh (struct vnode *, int *, unsigned char *, vfs_context_t context);
204 int synthfs_init (struct vfsconf *);
205 int synthfs_sysctl (int *, u_int, user_addr_t, size_t *, user_addr_t, size_t, vfs_context_t context);
206
207 int synthfs_create (struct vnop_create_args *);
208 int synthfs_open (struct vnop_open_args *);
209 int synthfs_mmap (struct vnop_mmap_args *);
210 int synthfs_getattr (struct vnop_getattr_args *);
211 int synthfs_setattr (struct vnop_setattr_args *);
212 int synthfs_rename (struct vnop_rename_args *);
213 int synthfs_select (struct vnop_select_args *);
214 int synthfs_remove (struct vnop_remove_args *);
215 int synthfs_mkdir (struct vnop_mkdir_args *);
216 int synthfs_rmdir (struct vnop_rmdir_args *);
217 int synthfs_symlink (struct vnop_symlink_args *);
218 int synthfs_readlink (struct vnop_readlink_args *);
219 int synthfs_readdir (struct vnop_readdir_args *);
220 int synthfs_cached_lookup (struct vnop_lookup_args *);
221 int synthfs_lookup (struct vnop_lookup_args *);
222 int synthfs_pathconf (struct vnop_pathconf_args *);
223
224
225 int synthfs_inactive (struct vnop_inactive_args*);
226 int synthfs_reclaim (struct vnop_reclaim_args*);
227
228 void synthfs_setupuio (struct iovec *iov, struct uio *uio, void *buffer, size_t bufsize, enum uio_seg space, enum uio_rw direction, proc_t p);
229 int synthfs_new_directory (mount_t mp, vnode_t dp, const char *name, unsigned long nodeid, mode_t mode, proc_t p, vnode_t *vpp);
230 int synthfs_new_symlink (mount_t mp, vnode_t dp, const char *name, unsigned long nodeid, char *targetstring, proc_t p, vnode_t *vpp);
231 long synthfs_adddirentry (u_int32_t fileno, u_int8_t type, const char *name, struct uio *uio);
232 int synthfs_remove_entry (struct vnode *vp);
233 int synthfs_remove_directory (struct vnode *vp);
234 int synthfs_remove_symlink (struct vnode *vp);
235 int synthfs_move_rename_entry (struct vnode *source_vp, struct vnode *newparent_vp, char *newname);
236 int synthfs_derive_vnode_path (struct vnode *vp, char *vnpath, size_t pathbuffersize);
237 int synthfs_update(struct vnode *vp, struct timeval *access, struct timeval *modify, int waitfor);
238
239 #endif /* __APPLE_API_PRIVATE */
240 #endif /* __SYNTHFS_H__ */