2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 /* Copyright (c) 1998, Apple Computer, Inc. All rights reserved. */
25 * Header file for synthfs data structures
29 * 17-Aug-1999 Pat Dirks New today.
36 #include <sys/appleapiopts.h>
38 #ifdef __APPLE_API_PRIVATE
39 #include <sys/param.h>
41 #include <sys/queue.h>
46 extern void Debugger(const char *message
); /* Private to pexpert... */
50 /* XXX Get rid of this as soon as sys/malloc.h can be updated to define a real M_SYNTHFS */
51 #define M_SYNTHFS M_TEMP
53 /* XXX Get rid of this as soon as sys/vnode.h can be updated to define a real VT_SYNTHFS */
54 #define VT_SYNTHFS (VT_OTHER+1)
57 struct synthfs_mntdata
59 struct mount
*synthfs_mp
; /* filesystem vfs structure */
60 struct vnode
*synthfs_rootvp
;
61 dev_t synthfs_mounteddev
;
62 unsigned long synthfs_nextid
;
63 unsigned long synthfs_filecount
;
64 unsigned long synthfs_dircount
;
65 unsigned long synthfs_encodingsused
;
66 LIST_HEAD(synthfs_fsvnodelist
, vnode
) synthfs_fsvnodes
;
70 * Various sorts of synthfs vnodes:
72 enum synthfsnodetype
{
73 SYNTHFS_DIRECTORY
= 1,
78 struct synthfs_dir_node
{
79 unsigned long d_entrycount
;
80 TAILQ_HEAD(synthfs_d_subnodelist
, synthfsnode
) d_subnodes
;
84 struct synthfs_file_node
{
88 struct synthfs_symlink_node
{
90 char *s_symlinktarget
; /* Dynamically allocated */
96 TAILQ_ENTRY(synthfsnode
) s_sibling
; /* synthfsnodes in a given directory */
97 enum synthfsnodetype s_type
;
98 struct synthfsnode
*s_parent
;
101 unsigned long s_nodeflags
; /* Internal synthfs flags: IN_CHANGED, IN_MODIFIED, etc. */
102 unsigned long s_pflags
; /* File system flags: IMMUTABLE, etc. */
103 unsigned long s_nodeid
;
104 unsigned long s_generation
;
110 struct timeval s_createtime
;
111 struct timeval s_accesstime
;
112 struct timeval s_modificationtime
;
113 struct timeval s_changetime
;
114 struct timeval s_backuptime
;
115 unsigned long s_flags
; /* inode flags: IMMUTABLE, APPEND, etc. */
116 unsigned long s_script
;
117 unsigned long s_finderInfo
[8];
119 struct synthfs_dir_node d
;
120 struct synthfs_file_node f
;
121 struct synthfs_symlink_node s
;
126 #define FIRST_SYNTHFS_ID 0x10
128 /* These flags are kept in flags. */
129 #define IN_ACCESS 0x0001 /* Access time update request. */
130 #define IN_CHANGE 0x0002 /* Change time update request. */
131 #define IN_UPDATE 0x0004 /* Modification time update request. */
132 #define IN_MODIFIED 0x0008 /* Node has been modified. */
133 #define IN_RENAME 0x0010 /* Node is being renamed. */
134 //#define IN_SHLOCK 0x0020 /* File has shared lock. */
135 //#define IN_EXLOCK 0x0040 /* File has exclusive lock. */
136 //#define IN_ALLOCATING 0x1000 /* vnode is in transit, wait or ignore */
137 //#define IN_WANT 0x2000 /* Its being waited for */
139 #define SYNTHFSTIMES(sp, t1, t2) { \
140 if ((sp)->s_nodeflags & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \
141 (sp)->s_nodeflags |= IN_MODIFIED; \
142 if ((sp)->s_nodeflags & IN_ACCESS) { \
143 (sp)->s_accesstime = *(t1); \
145 if ((sp)->s_nodeflags & IN_UPDATE) { \
146 (sp)->s_modificationtime = *(t2); \
148 if ((sp)->s_nodeflags & IN_CHANGE) { \
149 struct timeval _tv; \
152 (sp)->s_changetime = _tv; \
154 (sp)->s_nodeflags &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \
158 #define ATTR_REF_DATA(attrrefptr) (((char *)(attrrefptr)) + ((attrrefptr)->attr_dataoffset))
160 #define STOV(SP) ((SP)->s_vp)
162 #define VTOS(VP) ((struct synthfsnode *)((VP)->v_data))
164 #define VTOVFS(VP) ((VP)->v_mount)
165 #define STOVFS(HP) ((SP)->s_vp->v_mount)
166 #define SFSTOVFS(SFSMP) ((SFSMP)->sfs_mp)
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)
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."); } }
182 #define DBG_ASSERT(a)
185 extern int (**synthfs_vnodeop_p
)(void *);
188 int synthfs_mount (struct mount
*, vnode_t
, user_addr_t
, vfs_context_t context
);
189 int synthfs_start (struct mount
*, int, vfs_context_t context
);
190 int synthfs_unmount (struct mount
*, int, vfs_context_t context
);
191 int synthfs_root (struct mount
*, struct vnode
**, vfs_context_t context
);
192 int synthfs_vfs_getattr (mount_t mp
, struct vfs_attr
*fsap
, vfs_context_t context
);
193 int synthfs_sync (struct mount
*, int, vfs_context_t context
);
194 int synthfs_vget (struct mount
*, ino64_t ino
, struct vnode
**, vfs_context_t context
);
195 int synthfs_fhtovp (struct mount
*, int, unsigned char *, struct vnode
**, vfs_context_t context
);
196 int synthfs_vptofh (struct vnode
*, int *, unsigned char *, vfs_context_t context
);
197 int synthfs_init (struct vfsconf
*);
198 int synthfs_sysctl (int *, u_int
, user_addr_t
, size_t *, user_addr_t
, size_t, vfs_context_t context
);
200 int synthfs_create (struct vnop_create_args
*);
201 int synthfs_open (struct vnop_open_args
*);
202 int synthfs_mmap (struct vnop_mmap_args
*);
203 int synthfs_getattr (struct vnop_getattr_args
*);
204 int synthfs_setattr (struct vnop_setattr_args
*);
205 int synthfs_rename (struct vnop_rename_args
*);
206 int synthfs_select (struct vnop_select_args
*);
207 int synthfs_remove (struct vnop_remove_args
*);
208 int synthfs_mkdir (struct vnop_mkdir_args
*);
209 int synthfs_rmdir (struct vnop_rmdir_args
*);
210 int synthfs_symlink (struct vnop_symlink_args
*);
211 int synthfs_readlink (struct vnop_readlink_args
*);
212 int synthfs_readdir (struct vnop_readdir_args
*);
213 int synthfs_cached_lookup (struct vnop_lookup_args
*);
214 int synthfs_lookup (struct vnop_lookup_args
*);
215 int synthfs_pathconf (struct vnop_pathconf_args
*);
218 int synthfs_inactive (struct vnop_inactive_args
*);
219 int synthfs_reclaim (struct vnop_reclaim_args
*);
221 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
);
222 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
);
223 int synthfs_new_symlink (mount_t mp
, vnode_t dp
, const char *name
, unsigned long nodeid
, char *targetstring
, proc_t p
, vnode_t
*vpp
);
224 long synthfs_adddirentry (u_int32_t fileno
, u_int8_t type
, const char *name
, struct uio
*uio
);
225 int synthfs_remove_entry (struct vnode
*vp
);
226 int synthfs_remove_directory (struct vnode
*vp
);
227 int synthfs_remove_symlink (struct vnode
*vp
);
228 int synthfs_move_rename_entry (struct vnode
*source_vp
, struct vnode
*newparent_vp
, char *newname
);
229 int synthfs_derive_vnode_path (struct vnode
*vp
, char *vnpath
, size_t pathbuffersize
);
230 int synthfs_update(struct vnode
*vp
, struct timeval
*access
, struct timeval
*modify
, int waitfor
);
232 #endif /* __APPLE_API_PRIVATE */
233 #endif /* __SYNTHFS_H__ */