2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
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
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
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.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
30 /* Copyright (c) 1998, Apple Computer, Inc. All rights reserved. */
32 * Header file for synthfs data structures
36 * 17-Aug-1999 Pat Dirks New today.
43 #include <sys/appleapiopts.h>
45 #ifdef __APPLE_API_PRIVATE
46 #include <sys/param.h>
48 #include <sys/queue.h>
53 extern void Debugger(const char *message
); /* Private to pexpert... */
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
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)
64 struct synthfs_mntdata
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
;
77 * Various sorts of synthfs vnodes:
79 enum synthfsnodetype
{
80 SYNTHFS_DIRECTORY
= 1,
85 struct synthfs_dir_node
{
86 unsigned long d_entrycount
;
87 TAILQ_HEAD(synthfs_d_subnodelist
, synthfsnode
) d_subnodes
;
91 struct synthfs_file_node
{
95 struct synthfs_symlink_node
{
97 char *s_symlinktarget
; /* Dynamically allocated */
103 TAILQ_ENTRY(synthfsnode
) s_sibling
; /* synthfsnodes in a given directory */
104 enum synthfsnodetype s_type
;
105 struct synthfsnode
*s_parent
;
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
;
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];
126 struct synthfs_dir_node d
;
127 struct synthfs_file_node f
;
128 struct synthfs_symlink_node s
;
133 #define FIRST_SYNTHFS_ID 0x10
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 */
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); \
152 if ((sp)->s_nodeflags & IN_UPDATE) { \
153 (sp)->s_modificationtime = *(t2); \
155 if ((sp)->s_nodeflags & IN_CHANGE) { \
156 struct timeval _tv; \
159 (sp)->s_changetime = _tv; \
161 (sp)->s_nodeflags &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \
165 #define ATTR_REF_DATA(attrrefptr) (((char *)(attrrefptr)) + ((attrrefptr)->attr_dataoffset))
167 #define STOV(SP) ((SP)->s_vp)
169 #define VTOS(VP) ((struct synthfsnode *)((VP)->v_data))
171 #define VTOVFS(VP) ((VP)->v_mount)
172 #define STOVFS(HP) ((SP)->s_vp->v_mount)
173 #define SFSTOVFS(SFSMP) ((SFSMP)->sfs_mp)
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)
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."); } }
189 #define DBG_ASSERT(a)
192 extern int (**synthfs_vnodeop_p
)(void *);
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
);
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
*);
225 int synthfs_inactive (struct vnop_inactive_args
*);
226 int synthfs_reclaim (struct vnop_reclaim_args
*);
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
);
239 #endif /* __APPLE_API_PRIVATE */
240 #endif /* __SYNTHFS_H__ */