]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
91447636 | 2 | * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. |
1c79356b A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
e5568f75 A |
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. | |
1c79356b | 11 | * |
e5568f75 A |
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 | |
1c79356b A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
e5568f75 A |
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. | |
1c79356b A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
1c79356b A |
22 | |
23 | #ifndef __HFS__ | |
24 | #define __HFS__ | |
25 | ||
55e303ae A |
26 | #define HFS_SPARSE_DEV 1 |
27 | ||
9bccf70c A |
28 | #include <sys/appleapiopts.h> |
29 | ||
30 | #ifdef KERNEL | |
31 | #ifdef __APPLE_API_PRIVATE | |
1c79356b | 32 | #include <sys/param.h> |
1c79356b | 33 | #include <sys/queue.h> |
9bccf70c | 34 | #include <sys/mount.h> |
9bccf70c A |
35 | #include <sys/vnode.h> |
36 | #include <sys/quota.h> | |
1c79356b | 37 | #include <sys/dirent.h> |
55e303ae | 38 | #include <sys/event.h> |
1c79356b | 39 | |
91447636 A |
40 | #include <kern/locks.h> |
41 | ||
b4c24cb9 A |
42 | #include <vfs/vfs_journal.h> |
43 | ||
1c79356b | 44 | #include <hfs/hfs_format.h> |
9bccf70c A |
45 | #include <hfs/hfs_catalog.h> |
46 | #include <hfs/hfs_cnode.h> | |
1c79356b A |
47 | #include <hfs/hfs_macos_defs.h> |
48 | #include <hfs/hfs_encodings.h> | |
55e303ae | 49 | #include <hfs/hfs_hotfiles.h> |
1c79356b | 50 | |
1c79356b A |
51 | /* |
52 | * Just reported via MIG interface. | |
53 | */ | |
54 | #define VERSION_STRING "hfs-2 (4-12-99)" | |
55 | ||
56 | #define HFS_LINK_MAX 32767 | |
57 | ||
9bccf70c A |
58 | #define HFS_MAX_DEFERED_ALLOC (1024*1024) |
59 | ||
55e303ae A |
60 | // 32 gigs is a "big" file (i.e. one that when deleted |
61 | // would touch enough data that we should break it into | |
62 | // multiple separate transactions | |
63 | #define HFS_BIGFILE_SIZE (32LL * 1024LL * 1024LL * 1024LL) | |
64 | ||
1c79356b A |
65 | |
66 | enum { kMDBSize = 512 }; /* Size of I/O transfer to read entire MDB */ | |
67 | ||
68 | enum { kMasterDirectoryBlock = 2 }; /* MDB offset on disk in 512-byte blocks */ | |
69 | enum { kMDBOffset = kMasterDirectoryBlock * 512 }; /* MDB offset on disk in bytes */ | |
70 | ||
91447636 | 71 | #define kRootDirID kHFSRootFolderID |
1c79356b | 72 | |
1c79356b | 73 | |
0b4e3aa0 A |
74 | /* number of locked buffer caches to hold for b-tree meta data */ |
75 | #define kMaxLockedMetaBuffers 32 | |
1c79356b A |
76 | |
77 | /* | |
78 | * File type and creator for symbolic links | |
79 | */ | |
80 | enum { | |
9bccf70c A |
81 | kSymLinkFileType = 0x736C6E6B, /* 'slnk' */ |
82 | kSymLinkCreator = 0x72686170 /* 'rhap' */ | |
1c79356b A |
83 | }; |
84 | ||
1c79356b A |
85 | |
86 | extern struct timezone gTimeZone; | |
87 | ||
1c79356b | 88 | |
0b4e3aa0 A |
89 | /* How many free extents to cache per volume */ |
90 | #define kMaxFreeExtents 10 | |
91 | ||
9bccf70c A |
92 | /* |
93 | * HFS_MINFREE gives the minimum acceptable percentage | |
94 | * of file system blocks which may be free (but this | |
95 | * minimum will never exceed HFS_MAXRESERVE bytes). If | |
96 | * the free block count drops below this level only the | |
97 | * superuser may continue to allocate blocks. | |
98 | */ | |
99 | #define HFS_MINFREE 1 | |
55e303ae A |
100 | #define HFS_MAXRESERVE ((u_int64_t)(250*1024*1024)) |
101 | ||
102 | /* | |
103 | * The system distinguishes between the desirable low-disk | |
104 | * notifiaction levels for root volumes and non-root volumes. | |
105 | * The various thresholds are computed as a fraction of the | |
106 | * volume size, all capped at a certain fixed level | |
107 | */ | |
108 | ||
109 | #define HFS_ROOTLOWDISKTRIGGERFRACTION 5 | |
110 | #define HFS_ROOTLOWDISKTRIGGERLEVEL ((u_int64_t)(250*1024*1024)) | |
111 | #define HFS_ROOTLOWDISKSHUTOFFFRACTION 6 | |
112 | #define HFS_ROOTLOWDISKSHUTOFFLEVEL ((u_int64_t)(375*1024*1024)) | |
113 | ||
114 | #define HFS_LOWDISKTRIGGERFRACTION 1 | |
115 | #define HFS_LOWDISKTRIGGERLEVEL ((u_int64_t)(50*1024*1024)) | |
116 | #define HFS_LOWDISKSHUTOFFFRACTION 2 | |
117 | #define HFS_LOWDISKSHUTOFFLEVEL ((u_int64_t)(75*1024*1024)) | |
9bccf70c | 118 | |
1c79356b A |
119 | /* Internal Data structures*/ |
120 | ||
0b4e3aa0 | 121 | |
9bccf70c | 122 | #define kHFS_DamagedVolume 0x1 /* This volume has errors, unmount dirty */ |
1c79356b | 123 | |
9bccf70c A |
124 | /* XXX */ |
125 | #define MARK_VOLUMEDAMAGED(fcb) | |
1c79356b | 126 | |
1c79356b A |
127 | |
128 | /* This structure describes the HFS specific mount structure data. */ | |
129 | typedef struct hfsmount { | |
91447636 A |
130 | u_int32_t hfs_flags; /* see below */ |
131 | ||
1c79356b | 132 | /* Physical Description */ |
91447636 A |
133 | u_long hfs_phys_block_size; /* Always a multiple of 512 */ |
134 | daddr64_t hfs_phys_block_count; /* Num of PHYSICAL blocks of volume */ | |
135 | daddr64_t hfs_alt_id_sector; /* location of alternate VH/MDB */ | |
1c79356b A |
136 | |
137 | /* Access to VFS and devices */ | |
138 | struct mount *hfs_mp; /* filesystem vfs structure */ | |
139 | struct vnode *hfs_devvp; /* block device mounted vnode */ | |
91447636 A |
140 | struct vnode * hfs_extents_vp; |
141 | struct vnode * hfs_catalog_vp; | |
142 | struct vnode * hfs_allocation_vp; | |
143 | struct vnode * hfs_attribute_vp; | |
144 | dev_t hfs_raw_dev; /* device mounted */ | |
145 | u_int32_t hfs_logBlockSize; /* Size of buffer cache buffer for I/O */ | |
1c79356b A |
146 | |
147 | /* Default values for HFS standard and non-init access */ | |
91447636 A |
148 | uid_t hfs_uid; /* uid to set as owner of the files */ |
149 | gid_t hfs_gid; /* gid to set as owner of the files */ | |
150 | mode_t hfs_dir_mask; /* mask to and with directory protection bits */ | |
151 | mode_t hfs_file_mask; /* mask to and with file protection bits */ | |
152 | u_long hfs_encoding; /* Defualt encoding for non hfs+ volumes */ | |
153 | ||
154 | /* Persistent fields (on disk, dynamic) */ | |
155 | time_t hfs_mtime; /* file system last modification time */ | |
156 | u_int32_t hfs_filecount; /* number of files in file system */ | |
157 | u_int32_t hfs_dircount; /* number of directories in file system */ | |
158 | u_int32_t freeBlocks; /* free allocation blocks */ | |
159 | u_int32_t nextAllocation; /* start of next allocation search */ | |
160 | u_int32_t vcbNxtCNID; /* next unused catalog node ID */ | |
161 | u_int32_t vcbWrCnt; /* file system write count */ | |
162 | u_int64_t encodingsBitmap; /* in-use encodings */ | |
163 | u_int16_t vcbNmFls; /* HFS Only - root dir file count */ | |
164 | u_int16_t vcbNmRtDirs; /* HFS Only - root dir directory count */ | |
165 | ||
166 | /* Persistent fields (on disk, static) */ | |
167 | u_int16_t vcbSigWord; | |
168 | int16_t vcbFlags; | |
169 | u_int32_t vcbAtrb; | |
170 | u_int32_t vcbJinfoBlock; | |
171 | time_t hfs_itime; /* file system creation time */ | |
172 | time_t hfs_btime; /* file system last backup time */ | |
173 | u_int32_t blockSize; /* size of allocation blocks */ | |
174 | u_int32_t totalBlocks; /* total allocation blocks */ | |
175 | int32_t vcbClpSiz; | |
176 | u_int32_t vcbFndrInfo[8]; | |
177 | int16_t vcbVBMSt; /* HFS only */ | |
178 | int16_t vcbAlBlSt; /* HFS only */ | |
179 | ||
180 | /* vcb stuff */ | |
181 | u_int8_t vcbVN[256]; /* volume name in UTF-8 */ | |
182 | u_int32_t volumeNameEncodingHint; | |
183 | u_int32_t hfsPlusIOPosOffset; /* Disk block where HFS+ starts */ | |
184 | u_int32_t vcbVBMIOSize; /* volume bitmap I/O size */ | |
185 | ||
186 | /* cache of largest known free extents */ | |
187 | u_int32_t vcbFreeExtCnt; | |
188 | HFSPlusExtentDescriptor vcbFreeExt[kMaxFreeExtents]; | |
189 | ||
190 | u_int32_t reserveBlocks; /* free block reserve */ | |
191 | u_int32_t loanedBlocks; /* blocks on loan for delayed allocations */ | |
192 | ||
193 | u_int32_t localCreateDate; /* creation times for HFS+ volumes are in local time */ | |
9bccf70c A |
194 | struct cat_desc hfs_privdir_desc; |
195 | struct cat_attr hfs_privdir_attr; | |
1c79356b A |
196 | u_int32_t hfs_metadata_createdate; |
197 | hfs_to_unicode_func_t hfs_get_unicode; | |
198 | unicode_to_hfs_func_t hfs_get_hfsname; | |
9bccf70c | 199 | |
55e303ae | 200 | /* Quota variables: */ |
9bccf70c | 201 | struct quotafile hfs_qfiles[MAXQUOTAS]; /* quota files */ |
b4c24cb9 | 202 | |
55e303ae | 203 | /* Journaling variables: */ |
b4c24cb9 A |
204 | void *jnl; // the journal for this volume (if one exists) |
205 | struct vnode *jvp; // device where the journal lives (may be equal to devvp) | |
206 | u_int32_t jnl_start; // start block of the journal file (so we don't delete it) | |
55e303ae | 207 | u_int32_t jnl_size; |
b4c24cb9 A |
208 | u_int32_t hfs_jnlfileid; |
209 | u_int32_t hfs_jnlinfoblkid; | |
91447636 A |
210 | lck_rw_t hfs_global_lock; |
211 | u_int32_t hfs_global_lock_nesting; | |
55e303ae A |
212 | |
213 | /* Notification variables: */ | |
214 | unsigned long hfs_notification_conditions; | |
215 | u_int32_t hfs_freespace_notify_warninglimit; | |
216 | u_int32_t hfs_freespace_notify_desiredlevel; | |
217 | ||
91447636 A |
218 | /* time mounted and last mounted mod time "snapshot" */ |
219 | time_t hfs_mount_time; | |
220 | time_t hfs_last_mounted_mtime; | |
221 | ||
55e303ae A |
222 | /* Metadata allocation zone variables: */ |
223 | u_int32_t hfs_metazone_start; | |
224 | u_int32_t hfs_metazone_end; | |
225 | u_int32_t hfs_hotfile_start; | |
226 | u_int32_t hfs_hotfile_end; | |
227 | int hfs_hotfile_freeblks; | |
228 | int hfs_hotfile_maxblks; | |
229 | int hfs_overflow_maxblks; | |
230 | int hfs_catalog_maxblks; | |
231 | ||
232 | /* Hot File Clustering variables: */ | |
91447636 | 233 | lck_mtx_t hfc_mutex; /* serialize hot file stages */ |
55e303ae A |
234 | enum hfc_stage hfc_stage; /* what are we up to... */ |
235 | time_t hfc_timebase; /* recording period start time */ | |
236 | time_t hfc_timeout; /* recording period stop time */ | |
237 | void * hfc_recdata; /* recording data (opaque) */ | |
238 | int hfc_maxfiles; /* maximum files to track */ | |
239 | struct vnode * hfc_filevp; | |
240 | ||
241 | #ifdef HFS_SPARSE_DEV | |
242 | /* Sparse device variables: */ | |
243 | struct vnode * hfs_backingfs_rootvp; | |
244 | int hfs_sparsebandblks; | |
245 | #endif | |
91447636 A |
246 | size_t hfs_max_inline_attrsize; |
247 | ||
248 | lck_mtx_t hfs_mutex; /* protects access to hfsmount data */ | |
249 | void *hfs_freezing_proc; /* who froze the fs */ | |
1c79356b A |
250 | } hfsmount_t; |
251 | ||
91447636 A |
252 | typedef hfsmount_t ExtendedVCB; |
253 | ||
254 | /* Aliases for legacy field names */ | |
255 | #define vcbCrDate hfs_itime | |
256 | #define vcbLsMod hfs_mtime | |
257 | #define vcbVolBkUp hfs_btime | |
258 | #define extentsRefNum hfs_extents_vp | |
259 | #define catalogRefNum hfs_catalog_vp | |
260 | #define allocationsRefNum hfs_allocation_vp | |
261 | #define vcbFilCnt hfs_filecount | |
262 | #define vcbDirCnt hfs_dircount | |
263 | ||
55e303ae A |
264 | |
265 | /* HFS mount point flags */ | |
266 | #define HFS_READ_ONLY 0x001 | |
267 | #define HFS_UNKNOWN_PERMS 0x002 | |
268 | #define HFS_WRITEABLE_MEDIA 0x004 | |
269 | #define HFS_CLEANED_ORPHANS 0x008 | |
270 | #define HFS_X 0x010 | |
271 | #define HFS_CASE_SENSITIVE 0x020 | |
272 | #define HFS_STANDARD 0x040 | |
273 | #define HFS_METADATA_ZONE 0x080 | |
274 | #define HFS_FRAGMENTED_FREESPACE 0x100 | |
275 | #define HFS_NEED_JNL_RESET 0x200 | |
55e303ae | 276 | #define HFS_HAS_SPARSE_DEVICE 0x400 |
55e303ae | 277 | |
1c79356b | 278 | |
91447636 A |
279 | #define HFS_MOUNT_LOCK(hfsmp, metadata) \ |
280 | { \ | |
281 | if ((metadata) && 1) \ | |
282 | lck_mtx_lock(&(hfsmp)->hfs_mutex); \ | |
283 | } \ | |
284 | ||
285 | #define HFS_MOUNT_UNLOCK(hfsmp, metadata) \ | |
286 | { \ | |
287 | if ((metadata) && 1) \ | |
288 | lck_mtx_unlock(&(hfsmp)->hfs_mutex); \ | |
289 | } \ | |
290 | ||
291 | #define hfs_global_exclusive_lock_acquire(hfsmp) lck_rw_lock_exclusive(&(hfsmp)->hfs_global_lock) | |
292 | #define hfs_global_exclusive_lock_release(hfsmp) lck_rw_done(&(hfsmp)->hfs_global_lock) | |
293 | ||
b4c24cb9 | 294 | |
1c79356b | 295 | #define MAXHFSVNODELEN 31 |
1c79356b | 296 | |
1c79356b | 297 | |
9bccf70c | 298 | typedef struct filefork FCB; |
1c79356b | 299 | |
1c79356b A |
300 | |
301 | #define MAKE_INODE_NAME(name,linkno) \ | |
302 | (void) sprintf((name), "%s%d", HFS_INODE_PREFIX, (linkno)) | |
303 | ||
1c79356b | 304 | |
1c79356b | 305 | |
9bccf70c A |
306 | #define HFS_AVERAGE_NAME_SIZE 22 |
307 | #define AVERAGE_HFSDIRENTRY_SIZE (8+HFS_AVERAGE_NAME_SIZE+4) | |
1c79356b | 308 | |
91447636 A |
309 | #define STD_DIRENT_LEN(namlen) \ |
310 | ((sizeof(struct dirent) - (NAME_MAX+1)) + (((namlen)+1 + 3) &~ 3)) | |
1c79356b | 311 | |
91447636 A |
312 | #define EXT_DIRENT_LEN(namlen) \ |
313 | ((sizeof(struct direntry) + (namlen) - (MAXPATHLEN-1) + 3) & ~3) | |
1c79356b | 314 | |
1c79356b A |
315 | |
316 | enum { kHFSPlusMaxFileNameBytes = kHFSPlusMaxFileNameChars * 3 }; | |
317 | ||
1c79356b A |
318 | |
319 | /* macro to determine if hfs or hfsplus */ | |
320 | #define ISHFSPLUS(VCB) ((VCB)->vcbSigWord == kHFSPlusSigWord) | |
321 | #define ISHFS(VCB) ((VCB)->vcbSigWord == kHFSSigWord) | |
322 | ||
323 | ||
1c79356b A |
324 | /* |
325 | * Various ways to acquire a VFS mount point pointer: | |
326 | */ | |
91447636 | 327 | #define VTOVFS(VP) vnode_mount((VP)) |
1c79356b | 328 | #define HFSTOVFS(HFSMP) ((HFSMP)->hfs_mp) |
91447636 | 329 | #define VCBTOVFS(VCB) HFSTOVFS(VCB) |
1c79356b A |
330 | |
331 | /* | |
332 | * Various ways to acquire an HFS mount point pointer: | |
333 | */ | |
91447636 A |
334 | #define VTOHFS(VP) ((struct hfsmount *)vfs_fsprivate(vnode_mount((VP)))) |
335 | #define VFSTOHFS(MP) ((struct hfsmount *)vfs_fsprivate((MP))) | |
336 | #define VCBTOHFS(VCB) (VCB) | |
337 | #define FCBTOHFS(FCB) ((struct hfsmount *)vfs_fsprivate(vnode_mount((FCB)->ff_cp->c_vp))) | |
1c79356b A |
338 | |
339 | /* | |
91447636 | 340 | * Various ways to acquire a VCB (legacy) pointer: |
1c79356b | 341 | */ |
91447636 A |
342 | #define VTOVCB(VP) VTOHFS(VP) |
343 | #define VFSTOVCB(MP) VFSTOHFS(MP) | |
344 | #define HFSTOVCB(HFSMP) (HFSMP) | |
345 | #define FCBTOVCB(FCB) FCBTOHFS(FCB) | |
1c79356b A |
346 | |
347 | ||
55e303ae A |
348 | #define HFS_KNOTE(vp, hint) KNOTE(&VTOC(vp)->c_knotes, (hint)) |
349 | ||
350 | ||
1c79356b A |
351 | #define E_NONE 0 |
352 | #define kHFSBlockSize 512 | |
1c79356b | 353 | |
9bccf70c A |
354 | /* |
355 | * Macros for getting the MDB/VH sector and offset | |
356 | */ | |
357 | #define HFS_PRI_SECTOR(blksize) (1024 / (blksize)) | |
358 | #define HFS_PRI_OFFSET(blksize) ((blksize) > 1024 ? 1024 : 0) | |
d52fe63f A |
359 | |
360 | #define HFS_ALT_SECTOR(blksize, blkcnt) (((blkcnt) - 1) - (512 / (blksize))) | |
361 | #define HFS_ALT_OFFSET(blksize) ((blksize) > 1024 ? (blksize) - 1024 : 0) | |
362 | ||
91447636 A |
363 | |
364 | /* | |
365 | * HFS specific fcntl()'s | |
366 | */ | |
367 | #define HFS_BULKACCESS (FCNTL_FS_SPECIFIC_BASE + 0x00001) | |
368 | #define HFS_GET_MOUNT_TIME (FCNTL_FS_SPECIFIC_BASE + 0x00002) | |
369 | #define HFS_GET_LAST_MTIME (FCNTL_FS_SPECIFIC_BASE + 0x00003) | |
370 | #define HFS_GET_BOOT_INFO (FCNTL_FS_SPECIFIC_BASE + 0x00004) | |
371 | #define HFS_SET_BOOT_INFO (FCNTL_FS_SPECIFIC_BASE + 0x00005) | |
372 | ||
373 | ||
1c79356b A |
374 | /* |
375 | * This is the straight GMT conversion constant: | |
376 | * 00:00:00 January 1, 1970 - 00:00:00 January 1, 1904 | |
377 | * (3600 * 24 * ((365 * (1970 - 1904)) + (((1970 - 1904) / 4) + 1))) | |
378 | */ | |
379 | #define MAC_GMT_FACTOR 2082844800UL | |
380 | ||
1c79356b | 381 | |
91447636 A |
382 | time_t to_bsd_time(u_int32_t hfs_time); |
383 | u_int32_t to_hfs_time(time_t bsd_time); | |
1c79356b | 384 | |
9bccf70c A |
385 | int hfs_flushvolumeheader(struct hfsmount *hfsmp, int waitfor, int altflush); |
386 | #define HFS_ALTFLUSH 1 | |
1c79356b | 387 | |
55e303ae | 388 | extern int hfsUnmount(struct hfsmount *hfsmp, struct proc *p); |
1c79356b | 389 | |
91447636 | 390 | extern int hfs_getnewvnode(struct hfsmount *hfsmp, struct vnode *dvp, struct componentname *cnp, |
9bccf70c A |
391 | struct cat_desc *descp, int wantrsrc, struct cat_attr *attrp, |
392 | struct cat_fork *forkp, struct vnode **vpp); | |
393 | ||
9bccf70c A |
394 | extern u_int32_t hfs_freeblks(struct hfsmount * hfsmp, int wantreserve); |
395 | ||
b4c24cb9 A |
396 | extern void hfs_remove_orphans(struct hfsmount *); |
397 | ||
1c79356b A |
398 | |
399 | short MacToVFSError(OSErr err); | |
1c79356b | 400 | |
9bccf70c A |
401 | extern int hfs_owner_rights(struct hfsmount *hfsmp, uid_t cnode_uid, struct ucred *cred, |
402 | struct proc *p, int invokesuperuserstatus); | |
403 | ||
1c79356b A |
404 | u_long FindMetaDataDirectory(ExtendedVCB *vcb); |
405 | ||
9bccf70c A |
406 | #define kMaxSecsForFsync 5 |
407 | #define HFS_SYNCTRANS 1 | |
408 | ||
409 | extern int hfs_btsync(struct vnode *vp, int sync_transaction); | |
b4c24cb9 A |
410 | // used as a callback by the journaling code |
411 | extern void hfs_sync_metadata(void *arg); | |
1c79356b A |
412 | |
413 | short make_dir_entry(FCB **fileptr, char *name, u_int32_t fileID); | |
414 | ||
9bccf70c | 415 | |
1c79356b A |
416 | unsigned long BestBlockSizeFit(unsigned long allocationBlockSize, |
417 | unsigned long blockSizeLimit, | |
418 | unsigned long baseMultiple); | |
419 | ||
420 | OSErr hfs_MountHFSVolume(struct hfsmount *hfsmp, HFSMasterDirectoryBlock *mdb, | |
d52fe63f | 421 | struct proc *p); |
1c79356b | 422 | OSErr hfs_MountHFSPlusVolume(struct hfsmount *hfsmp, HFSPlusVolumeHeader *vhp, |
91447636 | 423 | off_t embeddedOffset, u_int64_t disksize, struct proc *p, void *args, kauth_cred_t cred); |
b4c24cb9 A |
424 | |
425 | extern int hfs_early_journal_init(struct hfsmount *hfsmp, HFSPlusVolumeHeader *vhp, | |
91447636 | 426 | void *_args, off_t embeddedOffset, daddr64_t mdb_offset, |
b4c24cb9 | 427 | HFSMasterDirectoryBlock *mdbp, struct ucred *cred); |
91447636 A |
428 | extern u_long GetFileInfo(ExtendedVCB *vcb, u_int32_t dirid, const char *name, |
429 | struct cat_attr *fattr, struct cat_fork *forkinfo); | |
1c79356b A |
430 | |
431 | int hfs_getconverter(u_int32_t encoding, hfs_to_unicode_func_t *get_unicode, | |
432 | unicode_to_hfs_func_t *get_hfsname); | |
433 | ||
434 | int hfs_relconverter(u_int32_t encoding); | |
435 | ||
436 | int hfs_to_utf8(ExtendedVCB *vcb, Str31 hfs_str, ByteCount maxDstLen, | |
437 | ByteCount *actualDstLen, unsigned char* dstStr); | |
438 | ||
439 | int utf8_to_hfs(ExtendedVCB *vcb, ByteCount srcLen, const unsigned char* srcStr, | |
440 | Str31 dstStr); | |
441 | ||
442 | int mac_roman_to_utf8(Str31 hfs_str, ByteCount maxDstLen, ByteCount *actualDstLen, | |
443 | unsigned char* dstStr); | |
444 | ||
445 | int utf8_to_mac_roman(ByteCount srcLen, const unsigned char* srcStr, Str31 dstStr); | |
446 | ||
0b4e3aa0 A |
447 | u_int32_t hfs_pickencoding(const u_int16_t *src, int len); |
448 | ||
9bccf70c A |
449 | enum volop {VOL_UPDATE, VOL_MKDIR, VOL_RMDIR, VOL_MKFILE, VOL_RMFILE}; |
450 | ||
451 | extern int hfs_volupdate(struct hfsmount *hfsmp, enum volop op, int inroot); | |
452 | ||
453 | extern void hfs_setencodingbits(struct hfsmount *hfsmp, u_int32_t encoding); | |
454 | ||
455 | ||
456 | extern void replace_desc(struct cnode *cp, struct cat_desc *cdp); | |
457 | ||
d7e50217 A |
458 | extern int hfs_namecmp(const char *, size_t, const char *, size_t); |
459 | ||
55e303ae A |
460 | extern int hfs_virtualmetafile(struct cnode *); |
461 | ||
462 | void hfs_generate_volume_notifications(struct hfsmount *hfsmp); | |
463 | ||
91447636 A |
464 | __private_extern__ u_int32_t hfs_getencodingbias(void); |
465 | __private_extern__ void hfs_setencodingbias(u_int32_t bias); | |
466 | ||
467 | extern int hfs_vgetrsrc(struct hfsmount *hfsmp, struct vnode *vp, | |
468 | struct vnode **rvpp, struct proc *p); | |
469 | ||
470 | extern int hfs_update(struct vnode *, int); | |
471 | ||
472 | extern int hfs_truncate(struct vnode *, off_t, int, int, vfs_context_t); | |
473 | ||
474 | extern int hfs_fsync(struct vnode *, int, int, struct proc *); | |
475 | ||
476 | extern int hfs_access(struct vnode *, mode_t, struct ucred *, struct proc *); | |
477 | ||
478 | extern int hfs_vget(struct hfsmount *, cnid_t, struct vnode **, int); | |
479 | ||
480 | extern int hfs_bmap(struct vnode *, daddr_t, struct vnode **, daddr64_t *, int *); | |
481 | ||
482 | extern int hfs_removeallattr(struct hfsmount *hfsmp, u_int32_t fileid); | |
483 | ||
484 | __private_extern__ int hfs_start_transaction(struct hfsmount *hfsmp); | |
485 | __private_extern__ int hfs_end_transaction(struct hfsmount *hfsmp); | |
486 | ||
487 | extern int hfs_setextendedsecurity(struct hfsmount *hfsmp, int state); | |
488 | extern void hfs_checkextendedsecurity(struct hfsmount *hfsmp); | |
489 | ||
490 | extern int hfs_extendfs(struct hfsmount *, u_int64_t, vfs_context_t); | |
491 | extern int hfs_truncatefs(struct hfsmount *, u_int64_t, vfs_context_t); | |
492 | ||
493 | extern int hfs_isallocated(struct hfsmount *, u_long, u_long); | |
494 | ||
495 | ||
496 | /* HFS System file locking */ | |
497 | #define SFL_CATALOG 0x0001 | |
498 | #define SFL_EXTENTS 0x0002 | |
499 | #define SFL_BITMAP 0x0004 | |
500 | #define SFL_ATTRIBUTE 0x0008 | |
501 | #define SFL_VALIDMASK (SFL_CATALOG | SFL_EXTENTS | SFL_BITMAP | SFL_ATTRIBUTE) | |
502 | ||
503 | extern int hfs_systemfile_lock(struct hfsmount *, int, enum hfslocktype); | |
504 | extern void hfs_systemfile_unlock(struct hfsmount *, int); | |
d7e50217 | 505 | |
9bccf70c A |
506 | #endif /* __APPLE_API_PRIVATE */ |
507 | #endif /* KERNEL */ | |
1c79356b | 508 | #endif /* __HFS__ */ |