]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
39236c6e | 2 | * Copyright (c) 2000-2012 Apple Inc. All rights reserved. |
5d5c5d0d | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
2d21ac55 A |
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. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
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. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b | 27 | */ |
1c79356b A |
28 | |
29 | #ifndef __HFS__ | |
30 | #define __HFS__ | |
31 | ||
6d2010ae A |
32 | /* If set to 1, enables the code to allocate blocks from the start |
33 | * of the disk instead of the nextAllocation for sparse devices like | |
34 | * sparse disk images or sparsebundle images. The free extent cache | |
35 | * for such volumes is also maintained based on the start block instead | |
36 | * of number of contiguous allocation blocks. These devices prefer | |
37 | * allocation of blocks near the start of the disk to avoid the | |
38 | * increasing the image size, but it can also result in file fragmentation. | |
39 | */ | |
55e303ae A |
40 | #define HFS_SPARSE_DEV 1 |
41 | ||
b0d623f7 | 42 | #if DEBUG |
2d21ac55 A |
43 | #define HFS_CHECK_LOCK_ORDER 1 |
44 | #endif | |
45 | ||
9bccf70c A |
46 | #include <sys/appleapiopts.h> |
47 | ||
48 | #ifdef KERNEL | |
49 | #ifdef __APPLE_API_PRIVATE | |
1c79356b | 50 | #include <sys/param.h> |
1c79356b | 51 | #include <sys/queue.h> |
9bccf70c | 52 | #include <sys/mount.h> |
9bccf70c A |
53 | #include <sys/vnode.h> |
54 | #include <sys/quota.h> | |
1c79356b | 55 | #include <sys/dirent.h> |
55e303ae | 56 | #include <sys/event.h> |
060df5ea | 57 | #include <sys/disk.h> |
e2fac8b1 | 58 | #include <kern/thread_call.h> |
1c79356b | 59 | |
91447636 A |
60 | #include <kern/locks.h> |
61 | ||
b4c24cb9 A |
62 | #include <vfs/vfs_journal.h> |
63 | ||
1c79356b | 64 | #include <hfs/hfs_format.h> |
9bccf70c A |
65 | #include <hfs/hfs_catalog.h> |
66 | #include <hfs/hfs_cnode.h> | |
1c79356b A |
67 | #include <hfs/hfs_macos_defs.h> |
68 | #include <hfs/hfs_encodings.h> | |
55e303ae | 69 | #include <hfs/hfs_hotfiles.h> |
1c79356b | 70 | |
316670eb A |
71 | #if CONFIG_PROTECT |
72 | /* Forward declare the cprotect struct */ | |
73 | struct cprotect; | |
74 | #endif | |
75 | ||
1c79356b A |
76 | /* |
77 | * Just reported via MIG interface. | |
78 | */ | |
79 | #define VERSION_STRING "hfs-2 (4-12-99)" | |
80 | ||
81 | #define HFS_LINK_MAX 32767 | |
82 | ||
9bccf70c A |
83 | #define HFS_MAX_DEFERED_ALLOC (1024*1024) |
84 | ||
2d21ac55 | 85 | // 400 megs is a "big" file (i.e. one that when deleted |
55e303ae | 86 | // would touch enough data that we should break it into |
2d21ac55 | 87 | // multiple separate transactions) |
0c530ab8 | 88 | #define HFS_BIGFILE_SIZE (400LL * 1024LL * 1024LL) |
55e303ae | 89 | |
1c79356b A |
90 | |
91 | enum { kMDBSize = 512 }; /* Size of I/O transfer to read entire MDB */ | |
92 | ||
93 | enum { kMasterDirectoryBlock = 2 }; /* MDB offset on disk in 512-byte blocks */ | |
94 | enum { kMDBOffset = kMasterDirectoryBlock * 512 }; /* MDB offset on disk in bytes */ | |
95 | ||
91447636 | 96 | #define kRootDirID kHFSRootFolderID |
1c79356b | 97 | |
1c79356b | 98 | |
0b4e3aa0 A |
99 | /* number of locked buffer caches to hold for b-tree meta data */ |
100 | #define kMaxLockedMetaBuffers 32 | |
1c79356b | 101 | |
1c79356b A |
102 | extern struct timezone gTimeZone; |
103 | ||
1c79356b | 104 | |
0b4e3aa0 A |
105 | /* How many free extents to cache per volume */ |
106 | #define kMaxFreeExtents 10 | |
107 | ||
9bccf70c A |
108 | /* |
109 | * HFS_MINFREE gives the minimum acceptable percentage | |
110 | * of file system blocks which may be free (but this | |
111 | * minimum will never exceed HFS_MAXRESERVE bytes). If | |
112 | * the free block count drops below this level only the | |
113 | * superuser may continue to allocate blocks. | |
114 | */ | |
115 | #define HFS_MINFREE 1 | |
55e303ae | 116 | #define HFS_MAXRESERVE ((u_int64_t)(250*1024*1024)) |
39236c6e | 117 | #define HFS_BT_MAXRESERVE ((u_int64_t)(10*1024*1024)) |
55e303ae A |
118 | |
119 | /* | |
120 | * The system distinguishes between the desirable low-disk | |
121 | * notifiaction levels for root volumes and non-root volumes. | |
122 | * The various thresholds are computed as a fraction of the | |
123 | * volume size, all capped at a certain fixed level | |
124 | */ | |
125 | ||
b0d623f7 | 126 | #define HFS_ROOTVERYLOWDISKTRIGGERFRACTION 5 |
6d2010ae | 127 | #define HFS_ROOTVERYLOWDISKTRIGGERLEVEL ((u_int64_t)(512*1024*1024)) |
b0d623f7 | 128 | #define HFS_ROOTLOWDISKTRIGGERFRACTION 10 |
6d2010ae | 129 | #define HFS_ROOTLOWDISKTRIGGERLEVEL ((u_int64_t)(1024*1024*1024)) |
b0d623f7 | 130 | #define HFS_ROOTLOWDISKSHUTOFFFRACTION 11 |
6d2010ae | 131 | #define HFS_ROOTLOWDISKSHUTOFFLEVEL ((u_int64_t)(1024*1024*1024 + 250*1024*1024)) |
55e303ae | 132 | |
b0d623f7 A |
133 | #define HFS_VERYLOWDISKTRIGGERFRACTION 1 |
134 | #define HFS_VERYLOWDISKTRIGGERLEVEL ((u_int64_t)(100*1024*1024)) | |
135 | #define HFS_LOWDISKTRIGGERFRACTION 2 | |
136 | #define HFS_LOWDISKTRIGGERLEVEL ((u_int64_t)(150*1024*1024)) | |
137 | #define HFS_LOWDISKSHUTOFFFRACTION 3 | |
138 | #define HFS_LOWDISKSHUTOFFLEVEL ((u_int64_t)(200*1024*1024)) | |
9bccf70c | 139 | |
1c79356b A |
140 | /* Internal Data structures*/ |
141 | ||
1c79356b A |
142 | /* This structure describes the HFS specific mount structure data. */ |
143 | typedef struct hfsmount { | |
91447636 A |
144 | u_int32_t hfs_flags; /* see below */ |
145 | ||
1c79356b | 146 | /* Physical Description */ |
593a1d5f A |
147 | u_int32_t hfs_logical_block_size; /* Logical block size of the disk as reported by ioctl(DKIOCGETBLOCKSIZE), always a multiple of 512 */ |
148 | daddr64_t hfs_logical_block_count; /* Number of logical blocks on the disk */ | |
316670eb | 149 | u_int64_t hfs_logical_bytes; /* Number of bytes on the disk device this HFS is mounted on (blockcount * blocksize) */ |
593a1d5f A |
150 | daddr64_t hfs_alt_id_sector; /* location of alternate VH/MDB */ |
151 | u_int32_t hfs_physical_block_size; /* Physical block size of the disk as reported by ioctl(DKIOCGETPHYSICALBLOCKSIZE) */ | |
152 | u_int32_t hfs_log_per_phys; /* Number of logical blocks per physical block size */ | |
1c79356b A |
153 | |
154 | /* Access to VFS and devices */ | |
155 | struct mount *hfs_mp; /* filesystem vfs structure */ | |
156 | struct vnode *hfs_devvp; /* block device mounted vnode */ | |
91447636 A |
157 | struct vnode * hfs_extents_vp; |
158 | struct vnode * hfs_catalog_vp; | |
159 | struct vnode * hfs_allocation_vp; | |
160 | struct vnode * hfs_attribute_vp; | |
2d21ac55 A |
161 | struct vnode * hfs_startup_vp; |
162 | struct vnode * hfs_attrdata_vp; /* pseudo file */ | |
163 | struct cnode * hfs_extents_cp; | |
164 | struct cnode * hfs_catalog_cp; | |
165 | struct cnode * hfs_allocation_cp; | |
166 | struct cnode * hfs_attribute_cp; | |
167 | struct cnode * hfs_startup_cp; | |
91447636 A |
168 | dev_t hfs_raw_dev; /* device mounted */ |
169 | u_int32_t hfs_logBlockSize; /* Size of buffer cache buffer for I/O */ | |
1c79356b A |
170 | |
171 | /* Default values for HFS standard and non-init access */ | |
91447636 A |
172 | uid_t hfs_uid; /* uid to set as owner of the files */ |
173 | gid_t hfs_gid; /* gid to set as owner of the files */ | |
174 | mode_t hfs_dir_mask; /* mask to and with directory protection bits */ | |
175 | mode_t hfs_file_mask; /* mask to and with file protection bits */ | |
b0d623f7 | 176 | u_int32_t hfs_encoding; /* Default encoding for non hfs+ volumes */ |
91447636 A |
177 | |
178 | /* Persistent fields (on disk, dynamic) */ | |
179 | time_t hfs_mtime; /* file system last modification time */ | |
180 | u_int32_t hfs_filecount; /* number of files in file system */ | |
181 | u_int32_t hfs_dircount; /* number of directories in file system */ | |
182 | u_int32_t freeBlocks; /* free allocation blocks */ | |
183 | u_int32_t nextAllocation; /* start of next allocation search */ | |
b0d623f7 | 184 | u_int32_t sparseAllocation; /* start of allocations for sparse devices */ |
2d21ac55 | 185 | u_int32_t vcbNxtCNID; /* next unused catalog node ID - protected by catalog lock */ |
91447636 A |
186 | u_int32_t vcbWrCnt; /* file system write count */ |
187 | u_int64_t encodingsBitmap; /* in-use encodings */ | |
188 | u_int16_t vcbNmFls; /* HFS Only - root dir file count */ | |
189 | u_int16_t vcbNmRtDirs; /* HFS Only - root dir directory count */ | |
190 | ||
191 | /* Persistent fields (on disk, static) */ | |
192 | u_int16_t vcbSigWord; | |
2d21ac55 | 193 | int16_t vcbFlags; /* Runtime flag to indicate if volume is dirty/clean */ |
91447636 A |
194 | u_int32_t vcbAtrb; |
195 | u_int32_t vcbJinfoBlock; | |
6d2010ae A |
196 | u_int32_t localCreateDate;/* volume create time from volume header (For HFS+, value is in local time) */ |
197 | time_t hfs_itime; /* file system creation time (creation date of the root folder) */ | |
198 | time_t hfs_btime; /* file system last backup time */ | |
91447636 A |
199 | u_int32_t blockSize; /* size of allocation blocks */ |
200 | u_int32_t totalBlocks; /* total allocation blocks */ | |
2d21ac55 A |
201 | u_int32_t allocLimit; /* Do not allocate this block or beyond */ |
202 | /* | |
203 | * NOTE: When resizing a volume to make it smaller, allocLimit is set to the allocation | |
204 | * block number which will contain the new alternate volume header. At all other times, | |
205 | * allocLimit is set to totalBlocks. The allocation code uses allocLimit instead of | |
206 | * totalBlocks to limit which blocks may be allocated, so that during a resize, we don't | |
207 | * put new content into the blocks we're trying to truncate away. | |
208 | */ | |
91447636 A |
209 | int32_t vcbClpSiz; |
210 | u_int32_t vcbFndrInfo[8]; | |
211 | int16_t vcbVBMSt; /* HFS only */ | |
212 | int16_t vcbAlBlSt; /* HFS only */ | |
213 | ||
214 | /* vcb stuff */ | |
215 | u_int8_t vcbVN[256]; /* volume name in UTF-8 */ | |
216 | u_int32_t volumeNameEncodingHint; | |
217 | u_int32_t hfsPlusIOPosOffset; /* Disk block where HFS+ starts */ | |
218 | u_int32_t vcbVBMIOSize; /* volume bitmap I/O size */ | |
219 | ||
220 | /* cache of largest known free extents */ | |
221 | u_int32_t vcbFreeExtCnt; | |
222 | HFSPlusExtentDescriptor vcbFreeExt[kMaxFreeExtents]; | |
6d2010ae A |
223 | lck_spin_t vcbFreeExtLock; |
224 | ||
39236c6e A |
225 | /* Summary Table */ |
226 | u_int8_t *hfs_summary_table; /* Each bit is 1 vcbVBMIOSize of bitmap, byte indexed */ | |
227 | u_int32_t hfs_summary_size; /* number of BITS in summary table defined above (not bytes!) */ | |
228 | u_int32_t hfs_summary_bytes; /* number of BYTES in summary table */ | |
91447636 | 229 | |
39236c6e | 230 | u_int32_t scan_var; /* For initializing the summary table */ |
6d2010ae A |
231 | |
232 | ||
91447636 A |
233 | u_int32_t reserveBlocks; /* free block reserve */ |
234 | u_int32_t loanedBlocks; /* blocks on loan for delayed allocations */ | |
235 | ||
2d21ac55 A |
236 | |
237 | /* | |
238 | * HFS+ Private system directories (two). Any access | |
239 | * (besides looking at the cd_cnid) requires holding | |
240 | * the Catalog File lock. | |
241 | */ | |
242 | struct cat_desc hfs_private_desc[2]; | |
243 | struct cat_attr hfs_private_attr[2]; | |
244 | ||
1c79356b A |
245 | u_int32_t hfs_metadata_createdate; |
246 | hfs_to_unicode_func_t hfs_get_unicode; | |
247 | unicode_to_hfs_func_t hfs_get_hfsname; | |
9bccf70c | 248 | |
55e303ae | 249 | /* Quota variables: */ |
9bccf70c | 250 | struct quotafile hfs_qfiles[MAXQUOTAS]; /* quota files */ |
b4c24cb9 | 251 | |
55e303ae | 252 | /* Journaling variables: */ |
b4c24cb9 A |
253 | void *jnl; // the journal for this volume (if one exists) |
254 | struct vnode *jvp; // device where the journal lives (may be equal to devvp) | |
255 | u_int32_t jnl_start; // start block of the journal file (so we don't delete it) | |
55e303ae | 256 | u_int32_t jnl_size; |
b4c24cb9 A |
257 | u_int32_t hfs_jnlfileid; |
258 | u_int32_t hfs_jnlinfoblkid; | |
6d2010ae | 259 | lck_rw_t hfs_global_lock; |
91447636 | 260 | u_int32_t hfs_global_lock_nesting; |
6d2010ae | 261 | void* hfs_global_lockowner; |
55e303ae A |
262 | |
263 | /* Notification variables: */ | |
b0d623f7 A |
264 | u_int32_t hfs_notification_conditions; |
265 | u_int32_t hfs_freespace_notify_dangerlimit; | |
55e303ae A |
266 | u_int32_t hfs_freespace_notify_warninglimit; |
267 | u_int32_t hfs_freespace_notify_desiredlevel; | |
268 | ||
91447636 A |
269 | /* time mounted and last mounted mod time "snapshot" */ |
270 | time_t hfs_mount_time; | |
271 | time_t hfs_last_mounted_mtime; | |
272 | ||
55e303ae A |
273 | /* Metadata allocation zone variables: */ |
274 | u_int32_t hfs_metazone_start; | |
275 | u_int32_t hfs_metazone_end; | |
276 | u_int32_t hfs_hotfile_start; | |
277 | u_int32_t hfs_hotfile_end; | |
b0d623f7 A |
278 | u_int32_t hfs_min_alloc_start; |
279 | u_int32_t hfs_freed_block_count; | |
55e303ae A |
280 | int hfs_hotfile_freeblks; |
281 | int hfs_hotfile_maxblks; | |
282 | int hfs_overflow_maxblks; | |
283 | int hfs_catalog_maxblks; | |
284 | ||
285 | /* Hot File Clustering variables: */ | |
91447636 | 286 | lck_mtx_t hfc_mutex; /* serialize hot file stages */ |
55e303ae A |
287 | enum hfc_stage hfc_stage; /* what are we up to... */ |
288 | time_t hfc_timebase; /* recording period start time */ | |
289 | time_t hfc_timeout; /* recording period stop time */ | |
290 | void * hfc_recdata; /* recording data (opaque) */ | |
291 | int hfc_maxfiles; /* maximum files to track */ | |
292 | struct vnode * hfc_filevp; | |
293 | ||
6d2010ae | 294 | #if HFS_SPARSE_DEV |
55e303ae A |
295 | /* Sparse device variables: */ |
296 | struct vnode * hfs_backingfs_rootvp; | |
2d21ac55 | 297 | u_int32_t hfs_last_backingstatfs; |
55e303ae | 298 | int hfs_sparsebandblks; |
b0d623f7 | 299 | u_int64_t hfs_backingfs_maxblocks; |
55e303ae | 300 | #endif |
91447636 A |
301 | size_t hfs_max_inline_attrsize; |
302 | ||
303 | lck_mtx_t hfs_mutex; /* protects access to hfsmount data */ | |
304 | void *hfs_freezing_proc; /* who froze the fs */ | |
c910b4d9 | 305 | void *hfs_downgrading_proc; /* process who's downgrading to rdonly */ |
3a60a9f5 | 306 | lck_rw_t hfs_insync; /* protects sync/freeze interaction */ |
0c530ab8 A |
307 | |
308 | /* Resize variables: */ | |
6d2010ae A |
309 | u_int32_t hfs_resize_blocksmoved; |
310 | u_int32_t hfs_resize_totalblocks; | |
311 | u_int32_t hfs_resize_progress; | |
316670eb A |
312 | #if CONFIG_PROTECT |
313 | struct cprotect *hfs_resize_cpentry; | |
314 | u_int16_t hfs_running_cp_major_vers; | |
39236c6e | 315 | uint32_t default_cp_class; |
316670eb A |
316 | #endif |
317 | ||
e2fac8b1 | 318 | |
b0d623f7 A |
319 | /* Per mount cnode hash variables: */ |
320 | lck_mtx_t hfs_chash_mutex; /* protects access to cnode hash table */ | |
321 | u_long hfs_cnodehash; /* size of cnode hash table - 1 */ | |
322 | LIST_HEAD(cnodehashhead, cnode) *hfs_cnodehashtbl; /* base of cnode hash */ | |
323 | ||
39236c6e A |
324 | /* Per mount fileid hash variables (protected by catalog lock!) */ |
325 | u_long hfs_idhash; /* size of cnid/fileid hash table -1 */ | |
326 | LIST_HEAD(idhashhead, cat_preflightid) *hfs_idhashtbl; /* base of ID hash */ | |
b0d623f7 | 327 | |
e2fac8b1 A |
328 | /* |
329 | * About the sync counters: | |
330 | * hfs_sync_scheduled keeps track whether a timer was scheduled but we | |
331 | * haven't started processing the callback (i.e. we | |
332 | * haven't begun the flush). This will be non-zero | |
333 | * even if the callback has been invoked, before we | |
334 | * start the flush. | |
335 | * hfs_sync_incomplete keeps track of the number of callbacks that have | |
336 | * not completed yet (including callbacks not yet | |
337 | * invoked). We cannot safely unmount until this | |
338 | * drops to zero. | |
339 | * | |
340 | * In both cases, we use counters, not flags, so that we can avoid | |
341 | * taking locks. | |
342 | */ | |
343 | int32_t hfs_sync_scheduled; | |
344 | int32_t hfs_sync_incomplete; | |
345 | u_int64_t hfs_last_sync_request_time; | |
b0d623f7 A |
346 | u_int32_t hfs_active_threads; |
347 | u_int64_t hfs_max_pending_io; | |
348 | ||
e2fac8b1 | 349 | thread_call_t hfs_syncer; // removeable devices get sync'ed by this guy |
6d2010ae | 350 | |
1c79356b A |
351 | } hfsmount_t; |
352 | ||
39236c6e A |
353 | /* |
354 | * HFS_META_DELAY is a duration (0.1 seconds, expressed in microseconds) | |
355 | * used for triggering the hfs_syncer() routine. It is used in two ways: | |
356 | * as the delay between ending a transaction and firing hfs_syncer(), and | |
357 | * the delay in re-firing hfs_syncer() when it decides to back off (for | |
358 | * example, due to in-progress writes). | |
359 | */ | |
360 | enum { HFS_META_DELAY = 100 * 1000ULL }; | |
e2fac8b1 | 361 | |
91447636 A |
362 | typedef hfsmount_t ExtendedVCB; |
363 | ||
2d21ac55 | 364 | /* Aliases for legacy (Mac OS 9) field names */ |
91447636 A |
365 | #define vcbLsMod hfs_mtime |
366 | #define vcbVolBkUp hfs_btime | |
367 | #define extentsRefNum hfs_extents_vp | |
368 | #define catalogRefNum hfs_catalog_vp | |
369 | #define allocationsRefNum hfs_allocation_vp | |
370 | #define vcbFilCnt hfs_filecount | |
371 | #define vcbDirCnt hfs_dircount | |
372 | ||
2d21ac55 A |
373 | /* Inline functions to set/reset vcbFlags. Upper 8 bits indicate if the volume |
374 | * header/VCB is clean/dirty --- if set, volume header is dirty, and | |
375 | * if clear, volume header is clean. This value is checked to determine | |
376 | * if the in-memory copy of volume header should be flushed to the disk | |
377 | * or not. | |
378 | */ | |
379 | /* Set runtime flag to indicate that volume is dirty */ | |
380 | static __inline__ void MarkVCBDirty(ExtendedVCB *vcb) | |
381 | { | |
382 | vcb->vcbFlags |= 0xFF00; | |
383 | } | |
384 | ||
385 | /* Clear runtime flag to indicate that volume is dirty */ | |
386 | static __inline__ void MarkVCBClean(ExtendedVCB *vcb) | |
387 | { | |
388 | vcb->vcbFlags &= 0x00FF; | |
389 | } | |
390 | ||
391 | /* Check runtime flag to determine if the volume is dirty or not */ | |
392 | static __inline__ Boolean IsVCBDirty(ExtendedVCB *vcb) | |
393 | { | |
394 | return (vcb->vcbFlags & 0xFF00 ? true : false); | |
395 | } | |
55e303ae | 396 | |
2d21ac55 A |
397 | /* |
398 | * There are two private directories in HFS+. | |
399 | * | |
400 | * One contains inodes for files that are hardlinked or open/unlinked. | |
401 | * The other contains inodes for directories that are hardlinked. | |
402 | */ | |
403 | enum privdirtype {FILE_HARDLINKS, DIR_HARDLINKS}; | |
55e303ae | 404 | |
39236c6e | 405 | #define HFS_ALLOCATOR_SCAN_INFLIGHT 0x0001 /* scan started */ |
1c79356b | 406 | |
2d21ac55 A |
407 | /* HFS mount point flags */ |
408 | #define HFS_READ_ONLY 0x00001 | |
409 | #define HFS_UNKNOWN_PERMS 0x00002 | |
410 | #define HFS_WRITEABLE_MEDIA 0x00004 | |
411 | #define HFS_CLEANED_ORPHANS 0x00008 | |
412 | #define HFS_X 0x00010 | |
413 | #define HFS_CASE_SENSITIVE 0x00020 | |
414 | #define HFS_STANDARD 0x00040 | |
415 | #define HFS_METADATA_ZONE 0x00080 | |
416 | #define HFS_FRAGMENTED_FREESPACE 0x00100 | |
417 | #define HFS_NEED_JNL_RESET 0x00200 | |
418 | #define HFS_HAS_SPARSE_DEVICE 0x00400 | |
419 | #define HFS_RESIZE_IN_PROGRESS 0x00800 | |
420 | #define HFS_QUOTAS 0x01000 | |
421 | #define HFS_CREATING_BTREE 0x02000 | |
422 | /* When set, do not update nextAllocation in the mount structure */ | |
423 | #define HFS_SKIP_UPDATE_NEXT_ALLOCATION 0x04000 | |
6d2010ae | 424 | /* When set, the file system supports extent-based extended attributes */ |
2d21ac55 A |
425 | #define HFS_XATTR_EXTENTS 0x08000 |
426 | #define HFS_FOLDERCOUNT 0x10000 | |
427 | /* When set, the file system exists on a virtual device, like disk image */ | |
428 | #define HFS_VIRTUAL_DEVICE 0x20000 | |
593a1d5f A |
429 | /* When set, we're in hfs_changefs, so hfs_sync should do nothing. */ |
430 | #define HFS_IN_CHANGEFS 0x40000 | |
c910b4d9 | 431 | /* When set, we are in process of downgrading or have downgraded to read-only, |
b0d623f7 A |
432 | * so hfs_start_transaction should return EROFS. |
433 | */ | |
c910b4d9 | 434 | #define HFS_RDONLY_DOWNGRADE 0x80000 |
b0d623f7 | 435 | #define HFS_DID_CONTIG_SCAN 0x100000 |
316670eb | 436 | #define HFS_UNMAP 0x200000 |
6d2010ae | 437 | #define HFS_SSD 0x400000 |
39236c6e A |
438 | #define HFS_SUMMARY_TABLE 0x800000 |
439 | #define HFS_CS 0x1000000 | |
2d21ac55 | 440 | |
316670eb | 441 | |
2d21ac55 A |
442 | /* Macro to update next allocation block in the HFS mount structure. If |
443 | * the HFS_SKIP_UPDATE_NEXT_ALLOCATION is set, do not update | |
444 | * nextAllocation block. | |
445 | */ | |
446 | #define HFS_UPDATE_NEXT_ALLOCATION(hfsmp, new_nextAllocation) \ | |
447 | { \ | |
448 | if ((hfsmp->hfs_flags & HFS_SKIP_UPDATE_NEXT_ALLOCATION) == 0)\ | |
449 | hfsmp->nextAllocation = new_nextAllocation; \ | |
450 | } \ | |
451 | ||
2d21ac55 A |
452 | /* Macro for incrementing and decrementing the folder count in a cnode |
453 | * attribute only if the HFS_FOLDERCOUNT bit is set in the mount flags | |
454 | * and kHFSHasFolderCount bit is set in the cnode flags. Currently these | |
455 | * bits are only set for case sensitive HFS+ volumes. | |
456 | */ | |
457 | #define INC_FOLDERCOUNT(hfsmp, cattr) \ | |
458 | if ((hfsmp->hfs_flags & HFS_FOLDERCOUNT) && \ | |
459 | (cattr.ca_recflags & kHFSHasFolderCountMask)) { \ | |
460 | cattr.ca_dircount++; \ | |
461 | } \ | |
462 | ||
463 | #define DEC_FOLDERCOUNT(hfsmp, cattr) \ | |
464 | if ((hfsmp->hfs_flags & HFS_FOLDERCOUNT) && \ | |
465 | (cattr.ca_recflags & kHFSHasFolderCountMask) && \ | |
466 | (cattr.ca_dircount > 0)) { \ | |
467 | cattr.ca_dircount--; \ | |
468 | } \ | |
1c79356b | 469 | |
9bccf70c | 470 | typedef struct filefork FCB; |
1c79356b | 471 | |
2d21ac55 A |
472 | /* |
473 | * Macros for creating item names for our special/private directories. | |
474 | */ | |
475 | #define MAKE_INODE_NAME(name, size, linkno) \ | |
476 | (void) snprintf((name), size, "%s%d", HFS_INODE_PREFIX, (linkno)) | |
477 | #define HFS_INODE_PREFIX_LEN 5 | |
1c79356b | 478 | |
2d21ac55 A |
479 | #define MAKE_DIRINODE_NAME(name, size, linkno) \ |
480 | (void) snprintf((name), size, "%s%d", HFS_DIRINODE_PREFIX, (linkno)) | |
481 | #define HFS_DIRINODE_PREFIX_LEN 4 | |
1c79356b | 482 | |
2d21ac55 A |
483 | #define MAKE_DELETED_NAME(NAME, size, FID) \ |
484 | (void) snprintf((NAME), size, "%s%d", HFS_DELETE_PREFIX, (FID)) | |
485 | #define HFS_DELETE_PREFIX_LEN 4 | |
1c79356b | 486 | |
1c79356b | 487 | |
9bccf70c A |
488 | #define HFS_AVERAGE_NAME_SIZE 22 |
489 | #define AVERAGE_HFSDIRENTRY_SIZE (8+HFS_AVERAGE_NAME_SIZE+4) | |
1c79356b | 490 | |
91447636 A |
491 | #define STD_DIRENT_LEN(namlen) \ |
492 | ((sizeof(struct dirent) - (NAME_MAX+1)) + (((namlen)+1 + 3) &~ 3)) | |
1c79356b | 493 | |
91447636 | 494 | #define EXT_DIRENT_LEN(namlen) \ |
39236c6e | 495 | ((sizeof(struct direntry) + (namlen) - (MAXPATHLEN-1) + 7) & ~7) |
1c79356b | 496 | |
1c79356b A |
497 | |
498 | enum { kHFSPlusMaxFileNameBytes = kHFSPlusMaxFileNameChars * 3 }; | |
499 | ||
1c79356b A |
500 | |
501 | /* macro to determine if hfs or hfsplus */ | |
502 | #define ISHFSPLUS(VCB) ((VCB)->vcbSigWord == kHFSPlusSigWord) | |
503 | #define ISHFS(VCB) ((VCB)->vcbSigWord == kHFSSigWord) | |
504 | ||
505 | ||
1c79356b A |
506 | /* |
507 | * Various ways to acquire a VFS mount point pointer: | |
508 | */ | |
91447636 | 509 | #define VTOVFS(VP) vnode_mount((VP)) |
1c79356b | 510 | #define HFSTOVFS(HFSMP) ((HFSMP)->hfs_mp) |
91447636 | 511 | #define VCBTOVFS(VCB) HFSTOVFS(VCB) |
1c79356b A |
512 | |
513 | /* | |
514 | * Various ways to acquire an HFS mount point pointer: | |
515 | */ | |
91447636 A |
516 | #define VTOHFS(VP) ((struct hfsmount *)vfs_fsprivate(vnode_mount((VP)))) |
517 | #define VFSTOHFS(MP) ((struct hfsmount *)vfs_fsprivate((MP))) | |
518 | #define VCBTOHFS(VCB) (VCB) | |
519 | #define FCBTOHFS(FCB) ((struct hfsmount *)vfs_fsprivate(vnode_mount((FCB)->ff_cp->c_vp))) | |
1c79356b A |
520 | |
521 | /* | |
91447636 | 522 | * Various ways to acquire a VCB (legacy) pointer: |
1c79356b | 523 | */ |
91447636 A |
524 | #define VTOVCB(VP) VTOHFS(VP) |
525 | #define VFSTOVCB(MP) VFSTOHFS(MP) | |
526 | #define HFSTOVCB(HFSMP) (HFSMP) | |
527 | #define FCBTOVCB(FCB) FCBTOHFS(FCB) | |
1c79356b A |
528 | |
529 | ||
530 | #define E_NONE 0 | |
531 | #define kHFSBlockSize 512 | |
1c79356b | 532 | |
9bccf70c A |
533 | /* |
534 | * Macros for getting the MDB/VH sector and offset | |
535 | */ | |
536 | #define HFS_PRI_SECTOR(blksize) (1024 / (blksize)) | |
537 | #define HFS_PRI_OFFSET(blksize) ((blksize) > 1024 ? 1024 : 0) | |
d52fe63f A |
538 | |
539 | #define HFS_ALT_SECTOR(blksize, blkcnt) (((blkcnt) - 1) - (512 / (blksize))) | |
540 | #define HFS_ALT_OFFSET(blksize) ((blksize) > 1024 ? (blksize) - 1024 : 0) | |
541 | ||
593a1d5f A |
542 | /* Convert the logical sector number to be aligned on physical block size boundary. |
543 | * We are assuming the partition is a multiple of physical block size. | |
544 | */ | |
545 | #define HFS_PHYSBLK_ROUNDDOWN(sector_num, log_per_phys) ((sector_num / log_per_phys) * log_per_phys) | |
91447636 A |
546 | |
547 | /* | |
548 | * HFS specific fcntl()'s | |
549 | */ | |
91447636 A |
550 | #define HFS_GET_BOOT_INFO (FCNTL_FS_SPECIFIC_BASE + 0x00004) |
551 | #define HFS_SET_BOOT_INFO (FCNTL_FS_SPECIFIC_BASE + 0x00005) | |
6d2010ae A |
552 | /* See HFSIOC_EXT_BULKACCESS and friends for HFS specific fsctls*/ |
553 | ||
91447636 A |
554 | |
555 | ||
1c79356b A |
556 | /* |
557 | * This is the straight GMT conversion constant: | |
558 | * 00:00:00 January 1, 1970 - 00:00:00 January 1, 1904 | |
559 | * (3600 * 24 * ((365 * (1970 - 1904)) + (((1970 - 1904) / 4) + 1))) | |
560 | */ | |
561 | #define MAC_GMT_FACTOR 2082844800UL | |
562 | ||
1c79356b | 563 | |
2d21ac55 A |
564 | /***************************************************************************** |
565 | FUNCTION PROTOTYPES | |
566 | ******************************************************************************/ | |
1c79356b | 567 | |
2d21ac55 A |
568 | /***************************************************************************** |
569 | hfs_vnop_xxx functions from different files | |
570 | ******************************************************************************/ | |
571 | int hfs_vnop_readdirattr(struct vnop_readdirattr_args *); /* in hfs_attrlist.c */ | |
1c79356b | 572 | |
2d21ac55 A |
573 | int hfs_vnop_inactive(struct vnop_inactive_args *); /* in hfs_cnode.c */ |
574 | int hfs_vnop_reclaim(struct vnop_reclaim_args *); /* in hfs_cnode.c */ | |
316670eb | 575 | |
6d2010ae A |
576 | int hfs_set_backingstore (struct vnode *vp, int val); /* in hfs_cnode.c */ |
577 | int hfs_is_backingstore (struct vnode *vp, int *val); /* in hfs_cnode.c */ | |
578 | ||
2d21ac55 | 579 | int hfs_vnop_link(struct vnop_link_args *); /* in hfs_link.c */ |
9bccf70c | 580 | |
2d21ac55 | 581 | int hfs_vnop_lookup(struct vnop_lookup_args *); /* in hfs_lookup.c */ |
b4c24cb9 | 582 | |
2d21ac55 | 583 | int hfs_vnop_search(struct vnop_searchfs_args *); /* in hfs_search.c */ |
1c79356b | 584 | |
2d21ac55 A |
585 | int hfs_vnop_read(struct vnop_read_args *); /* in hfs_readwrite.c */ |
586 | int hfs_vnop_write(struct vnop_write_args *); /* in hfs_readwrite.c */ | |
587 | int hfs_vnop_ioctl(struct vnop_ioctl_args *); /* in hfs_readwrite.c */ | |
588 | int hfs_vnop_select(struct vnop_select_args *); /* in hfs_readwrite.c */ | |
589 | int hfs_vnop_strategy(struct vnop_strategy_args *); /* in hfs_readwrite.c */ | |
590 | int hfs_vnop_allocate(struct vnop_allocate_args *); /* in hfs_readwrite.c */ | |
591 | int hfs_vnop_pagein(struct vnop_pagein_args *); /* in hfs_readwrite.c */ | |
592 | int hfs_vnop_pageout(struct vnop_pageout_args *); /* in hfs_readwrite.c */ | |
593 | int hfs_vnop_bwrite(struct vnop_bwrite_args *); /* in hfs_readwrite.c */ | |
594 | int hfs_vnop_blktooff(struct vnop_blktooff_args *); /* in hfs_readwrite.c */ | |
595 | int hfs_vnop_offtoblk(struct vnop_offtoblk_args *); /* in hfs_readwrite.c */ | |
596 | int hfs_vnop_blockmap(struct vnop_blockmap_args *); /* in hfs_readwrite.c */ | |
1c79356b | 597 | |
2d21ac55 A |
598 | int hfs_vnop_getxattr(struct vnop_getxattr_args *); /* in hfs_xattr.c */ |
599 | int hfs_vnop_setxattr(struct vnop_setxattr_args *); /* in hfs_xattr.c */ | |
600 | int hfs_vnop_removexattr(struct vnop_removexattr_args *); /* in hfs_xattr.c */ | |
601 | int hfs_vnop_listxattr(struct vnop_listxattr_args *); /* in hfs_xattr.c */ | |
602 | #if NAMEDSTREAMS | |
603 | extern int hfs_vnop_getnamedstream(struct vnop_getnamedstream_args*); | |
604 | extern int hfs_vnop_makenamedstream(struct vnop_makenamedstream_args*); | |
605 | extern int hfs_vnop_removenamedstream(struct vnop_removenamedstream_args*); | |
606 | #endif | |
9bccf70c | 607 | |
1c79356b | 608 | |
2d21ac55 A |
609 | /***************************************************************************** |
610 | Functions from MacOSStubs.c | |
611 | ******************************************************************************/ | |
612 | time_t to_bsd_time(u_int32_t hfs_time); | |
9bccf70c | 613 | |
2d21ac55 | 614 | u_int32_t to_hfs_time(time_t bsd_time); |
1c79356b | 615 | |
1c79356b | 616 | |
2d21ac55 A |
617 | /***************************************************************************** |
618 | Functions from hfs_encodinghint.c | |
619 | ******************************************************************************/ | |
620 | u_int32_t hfs_pickencoding(const u_int16_t *src, int len); | |
9bccf70c | 621 | |
2d21ac55 | 622 | u_int32_t hfs_getencodingbias(void); |
1c79356b | 623 | |
2d21ac55 | 624 | void hfs_setencodingbias(u_int32_t bias); |
b4c24cb9 | 625 | |
2d21ac55 A |
626 | |
627 | /***************************************************************************** | |
628 | Functions from hfs_encodings.c | |
629 | ******************************************************************************/ | |
630 | void hfs_converterinit(void); | |
1c79356b | 631 | |
39236c6e A |
632 | int hfs_relconverter (u_int32_t encoding); |
633 | ||
1c79356b A |
634 | int hfs_getconverter(u_int32_t encoding, hfs_to_unicode_func_t *get_unicode, |
635 | unicode_to_hfs_func_t *get_hfsname); | |
636 | ||
39236c6e | 637 | #if CONFIG_HFS_STD |
2d21ac55 | 638 | int hfs_to_utf8(ExtendedVCB *vcb, const Str31 hfs_str, ByteCount maxDstLen, |
1c79356b A |
639 | ByteCount *actualDstLen, unsigned char* dstStr); |
640 | ||
641 | int utf8_to_hfs(ExtendedVCB *vcb, ByteCount srcLen, const unsigned char* srcStr, | |
642 | Str31 dstStr); | |
643 | ||
2d21ac55 | 644 | int mac_roman_to_utf8(const Str31 hfs_str, ByteCount maxDstLen, ByteCount *actualDstLen, |
1c79356b A |
645 | unsigned char* dstStr); |
646 | ||
647 | int utf8_to_mac_roman(ByteCount srcLen, const unsigned char* srcStr, Str31 dstStr); | |
648 | ||
2d21ac55 | 649 | int mac_roman_to_unicode(const Str31 hfs_str, UniChar *uni_str, u_int32_t maxCharLen, u_int32_t *usedCharLen); |
0b4e3aa0 | 650 | |
2d21ac55 | 651 | int unicode_to_hfs(ExtendedVCB *vcb, ByteCount srcLen, u_int16_t* srcStr, Str31 dstStr, int retry); |
39236c6e | 652 | #endif |
9bccf70c | 653 | |
2d21ac55 A |
654 | /***************************************************************************** |
655 | Functions from hfs_notifications.c | |
656 | ******************************************************************************/ | |
657 | void hfs_generate_volume_notifications(struct hfsmount *hfsmp); | |
9bccf70c A |
658 | |
659 | ||
2d21ac55 A |
660 | /***************************************************************************** |
661 | Functions from hfs_readwrite.c | |
662 | ******************************************************************************/ | |
663 | extern int hfs_relocate(struct vnode *, u_int32_t, kauth_cred_t, struct proc *); | |
9bccf70c | 664 | |
39236c6e A |
665 | /* Flags for HFS truncate */ |
666 | #define HFS_TRUNCATE_SKIPUPDATE 0x00000001 | |
667 | #define HFS_TRUNCATE_SKIPTIMES 0x00000002 /* implied by skipupdate; it is a subset */ | |
668 | ||
b0d623f7 | 669 | extern int hfs_truncate(struct vnode *, off_t, int, int, int, vfs_context_t); |
d7e50217 | 670 | |
6d2010ae A |
671 | extern int hfs_release_storage (struct hfsmount *hfsmp, struct filefork *datafork, |
672 | struct filefork *rsrcfork, u_int32_t fileid); | |
673 | ||
674 | extern int hfs_prepare_release_storage (struct hfsmount *hfsmp, struct vnode *vp); | |
675 | ||
2d21ac55 | 676 | extern int hfs_bmap(struct vnode *, daddr_t, struct vnode **, daddr64_t *, unsigned int *); |
55e303ae | 677 | |
2d21ac55 | 678 | extern int hfs_fsync(struct vnode *, int, int, struct proc *); |
55e303ae | 679 | |
2d21ac55 | 680 | extern int hfs_access(struct vnode *, mode_t, kauth_cred_t, struct proc *); |
91447636 | 681 | |
2d21ac55 | 682 | extern int hfs_removeallattr(struct hfsmount *hfsmp, u_int32_t fileid); |
91447636 | 683 | |
2d21ac55 | 684 | extern int hfs_set_volxattr(struct hfsmount *hfsmp, unsigned int xattrtype, int state); |
91447636 | 685 | |
6d2010ae | 686 | extern int hfs_isallocated(struct hfsmount *hfsmp, u_int32_t startingBlock, u_int32_t numBlocks); |
91447636 | 687 | |
6d2010ae A |
688 | extern int hfs_count_allocated(struct hfsmount *hfsmp, u_int32_t startBlock, |
689 | u_int32_t numBlocks, u_int32_t *alloc_count); | |
690 | ||
691 | extern int hfs_isrbtree_active (struct hfsmount *hfsmp); | |
91447636 | 692 | |
91447636 | 693 | |
2d21ac55 A |
694 | /***************************************************************************** |
695 | Functions from hfs_vfsops.c | |
696 | ******************************************************************************/ | |
697 | int hfs_mountroot(mount_t mp, vnode_t rvp, vfs_context_t context); | |
91447636 | 698 | |
2d21ac55 A |
699 | /* used as a callback by the journaling code */ |
700 | extern void hfs_sync_metadata(void *arg); | |
91447636 | 701 | |
6d2010ae | 702 | extern int hfs_vget(struct hfsmount *, cnid_t, struct vnode **, int, int); |
91447636 | 703 | |
2d21ac55 | 704 | extern void hfs_setencodingbits(struct hfsmount *hfsmp, u_int32_t encoding); |
91447636 | 705 | |
2d21ac55 A |
706 | enum volop {VOL_UPDATE, VOL_MKDIR, VOL_RMDIR, VOL_MKFILE, VOL_RMFILE}; |
707 | extern int hfs_volupdate(struct hfsmount *hfsmp, enum volop op, int inroot); | |
708 | ||
709 | int hfs_flushvolumeheader(struct hfsmount *hfsmp, int waitfor, int altflush); | |
710 | #define HFS_ALTFLUSH 1 | |
91447636 A |
711 | |
712 | extern int hfs_extendfs(struct hfsmount *, u_int64_t, vfs_context_t); | |
713 | extern int hfs_truncatefs(struct hfsmount *, u_int64_t, vfs_context_t); | |
0c530ab8 | 714 | extern int hfs_resize_progress(struct hfsmount *, u_int32_t *); |
91447636 | 715 | |
2d21ac55 A |
716 | /* If a runtime corruption is detected, mark the volume inconsistent |
717 | * bit in the volume attributes. | |
718 | */ | |
719 | void hfs_mark_volume_inconsistent(struct hfsmount *hfsmp); | |
720 | ||
39236c6e A |
721 | void hfs_scan_blocks (struct hfsmount *hfsmp); |
722 | ||
2d21ac55 A |
723 | /***************************************************************************** |
724 | Functions from hfs_vfsutils.c | |
725 | ******************************************************************************/ | |
b0d623f7 A |
726 | u_int32_t BestBlockSizeFit(u_int32_t allocationBlockSize, |
727 | u_int32_t blockSizeLimit, | |
728 | u_int32_t baseMultiple); | |
2d21ac55 | 729 | |
39236c6e | 730 | #if CONFIG_HFS_STD |
2d21ac55 A |
731 | OSErr hfs_MountHFSVolume(struct hfsmount *hfsmp, HFSMasterDirectoryBlock *mdb, |
732 | struct proc *p); | |
39236c6e | 733 | #endif |
2d21ac55 A |
734 | OSErr hfs_MountHFSPlusVolume(struct hfsmount *hfsmp, HFSPlusVolumeHeader *vhp, |
735 | off_t embeddedOffset, u_int64_t disksize, struct proc *p, void *args, kauth_cred_t cred); | |
736 | ||
737 | extern int hfsUnmount(struct hfsmount *hfsmp, struct proc *p); | |
738 | ||
739 | extern int overflow_extents(struct filefork *fp); | |
740 | ||
741 | extern int hfs_owner_rights(struct hfsmount *hfsmp, uid_t cnode_uid, kauth_cred_t cred, | |
742 | struct proc *p, int invokesuperuserstatus); | |
91447636 | 743 | |
6d2010ae A |
744 | extern int check_for_tracked_file(struct vnode *vp, time_t ctime, uint64_t op_type, void *arg); |
745 | extern int check_for_dataless_file(struct vnode *vp, uint64_t op_type); | |
746 | ||
747 | /* | |
748 | * Journal lock function prototypes | |
749 | */ | |
39236c6e | 750 | int hfs_lock_global (struct hfsmount *hfsmp, enum hfs_locktype locktype); |
6d2010ae A |
751 | void hfs_unlock_global (struct hfsmount *hfsmp); |
752 | ||
39236c6e A |
753 | /* HFS mount lock/unlock prototypes */ |
754 | void hfs_lock_mount (struct hfsmount *hfsmp); | |
755 | void hfs_unlock_mount (struct hfsmount *hfsmp); | |
756 | ||
91447636 A |
757 | |
758 | /* HFS System file locking */ | |
759 | #define SFL_CATALOG 0x0001 | |
760 | #define SFL_EXTENTS 0x0002 | |
761 | #define SFL_BITMAP 0x0004 | |
762 | #define SFL_ATTRIBUTE 0x0008 | |
2d21ac55 A |
763 | #define SFL_STARTUP 0x0010 |
764 | #define SFL_VALIDMASK (SFL_CATALOG | SFL_EXTENTS | SFL_BITMAP | SFL_ATTRIBUTE | SFL_STARTUP) | |
91447636 | 765 | |
39236c6e | 766 | extern int hfs_systemfile_lock(struct hfsmount *, int, enum hfs_locktype); |
91447636 | 767 | extern void hfs_systemfile_unlock(struct hfsmount *, int); |
d7e50217 | 768 | |
b0d623f7 | 769 | extern u_int32_t GetFileInfo(ExtendedVCB *vcb, u_int32_t dirid, const char *name, |
2d21ac55 A |
770 | struct cat_attr *fattr, struct cat_fork *forkinfo); |
771 | ||
772 | extern void hfs_remove_orphans(struct hfsmount *); | |
773 | ||
774 | u_int32_t GetLogicalBlockSize(struct vnode *vp); | |
775 | ||
776 | extern u_int32_t hfs_freeblks(struct hfsmount * hfsmp, int wantreserve); | |
777 | ||
778 | short MacToVFSError(OSErr err); | |
779 | ||
6d2010ae | 780 | void hfs_metadatazone_init(struct hfsmount *hfsmp, int disable); |
0b4c1975 | 781 | |
2d21ac55 A |
782 | /* HFS directory hint functions. */ |
783 | extern directoryhint_t * hfs_getdirhint(struct cnode *, int, int); | |
784 | extern void hfs_reldirhint(struct cnode *, directoryhint_t *); | |
785 | extern void hfs_reldirhints(struct cnode *, int); | |
786 | extern void hfs_insertdirhint(struct cnode *, directoryhint_t *); | |
787 | ||
788 | extern int hfs_namecmp(const u_int8_t *str1, size_t len1, const u_int8_t *str2, size_t len2); | |
789 | ||
790 | extern int hfs_early_journal_init(struct hfsmount *hfsmp, HFSPlusVolumeHeader *vhp, | |
791 | void *_args, off_t embeddedOffset, daddr64_t mdb_offset, | |
792 | HFSMasterDirectoryBlock *mdbp, kauth_cred_t cred); | |
793 | ||
794 | extern int hfs_virtualmetafile(struct cnode *); | |
795 | ||
796 | extern int hfs_start_transaction(struct hfsmount *hfsmp); | |
797 | extern int hfs_end_transaction(struct hfsmount *hfsmp); | |
6d2010ae | 798 | extern int hfs_journal_flush(struct hfsmount *hfsmp, boolean_t wait_for_IO); |
e2fac8b1 | 799 | extern void hfs_sync_ejectable(struct hfsmount *hfsmp); |
2d21ac55 | 800 | |
6d2010ae A |
801 | extern void hfs_trim_callback(void *arg, uint32_t extent_count, const dk_extent_t *extents); |
802 | ||
b0d623f7 A |
803 | /* Erase unused Catalog nodes due to <rdar://problem/6947811>. */ |
804 | extern int hfs_erase_unused_nodes(struct hfsmount *hfsmp); | |
805 | ||
2d21ac55 A |
806 | |
807 | /***************************************************************************** | |
808 | Functions from hfs_vnops.c | |
809 | ******************************************************************************/ | |
810 | int hfs_write_access(struct vnode *vp, kauth_cred_t cred, struct proc *p, Boolean considerFlags); | |
811 | ||
812 | int hfs_chmod(struct vnode *vp, int mode, kauth_cred_t cred, struct proc *p); | |
813 | ||
814 | int hfs_chown(struct vnode *vp, uid_t uid, gid_t gid, kauth_cred_t cred, struct proc *p); | |
815 | ||
816 | #define kMaxSecsForFsync 5 | |
817 | #define HFS_SYNCTRANS 1 | |
818 | extern int hfs_btsync(struct vnode *vp, int sync_transaction); | |
819 | ||
820 | extern void replace_desc(struct cnode *cp, struct cat_desc *cdp); | |
821 | ||
822 | extern int hfs_vgetrsrc(struct hfsmount *hfsmp, struct vnode *vp, | |
6d2010ae | 823 | struct vnode **rvpp, int can_drop_lock, int error_on_unlink); |
2d21ac55 A |
824 | |
825 | extern int hfs_update(struct vnode *, int); | |
826 | ||
827 | ||
828 | /***************************************************************************** | |
829 | Functions from hfs_xattr.c | |
830 | ******************************************************************************/ | |
6d2010ae | 831 | |
39236c6e A |
832 | /* |
833 | * Maximum extended attribute size supported for all extended attributes except | |
6d2010ae A |
834 | * resource fork and finder info. |
835 | */ | |
39236c6e | 836 | #define HFS_XATTR_MAXSIZE INT32_MAX |
6d2010ae A |
837 | |
838 | /* Number of bits used to represent maximum extended attribute size */ | |
39236c6e | 839 | #define HFS_XATTR_SIZE_BITS 31 |
6d2010ae | 840 | |
2d21ac55 A |
841 | int hfs_attrkeycompare(HFSPlusAttrKey *searchKey, HFSPlusAttrKey *trialKey); |
842 | int hfs_buildattrkey(u_int32_t fileID, const char *attrname, HFSPlusAttrKey *key); | |
843 | void hfs_xattr_init(struct hfsmount * hfsmp); | |
844 | int file_attribute_exist(struct hfsmount *hfsmp, uint32_t fileID); | |
6d2010ae A |
845 | int init_attrdata_vnode(struct hfsmount *hfsmp); |
846 | int hfs_getxattr_internal(struct cnode *, struct vnop_getxattr_args *, | |
847 | struct hfsmount *, u_int32_t); | |
848 | int hfs_setxattr_internal(struct cnode *, caddr_t, size_t, | |
849 | struct vnop_setxattr_args *, struct hfsmount *, u_int32_t); | |
2d21ac55 A |
850 | |
851 | ||
852 | ||
853 | /***************************************************************************** | |
854 | Functions from hfs_link.c | |
855 | ******************************************************************************/ | |
856 | ||
857 | extern int hfs_unlink(struct hfsmount *hfsmp, struct vnode *dvp, struct vnode *vp, | |
858 | struct componentname *cnp, int skip_reserve); | |
6d2010ae | 859 | extern int hfs_lookup_siblinglinks(struct hfsmount *hfsmp, cnid_t linkfileid, |
2d21ac55 | 860 | cnid_t *prevlinkid, cnid_t *nextlinkid); |
39236c6e A |
861 | extern int hfs_lookup_lastlink(struct hfsmount *hfsmp, cnid_t linkfileid, |
862 | cnid_t *nextlinkid, struct cat_desc *cdesc); | |
2d21ac55 A |
863 | extern void hfs_privatedir_init(struct hfsmount *, enum privdirtype); |
864 | ||
865 | extern void hfs_savelinkorigin(cnode_t *cp, cnid_t parentcnid); | |
866 | extern void hfs_relorigins(struct cnode *cp); | |
867 | extern void hfs_relorigin(struct cnode *cp, cnid_t parentcnid); | |
868 | extern int hfs_haslinkorigin(cnode_t *cp); | |
869 | extern cnid_t hfs_currentparent(cnode_t *cp); | |
870 | extern cnid_t hfs_currentcnid(cnode_t *cp); | |
871 | ||
872 | ||
9bccf70c A |
873 | #endif /* __APPLE_API_PRIVATE */ |
874 | #endif /* KERNEL */ | |
1c79356b | 875 | #endif /* __HFS__ */ |