]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
55e303ae | 2 | * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. |
1c79356b A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
1c79356b A |
25 | |
26 | #ifndef __HFS__ | |
27 | #define __HFS__ | |
28 | ||
55e303ae A |
29 | #define HFS_SPARSE_DEV 1 |
30 | ||
9bccf70c A |
31 | #include <sys/appleapiopts.h> |
32 | ||
33 | #ifdef KERNEL | |
34 | #ifdef __APPLE_API_PRIVATE | |
1c79356b A |
35 | #include <sys/param.h> |
36 | #include <sys/lock.h> | |
37 | #include <sys/queue.h> | |
9bccf70c A |
38 | #include <sys/mount.h> |
39 | #include <sys/namei.h> | |
40 | #include <sys/vnode.h> | |
41 | #include <sys/quota.h> | |
1c79356b | 42 | #include <sys/dirent.h> |
55e303ae | 43 | #include <sys/event.h> |
1c79356b | 44 | |
b4c24cb9 A |
45 | #include <vfs/vfs_journal.h> |
46 | ||
1c79356b | 47 | #include <hfs/hfs_format.h> |
9bccf70c A |
48 | #include <hfs/hfs_catalog.h> |
49 | #include <hfs/hfs_cnode.h> | |
1c79356b A |
50 | #include <hfs/hfs_macos_defs.h> |
51 | #include <hfs/hfs_encodings.h> | |
55e303ae | 52 | #include <hfs/hfs_hotfiles.h> |
1c79356b A |
53 | |
54 | ||
9bccf70c A |
55 | struct uio; // This is more effective than #include <sys/uio.h> in case KERNEL is undefined... |
56 | struct hfslockf; /* For advisory locking */ | |
1c79356b A |
57 | |
58 | /* | |
59 | * Just reported via MIG interface. | |
60 | */ | |
61 | #define VERSION_STRING "hfs-2 (4-12-99)" | |
62 | ||
63 | #define HFS_LINK_MAX 32767 | |
64 | ||
9bccf70c A |
65 | #define HFS_MAX_DEFERED_ALLOC (1024*1024) |
66 | ||
55e303ae A |
67 | // 32 gigs is a "big" file (i.e. one that when deleted |
68 | // would touch enough data that we should break it into | |
69 | // multiple separate transactions | |
70 | #define HFS_BIGFILE_SIZE (32LL * 1024LL * 1024LL * 1024LL) | |
71 | ||
1c79356b A |
72 | |
73 | enum { kMDBSize = 512 }; /* Size of I/O transfer to read entire MDB */ | |
74 | ||
75 | enum { kMasterDirectoryBlock = 2 }; /* MDB offset on disk in 512-byte blocks */ | |
76 | enum { kMDBOffset = kMasterDirectoryBlock * 512 }; /* MDB offset on disk in bytes */ | |
77 | ||
78 | enum { | |
79 | kUnknownID = 0, | |
80 | kRootParID = 1, | |
81 | kRootDirID = 2 | |
82 | }; | |
83 | ||
84 | enum { | |
1c79356b A |
85 | kDataFork, |
86 | kRsrcFork, | |
9bccf70c | 87 | kDirectory |
1c79356b A |
88 | }; |
89 | ||
0b4e3aa0 A |
90 | /* number of locked buffer caches to hold for b-tree meta data */ |
91 | #define kMaxLockedMetaBuffers 32 | |
1c79356b A |
92 | |
93 | /* | |
94 | * File type and creator for symbolic links | |
95 | */ | |
96 | enum { | |
9bccf70c A |
97 | kSymLinkFileType = 0x736C6E6B, /* 'slnk' */ |
98 | kSymLinkCreator = 0x72686170 /* 'rhap' */ | |
1c79356b A |
99 | }; |
100 | ||
1c79356b A |
101 | |
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 A |
116 | #define HFS_MAXRESERVE ((u_int64_t)(250*1024*1024)) |
117 | ||
118 | /* | |
119 | * The system distinguishes between the desirable low-disk | |
120 | * notifiaction levels for root volumes and non-root volumes. | |
121 | * The various thresholds are computed as a fraction of the | |
122 | * volume size, all capped at a certain fixed level | |
123 | */ | |
124 | ||
125 | #define HFS_ROOTLOWDISKTRIGGERFRACTION 5 | |
126 | #define HFS_ROOTLOWDISKTRIGGERLEVEL ((u_int64_t)(250*1024*1024)) | |
127 | #define HFS_ROOTLOWDISKSHUTOFFFRACTION 6 | |
128 | #define HFS_ROOTLOWDISKSHUTOFFLEVEL ((u_int64_t)(375*1024*1024)) | |
129 | ||
130 | #define HFS_LOWDISKTRIGGERFRACTION 1 | |
131 | #define HFS_LOWDISKTRIGGERLEVEL ((u_int64_t)(50*1024*1024)) | |
132 | #define HFS_LOWDISKSHUTOFFFRACTION 2 | |
133 | #define HFS_LOWDISKSHUTOFFLEVEL ((u_int64_t)(75*1024*1024)) | |
9bccf70c | 134 | |
1c79356b A |
135 | /* Internal Data structures*/ |
136 | ||
137 | struct vcb_t { | |
1c79356b | 138 | u_int16_t vcbSigWord; |
1c79356b | 139 | int16_t vcbAtrb; |
9bccf70c A |
140 | int16_t vcbFlags; |
141 | int16_t vcbspare; | |
b4c24cb9 | 142 | u_int32_t vcbJinfoBlock; |
0b4e3aa0 A |
143 | |
144 | u_int32_t vcbCrDate; | |
145 | u_int32_t vcbLsMod; | |
1c79356b | 146 | u_int32_t vcbVolBkUp; |
0b4e3aa0 | 147 | |
1c79356b A |
148 | int32_t vcbFilCnt; |
149 | int32_t vcbDirCnt; | |
9bccf70c A |
150 | u_int32_t blockSize; /* size of allocation blocks */ |
151 | u_int32_t totalBlocks; /* total allocation blocks */ | |
152 | u_int32_t freeBlocks; /* free allocation blocks */ | |
153 | u_int32_t nextAllocation; /* start of next allocation search */ | |
0b4e3aa0 A |
154 | int32_t vcbClpSiz; |
155 | u_int32_t vcbNxtCNID; | |
9bccf70c A |
156 | u_int32_t vcbCNIDGen; |
157 | int32_t vcbWrCnt; | |
0b4e3aa0 | 158 | |
1c79356b | 159 | int32_t vcbFndrInfo[8]; |
0b4e3aa0 A |
160 | |
161 | u_int64_t encodingsBitmap; /* HFS Plus only */ | |
162 | ||
9bccf70c | 163 | u_int16_t vcbNmFls; /* HFS only */ |
0b4e3aa0 | 164 | u_int16_t vcbNmRtDirs; /* HFS only */ |
9bccf70c A |
165 | int16_t vcbVBMSt; /* HFS only */ |
166 | int16_t vcbAlBlSt; /* HFS only */ | |
0b4e3aa0 | 167 | |
1c79356b A |
168 | struct vnode * extentsRefNum; |
169 | struct vnode * catalogRefNum; | |
170 | struct vnode * allocationsRefNum; | |
0b4e3aa0 | 171 | |
9bccf70c | 172 | u_int8_t vcbVN[256]; /* volume name in UTF-8 */ |
0b4e3aa0 | 173 | u_int32_t volumeNameEncodingHint; |
9bccf70c | 174 | u_int32_t hfsPlusIOPosOffset; /* Disk block where HFS+ starts */ |
0b4e3aa0 | 175 | u_int32_t vcbVBMIOSize; /* volume bitmap I/O size */ |
0b4e3aa0 | 176 | |
9bccf70c A |
177 | /* cache of largest known free extents */ |
178 | u_int32_t vcbFreeExtCnt; | |
179 | HFSPlusExtentDescriptor vcbFreeExt[kMaxFreeExtents]; | |
180 | ||
181 | u_int32_t reserveBlocks; /* free block reserve */ | |
182 | u_int32_t loanedBlocks; /* blocks on loan for delayed allocations */ | |
0b4e3aa0 | 183 | |
1c79356b A |
184 | u_int32_t localCreateDate; /* creation times for HFS+ volumes are in local time */ |
185 | simple_lock_data_t vcbSimpleLock; /* simple lock to allow concurrent access to vcb data */ | |
186 | }; | |
187 | typedef struct vcb_t ExtendedVCB; | |
188 | ||
0b4e3aa0 | 189 | |
9bccf70c | 190 | #define kHFS_DamagedVolume 0x1 /* This volume has errors, unmount dirty */ |
1c79356b | 191 | |
9bccf70c A |
192 | /* XXX */ |
193 | #define MARK_VOLUMEDAMAGED(fcb) | |
1c79356b A |
194 | |
195 | /* | |
196 | * NOTE: The code relies on being able to cast an ExtendedVCB* to a vfsVCB* in order | |
197 | * to gain access to the mount point pointer from a pointer | |
198 | * to an ExtendedVCB. DO NOT INSERT OTHER FIELDS BEFORE THE vcb FIELD!! | |
199 | * | |
200 | * vcbFlags, vcbLsMod, vcbFilCnt, vcbDirCnt, vcbNxtCNID, etc | |
201 | * are locked by the hfs_lock simple lock. | |
202 | */ | |
203 | typedef struct vfsVCB { | |
204 | ExtendedVCB vcb_vcb; | |
205 | struct hfsmount *vcb_hfsmp; /* Pointer to hfsmount structure */ | |
206 | } vfsVCB_t; | |
207 | ||
208 | ||
209 | ||
210 | /* This structure describes the HFS specific mount structure data. */ | |
211 | typedef struct hfsmount { | |
55e303ae | 212 | u_int32_t hfs_flags; /* see below */ |
1c79356b A |
213 | |
214 | /* Physical Description */ | |
215 | u_long hfs_phys_block_count; /* Num of PHYSICAL blocks of volume */ | |
216 | u_long hfs_phys_block_size; /* Always a multiple of 512 */ | |
217 | ||
218 | /* Access to VFS and devices */ | |
219 | struct mount *hfs_mp; /* filesystem vfs structure */ | |
220 | struct vnode *hfs_devvp; /* block device mounted vnode */ | |
221 | dev_t hfs_raw_dev; /* device mounted */ | |
222 | struct netexport hfs_export; /* Export information */ | |
223 | u_int32_t hfs_logBlockSize; /* Size of buffer cache buffer for I/O */ | |
224 | ||
225 | /* Default values for HFS standard and non-init access */ | |
226 | uid_t hfs_uid; /* uid to set as owner of the files */ | |
227 | gid_t hfs_gid; /* gid to set as owner of the files */ | |
228 | mode_t hfs_dir_mask; /* mask to and with directory protection bits */ | |
229 | mode_t hfs_file_mask; /* mask to and with file protection bits */ | |
230 | u_long hfs_encoding; /* Defualt encoding for non hfs+ volumes */ | |
231 | ||
1c79356b A |
232 | /* HFS Specific */ |
233 | struct vfsVCB hfs_vcb; | |
9bccf70c A |
234 | struct cat_desc hfs_privdir_desc; |
235 | struct cat_attr hfs_privdir_attr; | |
1c79356b A |
236 | u_int32_t hfs_metadata_createdate; |
237 | hfs_to_unicode_func_t hfs_get_unicode; | |
238 | unicode_to_hfs_func_t hfs_get_hfsname; | |
9bccf70c | 239 | |
55e303ae | 240 | /* Quota variables: */ |
9bccf70c | 241 | struct quotafile hfs_qfiles[MAXQUOTAS]; /* quota files */ |
b4c24cb9 | 242 | |
55e303ae | 243 | /* Journaling variables: */ |
b4c24cb9 A |
244 | void *jnl; // the journal for this volume (if one exists) |
245 | struct vnode *jvp; // device where the journal lives (may be equal to devvp) | |
246 | u_int32_t jnl_start; // start block of the journal file (so we don't delete it) | |
55e303ae | 247 | u_int32_t jnl_size; |
b4c24cb9 A |
248 | u_int32_t hfs_jnlfileid; |
249 | u_int32_t hfs_jnlinfoblkid; | |
55e303ae | 250 | volatile int readers; |
b4c24cb9 | 251 | volatile int blocker; |
55e303ae A |
252 | |
253 | /* Notification variables: */ | |
254 | unsigned long hfs_notification_conditions; | |
255 | u_int32_t hfs_freespace_notify_warninglimit; | |
256 | u_int32_t hfs_freespace_notify_desiredlevel; | |
257 | ||
258 | /* Metadata allocation zone variables: */ | |
259 | u_int32_t hfs_metazone_start; | |
260 | u_int32_t hfs_metazone_end; | |
261 | u_int32_t hfs_hotfile_start; | |
262 | u_int32_t hfs_hotfile_end; | |
263 | int hfs_hotfile_freeblks; | |
264 | int hfs_hotfile_maxblks; | |
265 | int hfs_overflow_maxblks; | |
266 | int hfs_catalog_maxblks; | |
267 | ||
268 | /* Hot File Clustering variables: */ | |
269 | enum hfc_stage hfc_stage; /* what are we up to... */ | |
270 | time_t hfc_timebase; /* recording period start time */ | |
271 | time_t hfc_timeout; /* recording period stop time */ | |
272 | void * hfc_recdata; /* recording data (opaque) */ | |
273 | int hfc_maxfiles; /* maximum files to track */ | |
274 | struct vnode * hfc_filevp; | |
275 | ||
276 | #ifdef HFS_SPARSE_DEV | |
277 | /* Sparse device variables: */ | |
278 | struct vnode * hfs_backingfs_rootvp; | |
279 | int hfs_sparsebandblks; | |
280 | #endif | |
1c79356b A |
281 | } hfsmount_t; |
282 | ||
55e303ae A |
283 | |
284 | /* HFS mount point flags */ | |
285 | #define HFS_READ_ONLY 0x001 | |
286 | #define HFS_UNKNOWN_PERMS 0x002 | |
287 | #define HFS_WRITEABLE_MEDIA 0x004 | |
288 | #define HFS_CLEANED_ORPHANS 0x008 | |
289 | #define HFS_X 0x010 | |
290 | #define HFS_CASE_SENSITIVE 0x020 | |
291 | #define HFS_STANDARD 0x040 | |
292 | #define HFS_METADATA_ZONE 0x080 | |
293 | #define HFS_FRAGMENTED_FREESPACE 0x100 | |
294 | #define HFS_NEED_JNL_RESET 0x200 | |
295 | ||
296 | #ifdef HFS_SPARSE_DEV | |
297 | #define HFS_HAS_SPARSE_DEVICE 0x400 | |
298 | #endif | |
299 | ||
1c79356b | 300 | |
b4c24cb9 A |
301 | #define hfs_global_shared_lock_acquire(hfsmp) \ |
302 | do { \ | |
303 | if (hfsmp->blocker) { \ | |
304 | tsleep((caddr_t)&hfsmp->blocker, PRIBIO, "journal_blocker", 0); \ | |
305 | continue; \ | |
306 | } \ | |
307 | hfsmp->readers++; \ | |
308 | break; \ | |
309 | } while (1) | |
310 | ||
311 | #define hfs_global_shared_lock_release(hfsmp) \ | |
312 | do { \ | |
313 | hfsmp->readers--; \ | |
314 | if (hfsmp->readers == 0) { \ | |
315 | wakeup((caddr_t)&hfsmp->readers); \ | |
316 | } \ | |
317 | } while (0) | |
318 | ||
319 | #define hfs_global_exclusive_lock_acquire(hfsmp) \ | |
320 | do { \ | |
321 | if (hfsmp->blocker) { \ | |
322 | tsleep((caddr_t)&hfsmp->blocker, PRIBIO, "journal_blocker", 0); \ | |
323 | continue; \ | |
324 | } \ | |
325 | if (hfsmp->readers != 0) { \ | |
326 | tsleep((caddr_t)&hfsmp->readers, PRIBIO, "journal_enable/disble", 0); \ | |
327 | continue; \ | |
328 | } \ | |
329 | hfsmp->blocker = 1; \ | |
330 | break; \ | |
331 | } while (1) | |
332 | ||
333 | #define hfs_global_exclusive_lock_release(hfsmp) \ | |
334 | hfsmp->blocker = 0; \ | |
335 | wakeup((caddr_t)&hfsmp->blocker) | |
336 | ||
1c79356b | 337 | #define MAXHFSVNODELEN 31 |
1c79356b | 338 | |
1c79356b | 339 | |
9bccf70c | 340 | typedef struct filefork FCB; |
1c79356b | 341 | |
1c79356b A |
342 | |
343 | #define MAKE_INODE_NAME(name,linkno) \ | |
344 | (void) sprintf((name), "%s%d", HFS_INODE_PREFIX, (linkno)) | |
345 | ||
1c79356b | 346 | |
1c79356b A |
347 | /* structure to hold a "." or ".." directory entry (12 bytes) */ |
348 | typedef struct hfsdotentry { | |
349 | u_int32_t d_fileno; /* unique file number */ | |
350 | u_int16_t d_reclen; /* length of this structure */ | |
351 | u_int8_t d_type; /* dirent file type */ | |
352 | u_int8_t d_namelen; /* len of filename */ | |
353 | char d_name[4]; /* "." or ".." */ | |
354 | } hfsdotentry; | |
355 | ||
9bccf70c A |
356 | #define HFS_AVERAGE_NAME_SIZE 22 |
357 | #define AVERAGE_HFSDIRENTRY_SIZE (8+HFS_AVERAGE_NAME_SIZE+4) | |
1c79356b A |
358 | #define MAX_HFSDIRENTRY_SIZE sizeof(struct dirent) |
359 | ||
360 | #define DIRENTRY_SIZE(namlen) \ | |
361 | ((sizeof(struct dirent) - (NAME_MAX+1)) + (((namlen)+1 + 3) &~ 3)) | |
362 | ||
1c79356b | 363 | |
1c79356b A |
364 | |
365 | enum { kHFSPlusMaxFileNameBytes = kHFSPlusMaxFileNameChars * 3 }; | |
366 | ||
367 | enum { kdirentMaxNameBytes = NAME_MAX }; | |
368 | ||
1c79356b A |
369 | |
370 | /* macro to determine if hfs or hfsplus */ | |
371 | #define ISHFSPLUS(VCB) ((VCB)->vcbSigWord == kHFSPlusSigWord) | |
372 | #define ISHFS(VCB) ((VCB)->vcbSigWord == kHFSSigWord) | |
373 | ||
374 | ||
1c79356b A |
375 | /* |
376 | * Various ways to acquire a VFS mount point pointer: | |
377 | */ | |
378 | #define VTOVFS(VP) ((VP)->v_mount) | |
1c79356b A |
379 | #define HFSTOVFS(HFSMP) ((HFSMP)->hfs_mp) |
380 | #define VCBTOVFS(VCB) (((struct vfsVCB *)(VCB))->vcb_hfsmp->hfs_mp) | |
381 | ||
382 | /* | |
383 | * Various ways to acquire an HFS mount point pointer: | |
384 | */ | |
385 | #define VTOHFS(VP) ((struct hfsmount *)((VP)->v_mount->mnt_data)) | |
1c79356b A |
386 | #define VFSTOHFS(MP) ((struct hfsmount *)(MP)->mnt_data) |
387 | #define VCBTOHFS(VCB) (((struct vfsVCB *)(VCB))->vcb_hfsmp) | |
b4c24cb9 | 388 | #define FCBTOHFS(FCB) ((struct hfsmount *)(FCB)->ff_cp->c_vp->v_mount->mnt_data) |
1c79356b A |
389 | |
390 | /* | |
391 | * Various ways to acquire a VCB pointer: | |
392 | */ | |
393 | #define VTOVCB(VP) (&(((struct hfsmount *)((VP)->v_mount->mnt_data))->hfs_vcb.vcb_vcb)) | |
1c79356b A |
394 | #define VFSTOVCB(MP) (&(((struct hfsmount *)(MP)->mnt_data)->hfs_vcb.vcb_vcb)) |
395 | #define HFSTOVCB(HFSMP) (&(HFSMP)->hfs_vcb.vcb_vcb) | |
b4c24cb9 | 396 | #define FCBTOVCB(FCB) (&(((struct hfsmount *)((FCB)->ff_cp->c_vp->v_mount->mnt_data))->hfs_vcb.vcb_vcb)) |
1c79356b A |
397 | |
398 | ||
55e303ae A |
399 | #define HFS_KNOTE(vp, hint) KNOTE(&VTOC(vp)->c_knotes, (hint)) |
400 | ||
401 | ||
1c79356b A |
402 | #define E_NONE 0 |
403 | #define kHFSBlockSize 512 | |
1c79356b | 404 | |
9bccf70c A |
405 | /* |
406 | * Macros for getting the MDB/VH sector and offset | |
407 | */ | |
408 | #define HFS_PRI_SECTOR(blksize) (1024 / (blksize)) | |
409 | #define HFS_PRI_OFFSET(blksize) ((blksize) > 1024 ? 1024 : 0) | |
d52fe63f A |
410 | |
411 | #define HFS_ALT_SECTOR(blksize, blkcnt) (((blkcnt) - 1) - (512 / (blksize))) | |
412 | #define HFS_ALT_OFFSET(blksize) ((blksize) > 1024 ? (blksize) - 1024 : 0) | |
413 | ||
1c79356b A |
414 | /* |
415 | * This is the straight GMT conversion constant: | |
416 | * 00:00:00 January 1, 1970 - 00:00:00 January 1, 1904 | |
417 | * (3600 * 24 * ((365 * (1970 - 1904)) + (((1970 - 1904) / 4) + 1))) | |
418 | */ | |
419 | #define MAC_GMT_FACTOR 2082844800UL | |
420 | ||
1c79356b A |
421 | |
422 | u_int32_t to_bsd_time(u_int32_t hfs_time); | |
423 | u_int32_t to_hfs_time(u_int32_t bsd_time); | |
424 | ||
9bccf70c A |
425 | int hfs_flushvolumeheader(struct hfsmount *hfsmp, int waitfor, int altflush); |
426 | #define HFS_ALTFLUSH 1 | |
1c79356b | 427 | |
55e303ae | 428 | extern int hfsUnmount(struct hfsmount *hfsmp, struct proc *p); |
1c79356b | 429 | |
9bccf70c A |
430 | |
431 | extern int hfs_getcnode(struct hfsmount *hfsmp, cnid_t cnid, struct cat_desc *descp, | |
432 | int wantrsrc, struct cat_attr *attrp, struct cat_fork *forkp, | |
433 | struct vnode **vpp); | |
434 | ||
435 | extern int hfs_getnewvnode(struct hfsmount *hfsmp, struct cnode *cp, | |
436 | struct cat_desc *descp, int wantrsrc, struct cat_attr *attrp, | |
437 | struct cat_fork *forkp, struct vnode **vpp); | |
438 | ||
1c79356b | 439 | extern int hfs_metafilelocking(struct hfsmount *hfsmp, u_long fileID, u_int flags, struct proc *p); |
1c79356b | 440 | |
9bccf70c A |
441 | extern u_int32_t hfs_freeblks(struct hfsmount * hfsmp, int wantreserve); |
442 | ||
b4c24cb9 A |
443 | extern void hfs_remove_orphans(struct hfsmount *); |
444 | ||
1c79356b A |
445 | |
446 | short MacToVFSError(OSErr err); | |
1c79356b | 447 | |
9bccf70c A |
448 | extern int hfs_owner_rights(struct hfsmount *hfsmp, uid_t cnode_uid, struct ucred *cred, |
449 | struct proc *p, int invokesuperuserstatus); | |
450 | ||
1c79356b A |
451 | u_long FindMetaDataDirectory(ExtendedVCB *vcb); |
452 | ||
9bccf70c A |
453 | #define kMaxSecsForFsync 5 |
454 | #define HFS_SYNCTRANS 1 | |
455 | ||
456 | extern int hfs_btsync(struct vnode *vp, int sync_transaction); | |
b4c24cb9 A |
457 | // used as a callback by the journaling code |
458 | extern void hfs_sync_metadata(void *arg); | |
1c79356b A |
459 | |
460 | short make_dir_entry(FCB **fileptr, char *name, u_int32_t fileID); | |
461 | ||
9bccf70c | 462 | |
1c79356b A |
463 | unsigned long BestBlockSizeFit(unsigned long allocationBlockSize, |
464 | unsigned long blockSizeLimit, | |
465 | unsigned long baseMultiple); | |
466 | ||
467 | OSErr hfs_MountHFSVolume(struct hfsmount *hfsmp, HFSMasterDirectoryBlock *mdb, | |
d52fe63f | 468 | struct proc *p); |
1c79356b | 469 | OSErr hfs_MountHFSPlusVolume(struct hfsmount *hfsmp, HFSPlusVolumeHeader *vhp, |
b4c24cb9 A |
470 | off_t embeddedOffset, u_int64_t disksize, struct proc *p, void *args); |
471 | ||
472 | extern int hfs_early_journal_init(struct hfsmount *hfsmp, HFSPlusVolumeHeader *vhp, | |
473 | void *_args, int embeddedOffset, int mdb_offset, | |
474 | HFSMasterDirectoryBlock *mdbp, struct ucred *cred); | |
475 | extern u_long GetFileInfo(ExtendedVCB *vcb, u_int32_t dirid, char *name, | |
476 | struct cat_attr *fattr, struct cat_fork *forkinfo); | |
1c79356b A |
477 | |
478 | int hfs_getconverter(u_int32_t encoding, hfs_to_unicode_func_t *get_unicode, | |
479 | unicode_to_hfs_func_t *get_hfsname); | |
480 | ||
481 | int hfs_relconverter(u_int32_t encoding); | |
482 | ||
483 | int hfs_to_utf8(ExtendedVCB *vcb, Str31 hfs_str, ByteCount maxDstLen, | |
484 | ByteCount *actualDstLen, unsigned char* dstStr); | |
485 | ||
486 | int utf8_to_hfs(ExtendedVCB *vcb, ByteCount srcLen, const unsigned char* srcStr, | |
487 | Str31 dstStr); | |
488 | ||
489 | int mac_roman_to_utf8(Str31 hfs_str, ByteCount maxDstLen, ByteCount *actualDstLen, | |
490 | unsigned char* dstStr); | |
491 | ||
492 | int utf8_to_mac_roman(ByteCount srcLen, const unsigned char* srcStr, Str31 dstStr); | |
493 | ||
0b4e3aa0 A |
494 | u_int32_t hfs_pickencoding(const u_int16_t *src, int len); |
495 | ||
9bccf70c A |
496 | enum volop {VOL_UPDATE, VOL_MKDIR, VOL_RMDIR, VOL_MKFILE, VOL_RMFILE}; |
497 | ||
498 | extern int hfs_volupdate(struct hfsmount *hfsmp, enum volop op, int inroot); | |
499 | ||
500 | extern void hfs_setencodingbits(struct hfsmount *hfsmp, u_int32_t encoding); | |
501 | ||
502 | ||
503 | extern void replace_desc(struct cnode *cp, struct cat_desc *cdp); | |
504 | ||
d7e50217 A |
505 | extern int hfs_namecmp(const char *, size_t, const char *, size_t); |
506 | ||
55e303ae A |
507 | extern int hfs_virtualmetafile(struct cnode *); |
508 | ||
509 | void hfs_generate_volume_notifications(struct hfsmount *hfsmp); | |
510 | ||
d7e50217 | 511 | |
9bccf70c A |
512 | #endif /* __APPLE_API_PRIVATE */ |
513 | #endif /* KERNEL */ | |
1c79356b | 514 | #endif /* __HFS__ */ |