]>
git.saurik.com Git - apple/hfs.git/blob - livefiles_hfs_plugin/lf_hfs_vnode.h
1 /* Copyright © 2017-2018 Apple Inc. All rights reserved.
6 * Created by Or Haimovich on 18/3/18.
10 #define lf_hfs_vnode_h
12 #include <sys/_types/_guid_t.h>
14 #include "lf_hfs_common.h"
15 #include <System/sys/vnode.h>
17 extern int VTtoUVFS_tab
[];
19 #define VTTOUVFS(vt) (VTtoUVFS_tab[vt])
20 #define IS_ROOT(vp) (vp->sFSParams.vnfs_markroot)
21 #define IS_DIR(vp) (vp->sFSParams.vnfs_vtype == VDIR)
22 #define IS_LNK(vp) (vp->sFSParams.vnfs_vtype == VLNK)
26 * Convert between vnode types and inode formats (since POSIX.1
27 * defines mode word of stat structure in terms of inode formats).
29 struct componentname
{
31 * Arguments to lookup.
33 uint32_t cn_nameiop
; /* lookup operation */
34 uint32_t cn_flags
; /* flags (see below) */
37 * Shared between lookup and commit routines.
39 char *cn_pnbuf
; /* pathname buffer */
40 int cn_pnlen
; /* length of allocated buffer */
41 char *cn_nameptr
; /* pointer to looked up name */
42 int cn_namelen
; /* length of looked up component */
43 uint32_t cn_hash
; /* hash value of looked up name */
44 uint32_t cn_consume
; /* chars to consume in lookup() */
47 /* The following structure specifies a vnode for creation */
48 struct vnode_fsparam
{
49 struct mount
*vnfs_mp
; /* mount point to which this vnode_t is part of */
50 enum vtype vnfs_vtype
; /* vnode type */
51 const char *vnfs_str
; /* File system Debug aid */
52 struct vnode
*vnfs_dvp
; /* The parent vnode */
53 void *vnfs_fsnode
; /* inode */
54 // int (**vnfs_vops)(void *); /* vnode dispatch table */
55 int vnfs_markroot
; /* is this a root vnode in FS (not a system wide one) */
56 int vnfs_marksystem
; /* is a system vnode */
57 dev_t vnfs_rdev
; /* dev_t for block or char vnodes */
58 off_t vnfs_filesize
; /* that way no need for getattr in UBC */
59 struct componentname
*vnfs_cnp
; /* component name to add to namecache */
60 uint32_t vnfs_flags
; /* flags */
70 uint32_t uValidNodeMagic1
;
72 struct hfsmount
*mount
;
75 struct vnode_fsparam sFSParams
;
76 FileSystemRecord_s
* psFSRecord
;
84 uint32_t uValidNodeMagic2
;
90 struct hfsmount
* psHfsmount
;
96 uint64_t va_supported
;
99 * Control flags. The low 16 bits are reserved for the
100 * ioflags being passed for truncation operations.
104 /* traditional stat(2) parameter fields */
105 dev_t va_rdev
; /* device id (device nodes only) */
106 uint64_t va_nlink
; /* number of references to this file */
107 uint64_t va_total_size
; /* size in bytes of all forks */
108 uint64_t va_total_alloc
; /* disk space used by all forks */
109 uint64_t va_data_size
; /* size in bytes of the fork managed by current vnode */
110 uint64_t va_data_alloc
; /* disk space used by the fork managed by current vnode */
111 uint32_t va_iosize
; /* optimal I/O blocksize */
112 /* file security information */
113 uid_t va_uid
; /* owner UID */
114 gid_t va_gid
; /* owner GID */
115 mode_t va_mode
; /* posix permissions */
116 uint32_t va_flags
; /* file flags */
117 struct kauth_acl
*va_acl
; /* access control list */
119 struct timespec va_create_time
; /* time of creation */
120 struct timespec va_access_time
; /* time of last access */
121 struct timespec va_modify_time
; /* time of last data modification */
122 struct timespec va_change_time
; /* time of last metadata change */
123 struct timespec va_backup_time
; /* time of last backup */
125 /* file parameters */
126 uint64_t va_fileid
; /* file unique ID in filesystem */
127 uint64_t va_linkid
; /* file link unique ID */
128 uint64_t va_parentid
; /* parent ID */
129 uint32_t va_fsid
; /* filesystem ID */
130 uint64_t va_filerev
; /* file revision counter */ /* XXX */
131 uint32_t va_gen
; /* file generation count */ /* XXX - relationship of
133 /* misc parameters */
134 uint32_t va_encoding
; /* filename encoding script */
135 enum vtype va_type
; /* file type */
136 char * va_name
; /* Name for ATTR_CMN_NAME; MAXPATHLEN bytes */
137 guid_t va_uuuid
; /* file owner UUID */
138 guid_t va_guuid
; /* file group UUID */
140 /* Meaningful for directories only */
141 uint64_t va_nchildren
; /* Number of items in a directory */
142 uint64_t va_dirlinkcount
; /* Real references to dir (i.e. excluding "." and ".." refs) */
144 struct kauth_acl
*va_base_acl
;
146 struct timespec va_addedtime
; /* timestamp when item was added to parent directory */
148 /* Data Protection fields */
149 uint32_t va_dataprotect_class
; /* class specified for this file if it didn't exist */
150 uint32_t va_dataprotect_flags
; /* flags from NP open(2) to the filesystem */
151 /* Document revision tracking */
152 uint32_t va_document_id
;
153 /* Fields for Bulk args */
154 uint32_t va_devid
; /* devid of filesystem */
155 uint32_t va_objtype
; /* type of object */
156 uint32_t va_objtag
; /* vnode tag of filesystem */
157 uint32_t va_user_access
; /* access for user */
158 uint8_t va_finderinfo
[32]; /* Finder Info */
159 uint64_t va_rsrc_length
; /* Resource Fork length */
160 uint64_t va_rsrc_alloc
; /* Resource Fork allocation size */
161 fsid_t va_fsid64
; /* fsid, of the correct type */
162 uint32_t va_write_gencount
; /* counter that increments each time the file changes */
163 uint64_t va_private_size
; /* If the file were deleted, how many bytes would be freed immediately */
164 /* add new fields here only */
168 * Convert between vnode types and inode formats (since POSIX.1
169 * defines mode word of stat structure in terms of inode formats).
171 extern enum vtype iftovt_tab
[];
172 #define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12])
174 extern int VTtoUVFS_tab
[];
175 extern int uvfsToVtype_tab
[];
176 extern mode_t vttoif_tab
[];
178 #define VTOUVFS(type) (VTtoUVFS_tab[type])
179 #define UVFSTOV(type) (uvfsToVtype_tab[type])
180 #define MAKEIMODE(indx) (vttoif_tab[indx])
182 #define VNODE_UPDATE_PARENT 0x01
183 #define VNODE_UPDATE_NAME 0x02
184 #define VNODE_UPDATE_CACHE 0x04
186 #define VNODE_REMOVE_NODELETEBUSY 0x0001 /* Don't delete busy files (Carbon) */
187 #define VNODE_REMOVE_SKIP_NAMESPACE_EVENT 0x0002 /* Do not upcall to userland handlers */
188 #define VNODE_REMOVE_NO_AUDIT_PATH 0x0004 /* Do not audit the path */
195 #define IO_UNIT 0x0001 /* do I/O as atomic unit */
196 #define IO_APPEND 0x0002 /* append write to end */
197 #define IO_SYNC 0x0004 /* do I/O synchronously */
198 #define IO_NODELOCKED 0x0008 /* underlying node already locked */
199 #define IO_NDELAY 0x0010 /* FNDELAY flag set in file table */
200 #define IO_NOZEROFILL 0x0020 /* F_SETSIZE fcntl uses to prevent zero filling */
201 //#ifdef XNU_KERNEL_PRIVATE
202 #define IO_REVOKE IO_NOZEROFILL /* revoked close for tty, will Not be used in conjunction */
203 //#endif /* XNU_KERNEL_PRIVATE */
204 #define IO_TAILZEROFILL 0x0040 /* zero fills at the tail of write */
205 #define IO_HEADZEROFILL 0x0080 /* zero fills at the head of write */
206 #define IO_NOZEROVALID 0x0100 /* do not zero fill if valid page */
207 #define IO_NOZERODIRTY 0x0200 /* do not zero fill if page is dirty */
208 #define IO_CLOSE 0x0400 /* I/O issued from close path */
209 #define IO_NOCACHE 0x0800 /* same effect as VNOCACHE_DATA, but only for this 1 I/O */
210 #define IO_RAOFF 0x1000 /* same effect as VRAOFF, but only for this 1 I/O */
211 #define IO_DEFWRITE 0x2000 /* defer write if vfs.defwrite is set */
212 #define IO_PASSIVE 0x4000 /* this I/O is marked as background I/O so it won't throttle Throttleable I/O */
213 #define IO_BACKGROUND IO_PASSIVE /* used for backward compatibility. to be removed after IO_BACKGROUND is no longer
214 * used by DiskImages in-kernel mode */
215 #define IO_NOAUTH 0x8000 /* No authorization checks. */
216 #define IO_NODIRECT 0x10000 /* don't use direct synchronous writes if IO_NOCACHE is specified */
217 #define IO_ENCRYPTED 0x20000 /* Retrieve encrypted blocks from the filesystem */
218 #define IO_RETURN_ON_THROTTLE 0x40000
219 #define IO_SINGLE_WRITER 0x80000
220 #define IO_SYSCALL_DISPATCH 0x100000 /* I/O was originated from a file table syscall */
221 #define IO_SWAP_DISPATCH 0x200000 /* I/O was originated from the swap layer */
222 #define IO_SKIP_ENCRYPTION 0x400000 /* Skips en(de)cryption on the IO. Must be initiated from kernel */
223 #define IO_EVTONLY 0x800000 /* the i/o is being done on an fd that's marked O_EVTONLY */
225 errno_t
vnode_create(uint32_t size
, void *data
, vnode_t
*vpp
);
226 errno_t
vnode_initialize(uint32_t size
, void *data
, vnode_t
*vpp
);
227 void vnode_rele(vnode_t vp
);
228 mount_t
vnode_mount(vnode_t vp
);
229 int vnode_issystem(vnode_t vp
);
230 int vnode_isreg(vnode_t vp
);
231 int vnode_isdir(vnode_t vp
);
232 int vnode_islnk(vnode_t vp
);
233 void vnode_update_identity(vnode_t vp
, vnode_t dvp
, const char *name
, int name_len
, uint32_t name_hashval
, int flags
);
234 void vnode_GetAttrInternal (vnode_t vp
, UVFSFileAttributes
*psOutAttr
);
235 #endif /* lf_hfs_vnode_h */