2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 /* Copyright (c) 1998, Apple Computer, Inc. All rights reserved. */
24 * Header file for synthfs data structures
28 * 17-Aug-1999 Pat Dirks New today.
35 #include <sys/appleapiopts.h>
37 #ifdef __APPLE_API_PRIVATE
38 #include <sys/param.h>
40 #include <sys/queue.h>
45 extern void Debugger(const char *message
); /* Private to pexpert... */
49 /* XXX Get rid of this as soon as sys/malloc.h can be updated to define a real M_SYNTHFS */
50 #define M_SYNTHFS M_TEMP
52 /* XXX Get rid of this as soon as sys/vnode.h can be updated to define a real VT_SYNTHFS */
53 #define VT_SYNTHFS (VT_OTHER+1)
56 struct synthfs_mntdata
58 struct mount
*synthfs_mp
; /* filesystem vfs structure */
59 struct vnode
*synthfs_rootvp
;
60 dev_t synthfs_mounteddev
;
61 unsigned long synthfs_nextid
;
62 unsigned long synthfs_filecount
;
63 unsigned long synthfs_dircount
;
64 unsigned long synthfs_encodingsused
;
65 LIST_HEAD(synthfs_fsvnodelist
, vnode
) synthfs_fsvnodes
;
69 * Various sorts of synthfs vnodes:
71 enum synthfsnodetype
{
72 SYNTHFS_DIRECTORY
= 1,
77 struct synthfs_dir_node
{
78 unsigned long d_entrycount
;
79 TAILQ_HEAD(synthfs_d_subnodelist
, synthfsnode
) d_subnodes
;
83 struct synthfs_file_node
{
87 struct synthfs_symlink_node
{
89 char *s_symlinktarget
; /* Dynamically allocated */
95 TAILQ_ENTRY(synthfsnode
) s_sibling
; /* synthfsnodes in a given directory */
96 enum synthfsnodetype s_type
;
97 struct synthfsnode
*s_parent
;
100 unsigned long s_nodeflags
; /* Internal synthfs flags: IN_CHANGED, IN_MODIFIED, etc. */
101 unsigned long s_pflags
; /* File system flags: IMMUTABLE, etc. */
102 unsigned long s_nodeid
;
103 unsigned long s_generation
;
109 struct timeval s_createtime
;
110 struct timeval s_accesstime
;
111 struct timeval s_modificationtime
;
112 struct timeval s_changetime
;
113 struct timeval s_backuptime
;
114 unsigned long s_flags
; /* inode flags: IMMUTABLE, APPEND, etc. */
115 unsigned long s_script
;
116 unsigned long s_finderInfo
[8];
118 struct synthfs_dir_node d
;
119 struct synthfs_file_node f
;
120 struct synthfs_symlink_node s
;
125 #define FIRST_SYNTHFS_ID 0x10
127 /* These flags are kept in flags. */
128 #define IN_ACCESS 0x0001 /* Access time update request. */
129 #define IN_CHANGE 0x0002 /* Change time update request. */
130 #define IN_UPDATE 0x0004 /* Modification time update request. */
131 #define IN_MODIFIED 0x0008 /* Node has been modified. */
132 #define IN_RENAME 0x0010 /* Node is being renamed. */
133 //#define IN_SHLOCK 0x0020 /* File has shared lock. */
134 //#define IN_EXLOCK 0x0040 /* File has exclusive lock. */
135 //#define IN_ALLOCATING 0x1000 /* vnode is in transit, wait or ignore */
136 //#define IN_WANT 0x2000 /* Its being waited for */
138 #define SYNTHFSTIMES(sp, t1, t2) { \
139 if ((sp)->s_nodeflags & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \
140 (sp)->s_nodeflags |= IN_MODIFIED; \
141 if ((sp)->s_nodeflags & IN_ACCESS) { \
142 (sp)->s_accesstime = *(t1); \
144 if ((sp)->s_nodeflags & IN_UPDATE) { \
145 (sp)->s_modificationtime = *(t2); \
147 if ((sp)->s_nodeflags & IN_CHANGE) { \
148 struct timeval _tv; \
151 (sp)->s_changetime = _tv; \
153 (sp)->s_nodeflags &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \
157 #define ATTR_REF_DATA(attrrefptr) (((char *)(attrrefptr)) + ((attrrefptr)->attr_dataoffset))
159 #define STOV(SP) ((SP)->s_vp)
161 #define VTOS(VP) ((struct synthfsnode *)((VP)->v_data))
163 #define VTOVFS(VP) ((VP)->v_mount)
164 #define STOVFS(HP) ((SP)->s_vp->v_mount)
165 #define SFSTOVFS(SFSMP) ((SFSMP)->sfs_mp)
167 #define VTOSFS(VP) ((struct synthfs_mntdata *)((VP)->v_mount->mnt_data))
168 #define STOTFS(SP) ((struct synthfs_mntdata *)(SP)->s_vp->v_mount->mnt_data)
169 #define VFSTOSFS(MP) ((struct synthfs_mntdata *)(MP)->mnt_data)
172 #define DBG_TRACE(P) printf P;
173 #define DBG_INIT(P) printf P;
174 #define DBG_VOP(P) printf P;
175 //#define DBG_ASSERT(a) { if (!(a)) { panic("File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); } }
176 #define DBG_ASSERT(a) { if (!(a)) { Debugger("Oops - File __FILE__ , line __LINE__: assertion '"#a"' failed."); } }
181 #define DBG_ASSERT(a)
184 extern int (**synthfs_vnodeop_p
)(void *);
187 int synthfs_mount (struct mount
*, vnode_t
, user_addr_t
, vfs_context_t context
);
188 int synthfs_start (struct mount
*, int, vfs_context_t context
);
189 int synthfs_unmount (struct mount
*, int, vfs_context_t context
);
190 int synthfs_root (struct mount
*, struct vnode
**, vfs_context_t context
);
191 int synthfs_vfs_getattr (mount_t mp
, struct vfs_attr
*fsap
, vfs_context_t context
);
192 int synthfs_sync (struct mount
*, int, vfs_context_t context
);
193 int synthfs_vget (struct mount
*, ino64_t ino
, struct vnode
**, vfs_context_t context
);
194 int synthfs_fhtovp (struct mount
*, int, unsigned char *, struct vnode
**, vfs_context_t context
);
195 int synthfs_vptofh (struct vnode
*, int *, unsigned char *, vfs_context_t context
);
196 int synthfs_init (struct vfsconf
*);
197 int synthfs_sysctl (int *, u_int
, user_addr_t
, size_t *, user_addr_t
, size_t, vfs_context_t context
);
199 int synthfs_create (struct vnop_create_args
*);
200 int synthfs_open (struct vnop_open_args
*);
201 int synthfs_mmap (struct vnop_mmap_args
*);
202 int synthfs_getattr (struct vnop_getattr_args
*);
203 int synthfs_setattr (struct vnop_setattr_args
*);
204 int synthfs_rename (struct vnop_rename_args
*);
205 int synthfs_select (struct vnop_select_args
*);
206 int synthfs_remove (struct vnop_remove_args
*);
207 int synthfs_mkdir (struct vnop_mkdir_args
*);
208 int synthfs_rmdir (struct vnop_rmdir_args
*);
209 int synthfs_symlink (struct vnop_symlink_args
*);
210 int synthfs_readlink (struct vnop_readlink_args
*);
211 int synthfs_readdir (struct vnop_readdir_args
*);
212 int synthfs_cached_lookup (struct vnop_lookup_args
*);
213 int synthfs_lookup (struct vnop_lookup_args
*);
214 int synthfs_pathconf (struct vnop_pathconf_args
*);
217 int synthfs_inactive (struct vnop_inactive_args
*);
218 int synthfs_reclaim (struct vnop_reclaim_args
*);
220 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
);
221 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
);
222 int synthfs_new_symlink (mount_t mp
, vnode_t dp
, const char *name
, unsigned long nodeid
, char *targetstring
, proc_t p
, vnode_t
*vpp
);
223 long synthfs_adddirentry (u_int32_t fileno
, u_int8_t type
, const char *name
, struct uio
*uio
);
224 int synthfs_remove_entry (struct vnode
*vp
);
225 int synthfs_remove_directory (struct vnode
*vp
);
226 int synthfs_remove_symlink (struct vnode
*vp
);
227 int synthfs_move_rename_entry (struct vnode
*source_vp
, struct vnode
*newparent_vp
, char *newname
);
228 int synthfs_derive_vnode_path (struct vnode
*vp
, char *vnpath
, size_t pathbuffersize
);
229 int synthfs_update(struct vnode
*vp
, struct timeval
*access
, struct timeval
*modify
, int waitfor
);
231 #endif /* __APPLE_API_PRIVATE */
232 #endif /* __SYNTHFS_H__ */