]> git.saurik.com Git - apple/xnu.git/blame - bsd/miscfs/synthfs/synthfs.h
xnu-201.42.3.tar.gz
[apple/xnu.git] / bsd / miscfs / synthfs / synthfs.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/* Copyright (c) 1998, Apple Computer, Inc. All rights reserved. */
23/*
24 * Header file for synthfs data structures
25 *
26 * Change History:
27 *
28 * 17-Aug-1999 Pat Dirks New today.
29 *
30 */
31
32#ifndef __SYNTHFS_H__
33#define __SYNTHFS_H__
34
35#include <sys/param.h>
36#include <sys/lock.h>
37#include <sys/queue.h>
38#include <sys/attr.h>
39
40
41#if DEBUG
42extern void Debugger(const char *message); /* Private to pexpert... */
43#endif
44__END_DECLS
45
46/* XXX Get rid of this as soon as sys/malloc.h can be updated to define a real M_SYNTHFS */
47#define M_SYNTHFS M_TEMP
48
49/* XXX Get rid of this as soon as sys/vnode.h can be updated to define a real VT_SYNTHFS */
50#define VT_SYNTHFS (VT_OTHER+1)
51
52
53struct synthfs_mntdata
54{
55 struct mount *synthfs_mp; /* filesystem vfs structure */
56 struct vnode *synthfs_rootvp;
57 dev_t synthfs_mounteddev;
58 unsigned long synthfs_nextid;
59 unsigned long synthfs_filecount;
60 unsigned long synthfs_dircount;
61 unsigned long synthfs_encodingsused;
62 LIST_HEAD(synthfs_fsvnodelist, vnode) synthfs_fsvnodes;
63};
64
65/*
66 * Various sorts of synthfs vnodes:
67 */
68enum synthfsnodetype {
69 SYNTHFS_DIRECTORY = 1,
70 SYNTHFS_FILE,
71 SYNTHFS_SYMLINK
72};
73
74struct synthfs_dir_node {
75 unsigned long d_entrycount;
76 TAILQ_HEAD(synthfs_d_subnodelist, synthfsnode) d_subnodes;
77
78};
79
80struct synthfs_file_node {
81 off_t f_size;
82};
83
84struct synthfs_symlink_node {
85 int s_length;
86 char *s_symlinktarget; /* Dynamically allocated */
87};
88
89
90struct synthfsnode
91{
92 TAILQ_ENTRY(synthfsnode) s_sibling; /* synthfsnodes in a given directory */
93 enum synthfsnodetype s_type;
94 struct synthfsnode *s_parent;
95 struct vnode *s_vp;
96 char *s_name;
97 struct lock__bsd__ s_lock;
98 unsigned long s_nodeflags; /* Internal synthfs flags: IN_CHANGED, IN_MODIFIED, etc. */
99 unsigned long s_pflags; /* File system flags: IMMUTABLE, etc. */
100 unsigned long s_nodeid;
101 unsigned long s_generation;
102 mode_t s_mode;
103 short s_linkcount;
104 uid_t s_uid;
105 gid_t s_gid;
106 dev_t s_rdev;
107 struct timeval s_createtime;
108 struct timeval s_accesstime;
109 struct timeval s_modificationtime;
110 struct timeval s_changetime;
111 struct timeval s_backuptime;
112 unsigned long s_flags; /* inode flags: IMMUTABLE, APPEND, etc. */
113 unsigned long s_script;
114 unsigned long s_finderInfo[8];
115 union {
116 struct synthfs_dir_node d;
117 struct synthfs_file_node f;
118 struct synthfs_symlink_node s;
119 } s_u;
120};
121
122#define ROOT_DIRID 2
123#define FIRST_SYNTHFS_ID 0x10
124
125/* These flags are kept in flags. */
126#define IN_ACCESS 0x0001 /* Access time update request. */
127#define IN_CHANGE 0x0002 /* Change time update request. */
128#define IN_UPDATE 0x0004 /* Modification time update request. */
129#define IN_MODIFIED 0x0008 /* Node has been modified. */
130#define IN_RENAME 0x0010 /* Node is being renamed. */
131//#define IN_SHLOCK 0x0020 /* File has shared lock. */
132//#define IN_EXLOCK 0x0040 /* File has exclusive lock. */
133//#define IN_ALLOCATING 0x1000 /* vnode is in transit, wait or ignore */
134//#define IN_WANT 0x2000 /* Its being waited for */
135
136#define SYNTHFSTIMES(sp, t1, t2) { \
137 if ((sp)->s_nodeflags & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \
138 (sp)->s_nodeflags |= IN_MODIFIED; \
139 if ((sp)->s_nodeflags & IN_ACCESS) { \
140 (sp)->s_accesstime = *(t1); \
141 }; \
142 if ((sp)->s_nodeflags & IN_UPDATE) { \
143 (sp)->s_modificationtime = *(t2); \
144 } \
145 if ((sp)->s_nodeflags & IN_CHANGE) { \
146 (sp)->s_changetime = time; \
147 }; \
148 (sp)->s_nodeflags &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \
149 } \
150}
151
152#define ATTR_REF_DATA(attrrefptr) (((char *)(attrrefptr)) + ((attrrefptr)->attr_dataoffset))
153
154#define STOV(SP) ((SP)->s_vp)
155
156#define VTOS(VP) ((struct synthfsnode *)((VP)->v_data))
157
158#define VTOVFS(VP) ((VP)->v_mount)
159#define STOVFS(HP) ((SP)->s_vp->v_mount)
160#define SFSTOVFS(SFSMP) ((SFSMP)->sfs_mp)
161
162#define VTOSFS(VP) ((struct synthfs_mntdata *)((VP)->v_mount->mnt_data))
163#define STOTFS(SP) ((struct synthfs_mntdata *)(SP)->s_vp->v_mount->mnt_data)
164#define VFSTOSFS(MP) ((struct synthfs_mntdata *)(MP)->mnt_data)
165
166#if DEBUG
167#define DBG_TRACE(P) printf P;
168#define DBG_INIT(P) printf P;
169#define DBG_VOP(P) printf P;
170//#define DBG_ASSERT(a) { if (!(a)) { panic("File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); } }
171 #define DBG_ASSERT(a) { if (!(a)) { Debugger("Oops - File __FILE__ , line __LINE__: assertion '"#a"' failed."); } }
172#else
173#define DBG_TRACE(P)
174#define DBG_INIT(P)
175#define DBG_VOP(P)
176#define DBG_ASSERT(a)
177#endif
178
179extern int (**synthfs_vnodeop_p)(void *);
180
181__BEGIN_DECLS
182int synthfs_mount __P((struct mount *, char *, caddr_t, struct nameidata *, struct proc *));
183int synthfs_start __P((struct mount *, int, struct proc *));
184int synthfs_unmount __P((struct mount *, int, struct proc *));
185int synthfs_root __P((struct mount *, struct vnode **));
186int synthfs_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *));
187int synthfs_statfs __P((struct mount *, struct statfs *, struct proc *));
188int synthfs_sync __P((struct mount *, int, struct ucred *, struct proc *));
189int synthfs_vget __P((struct mount *, void *ino, struct vnode **));
190int synthfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *, struct vnode **, int *, struct ucred **));
191int synthfs_vptofh __P((struct vnode *, struct fid *));
192int synthfs_init __P((struct vfsconf *));
193int synthfs_sysctl __P((int *, u_int, void *, size_t *, void *, size_t, struct proc *));
194
195int synthfs_create __P((struct vop_create_args *));
196int synthfs_open __P((struct vop_open_args *));
197int synthfs_mmap __P((struct vop_mmap_args *));
198int synthfs_access __P((struct vop_access_args *));
199int synthfs_getattr __P((struct vop_getattr_args *));
200int synthfs_setattr __P((struct vop_setattr_args *));
201int synthfs_rename __P((struct vop_rename_args *));
202int synthfs_select __P((struct vop_select_args *));
203int synthfs_remove __P((struct vop_remove_args *));
204int synthfs_mkdir __P((struct vop_mkdir_args *));
205int synthfs_rmdir __P((struct vop_rmdir_args *));
206int synthfs_symlink __P((struct vop_symlink_args *));
207int synthfs_readlink __P((struct vop_readlink_args *));
208int synthfs_readdir __P((struct vop_readdir_args *));
209int synthfs_cached_lookup __P((struct vop_cachedlookup_args *));
210int synthfs_lookup __P((struct vop_cachedlookup_args *));
211int synthfs_pathconf __P((struct vop_pathconf_args *));
212int synthfs_update __P((struct vop_update_args *));
213
214int synthfs_lock __P((struct vop_lock_args *));
215int synthfs_unlock __P((struct vop_unlock_args *));
216int synthfs_islocked __P((struct vop_islocked_args *));
217
218int synthfs_inactive __P((struct vop_inactive_args*));
219int synthfs_reclaim __P((struct vop_reclaim_args*));
220
221void synthfs_setupuio __P((struct iovec *iov, struct uio *uio, void *buffer, size_t bufsize, enum uio_seg space, enum uio_rw direction, struct proc *p));
222int synthfs_new_directory __P((struct mount *mp, struct vnode *dp, const char *name, unsigned long nodeid, mode_t mode, struct proc *p, struct vnode **vpp));
223int synthfs_new_symlink __P((struct mount *mp, struct vnode *dp, const char *name, unsigned long nodeid, char *targetstring, struct proc *p, struct vnode **vpp));
224long synthfs_adddirentry __P((u_int32_t fileno, u_int8_t type, const char *name, struct uio *uio));
225int synthfs_remove_entry __P((struct vnode *vp));
226int synthfs_remove_directory __P((struct vnode *vp));
227int synthfs_remove_symlink __P((struct vnode *vp));
228int synthfs_move_rename_entry __P((struct vnode *source_vp, struct vnode *newparent_vp, char *newname));
229int synthfs_derive_vnode_path __P((struct vnode *vp, char *vnpath, size_t pathbuffersize));
230
231#endif /* __SYNTHFS_H__ */