2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_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. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 /* Copyright (c) 1998, Apple Computer, Inc. All rights reserved. */
30 * Header file for synthfs data structures
34 * 17-Aug-1999 Pat Dirks New today.
41 #include <sys/appleapiopts.h>
43 #ifdef __APPLE_API_PRIVATE
44 #include <sys/param.h>
46 #include <sys/queue.h>
51 extern void Debugger(const char *message
); /* Private to pexpert... */
55 /* XXX Get rid of this as soon as sys/malloc.h can be updated to define a real M_SYNTHFS */
56 #define M_SYNTHFS M_TEMP
58 /* XXX Get rid of this as soon as sys/vnode.h can be updated to define a real VT_SYNTHFS */
59 #define VT_SYNTHFS (VT_OTHER+1)
62 struct synthfs_mntdata
64 struct mount
*synthfs_mp
; /* filesystem vfs structure */
65 struct vnode
*synthfs_rootvp
;
66 dev_t synthfs_mounteddev
;
67 unsigned long synthfs_nextid
;
68 unsigned long synthfs_filecount
;
69 unsigned long synthfs_dircount
;
70 unsigned long synthfs_encodingsused
;
71 LIST_HEAD(synthfs_fsvnodelist
, vnode
) synthfs_fsvnodes
;
75 * Various sorts of synthfs vnodes:
77 enum synthfsnodetype
{
78 SYNTHFS_DIRECTORY
= 1,
83 struct synthfs_dir_node
{
84 unsigned long d_entrycount
;
85 TAILQ_HEAD(synthfs_d_subnodelist
, synthfsnode
) d_subnodes
;
89 struct synthfs_file_node
{
93 struct synthfs_symlink_node
{
95 char *s_symlinktarget
; /* Dynamically allocated */
101 TAILQ_ENTRY(synthfsnode
) s_sibling
; /* synthfsnodes in a given directory */
102 enum synthfsnodetype s_type
;
103 struct synthfsnode
*s_parent
;
106 unsigned long s_nodeflags
; /* Internal synthfs flags: IN_CHANGED, IN_MODIFIED, etc. */
107 unsigned long s_pflags
; /* File system flags: IMMUTABLE, etc. */
108 unsigned long s_nodeid
;
109 unsigned long s_generation
;
115 struct timeval s_createtime
;
116 struct timeval s_accesstime
;
117 struct timeval s_modificationtime
;
118 struct timeval s_changetime
;
119 struct timeval s_backuptime
;
120 unsigned long s_flags
; /* inode flags: IMMUTABLE, APPEND, etc. */
121 unsigned long s_script
;
122 unsigned long s_finderInfo
[8];
124 struct synthfs_dir_node d
;
125 struct synthfs_file_node f
;
126 struct synthfs_symlink_node s
;
131 #define FIRST_SYNTHFS_ID 0x10
133 /* These flags are kept in flags. */
134 #define IN_ACCESS 0x0001 /* Access time update request. */
135 #define IN_CHANGE 0x0002 /* Change time update request. */
136 #define IN_UPDATE 0x0004 /* Modification time update request. */
137 #define IN_MODIFIED 0x0008 /* Node has been modified. */
138 #define IN_RENAME 0x0010 /* Node is being renamed. */
139 //#define IN_SHLOCK 0x0020 /* File has shared lock. */
140 //#define IN_EXLOCK 0x0040 /* File has exclusive lock. */
141 //#define IN_ALLOCATING 0x1000 /* vnode is in transit, wait or ignore */
142 //#define IN_WANT 0x2000 /* Its being waited for */
144 #define SYNTHFSTIMES(sp, t1, t2) { \
145 if ((sp)->s_nodeflags & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \
146 (sp)->s_nodeflags |= IN_MODIFIED; \
147 if ((sp)->s_nodeflags & IN_ACCESS) { \
148 (sp)->s_accesstime = *(t1); \
150 if ((sp)->s_nodeflags & IN_UPDATE) { \
151 (sp)->s_modificationtime = *(t2); \
153 if ((sp)->s_nodeflags & IN_CHANGE) { \
154 struct timeval _tv; \
157 (sp)->s_changetime = _tv; \
159 (sp)->s_nodeflags &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \
163 #define ATTR_REF_DATA(attrrefptr) (((char *)(attrrefptr)) + ((attrrefptr)->attr_dataoffset))
165 #define STOV(SP) ((SP)->s_vp)
167 #define VTOS(VP) ((struct synthfsnode *)((VP)->v_data))
169 #define VTOVFS(VP) ((VP)->v_mount)
170 #define STOVFS(HP) ((SP)->s_vp->v_mount)
171 #define SFSTOVFS(SFSMP) ((SFSMP)->sfs_mp)
173 #define VTOSFS(VP) ((struct synthfs_mntdata *)((VP)->v_mount->mnt_data))
174 #define STOTFS(SP) ((struct synthfs_mntdata *)(SP)->s_vp->v_mount->mnt_data)
175 #define VFSTOSFS(MP) ((struct synthfs_mntdata *)(MP)->mnt_data)
178 #define DBG_TRACE(P) printf P;
179 #define DBG_INIT(P) printf P;
180 #define DBG_VOP(P) printf P;
181 //#define DBG_ASSERT(a) { if (!(a)) { panic("File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); } }
182 #define DBG_ASSERT(a) { if (!(a)) { Debugger("Oops - File __FILE__ , line __LINE__: assertion '"#a"' failed."); } }
187 #define DBG_ASSERT(a)
190 extern int (**synthfs_vnodeop_p
)(void *);
193 int synthfs_mount (struct mount
*, vnode_t
, user_addr_t
, vfs_context_t context
);
194 int synthfs_start (struct mount
*, int, vfs_context_t context
);
195 int synthfs_unmount (struct mount
*, int, vfs_context_t context
);
196 int synthfs_root (struct mount
*, struct vnode
**, vfs_context_t context
);
197 int synthfs_vfs_getattr (mount_t mp
, struct vfs_attr
*fsap
, vfs_context_t context
);
198 int synthfs_sync (struct mount
*, int, vfs_context_t context
);
199 int synthfs_vget (struct mount
*, ino64_t ino
, struct vnode
**, vfs_context_t context
);
200 int synthfs_fhtovp (struct mount
*, int, unsigned char *, struct vnode
**, vfs_context_t context
);
201 int synthfs_vptofh (struct vnode
*, int *, unsigned char *, vfs_context_t context
);
202 int synthfs_init (struct vfsconf
*);
203 int synthfs_sysctl (int *, u_int
, user_addr_t
, size_t *, user_addr_t
, size_t, vfs_context_t context
);
205 int synthfs_create (struct vnop_create_args
*);
206 int synthfs_open (struct vnop_open_args
*);
207 int synthfs_mmap (struct vnop_mmap_args
*);
208 int synthfs_getattr (struct vnop_getattr_args
*);
209 int synthfs_setattr (struct vnop_setattr_args
*);
210 int synthfs_rename (struct vnop_rename_args
*);
211 int synthfs_select (struct vnop_select_args
*);
212 int synthfs_remove (struct vnop_remove_args
*);
213 int synthfs_mkdir (struct vnop_mkdir_args
*);
214 int synthfs_rmdir (struct vnop_rmdir_args
*);
215 int synthfs_symlink (struct vnop_symlink_args
*);
216 int synthfs_readlink (struct vnop_readlink_args
*);
217 int synthfs_readdir (struct vnop_readdir_args
*);
218 int synthfs_cached_lookup (struct vnop_lookup_args
*);
219 int synthfs_lookup (struct vnop_lookup_args
*);
220 int synthfs_pathconf (struct vnop_pathconf_args
*);
223 int synthfs_inactive (struct vnop_inactive_args
*);
224 int synthfs_reclaim (struct vnop_reclaim_args
*);
226 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
);
227 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
);
228 int synthfs_new_symlink (mount_t mp
, vnode_t dp
, const char *name
, unsigned long nodeid
, char *targetstring
, proc_t p
, vnode_t
*vpp
);
229 long synthfs_adddirentry (u_int32_t fileno
, u_int8_t type
, const char *name
, struct uio
*uio
);
230 int synthfs_remove_entry (struct vnode
*vp
);
231 int synthfs_remove_directory (struct vnode
*vp
);
232 int synthfs_remove_symlink (struct vnode
*vp
);
233 int synthfs_move_rename_entry (struct vnode
*source_vp
, struct vnode
*newparent_vp
, char *newname
);
234 int synthfs_derive_vnode_path (struct vnode
*vp
, char *vnpath
, size_t pathbuffersize
);
235 int synthfs_update(struct vnode
*vp
, struct timeval
*access
, struct timeval
*modify
, int waitfor
);
237 #endif /* __APPLE_API_PRIVATE */
238 #endif /* __SYNTHFS_H__ */