0003-Add-helper-include-files-absent-from-the-upstream-pa.patch 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024
  1. From: =?UTF-8?q?Rog=C3=A9rio=20Brito?= <rbrito@ime.usp.br>
  2. Date: Thu, 24 Oct 2013 01:11:21 -0200
  3. Subject: Add helper include files absent from the upstream package
  4. Add some include files from an Apple system that contain the definition of
  5. the data structures used by the programs that manipulate the filesystems.
  6. ---
  7. include/bitstring.h | 164 +++++++++++
  8. include/hfs/hfs_format.h | 689 +++++++++++++++++++++++++++++++++++++++++++++
  9. include/hfs/hfs_mount.h | 78 +++++
  10. include/sys/appleapiopts.h | 52 ++++
  11. 4 files changed, 983 insertions(+)
  12. create mode 100644 include/bitstring.h
  13. create mode 100644 include/hfs/hfs_format.h
  14. create mode 100644 include/hfs/hfs_mount.h
  15. create mode 100644 include/sys/appleapiopts.h
  16. diff --git a/include/bitstring.h b/include/bitstring.h
  17. new file mode 100644
  18. index 0000000..fbecfbe
  19. --- /dev/null
  20. +++ b/include/bitstring.h
  21. @@ -0,0 +1,164 @@
  22. +/*
  23. + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  24. + *
  25. + * @APPLE_LICENSE_HEADER_START@
  26. + *
  27. + * The contents of this file constitute Original Code as defined in and
  28. + * are subject to the Apple Public Source License Version 1.1 (the
  29. + * "License"). You may not use this file except in compliance with the
  30. + * License. Please obtain a copy of the License at
  31. + * http://www.apple.com/publicsource and read it before using this file.
  32. + *
  33. + * This Original Code and all software distributed under the License are
  34. + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  35. + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  36. + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  37. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
  38. + * License for the specific language governing rights and limitations
  39. + * under the License.
  40. + *
  41. + * @APPLE_LICENSE_HEADER_END@
  42. + */
  43. +/*
  44. + * Copyright (c) 1989, 1993
  45. + * The Regents of the University of California. All rights reserved.
  46. + *
  47. + * This code is derived from software contributed to Berkeley by
  48. + * Paul Vixie.
  49. + *
  50. + * Redistribution and use in source and binary forms, with or without
  51. + * modification, are permitted provided that the following conditions
  52. + * are met:
  53. + * 1. Redistributions of source code must retain the above copyright
  54. + * notice, this list of conditions and the following disclaimer.
  55. + * 2. Redistributions in binary form must reproduce the above copyright
  56. + * notice, this list of conditions and the following disclaimer in the
  57. + * documentation and/or other materials provided with the distribution.
  58. + * 3. All advertising materials mentioning features or use of this software
  59. + * must display the following acknowledgement:
  60. + * This product includes software developed by the University of
  61. + * California, Berkeley and its contributors.
  62. + * 4. Neither the name of the University nor the names of its contributors
  63. + * may be used to endorse or promote products derived from this software
  64. + * without specific prior written permission.
  65. + *
  66. + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  67. + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  68. + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  69. + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  70. + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  71. + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  72. + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  73. + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  74. + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  75. + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  76. + * SUCH DAMAGE.
  77. + *
  78. + * @(#)bitstring.h 8.1 (Berkeley) 7/19/93
  79. + */
  80. +
  81. +#ifndef _BITSTRING_H_
  82. +#define _BITSTRING_H_
  83. +
  84. +typedef unsigned char bitstr_t;
  85. +
  86. +/* internal macros */
  87. + /* byte of the bitstring bit is in */
  88. +#define _bit_byte(bit) \
  89. + ((bit) >> 3)
  90. +
  91. + /* mask for the bit within its byte */
  92. +#define _bit_mask(bit) \
  93. + (1 << ((bit)&0x7))
  94. +
  95. +/* external macros */
  96. + /* bytes in a bitstring of nbits bits */
  97. +#define bitstr_size(nbits) \
  98. + ((((nbits) - 1) >> 3) + 1)
  99. +
  100. + /* allocate a bitstring */
  101. +#define bit_alloc(nbits) \
  102. + (bitstr_t *)calloc(1, \
  103. + (unsigned int)bitstr_size(nbits) * sizeof(bitstr_t))
  104. +
  105. + /* allocate a bitstring on the stack */
  106. +#define bit_decl(name, nbits) \
  107. + (name)[bitstr_size(nbits)]
  108. +
  109. + /* is bit N of bitstring name set? */
  110. +#define bit_test(name, bit) \
  111. + ((name)[_bit_byte(bit)] & _bit_mask(bit))
  112. +
  113. + /* set bit N of bitstring name */
  114. +#define bit_set(name, bit) \
  115. + (name)[_bit_byte(bit)] |= _bit_mask(bit)
  116. +
  117. + /* clear bit N of bitstring name */
  118. +#define bit_clear(name, bit) \
  119. + (name)[_bit_byte(bit)] &= ~_bit_mask(bit)
  120. +
  121. + /* clear bits start ... stop in bitstring */
  122. +#define bit_nclear(name, start, stop) { \
  123. + register bitstr_t *_name = name; \
  124. + register int _start = start, _stop = stop; \
  125. + register int _startbyte = _bit_byte(_start); \
  126. + register int _stopbyte = _bit_byte(_stop); \
  127. + if (_startbyte == _stopbyte) { \
  128. + _name[_startbyte] &= ((0xff >> (8 - (_start&0x7))) | \
  129. + (0xff << ((_stop&0x7) + 1))); \
  130. + } else { \
  131. + _name[_startbyte] &= 0xff >> (8 - (_start&0x7)); \
  132. + while (++_startbyte < _stopbyte) \
  133. + _name[_startbyte] = 0; \
  134. + _name[_stopbyte] &= 0xff << ((_stop&0x7) + 1); \
  135. + } \
  136. +}
  137. +
  138. + /* set bits start ... stop in bitstring */
  139. +#define bit_nset(name, start, stop) { \
  140. + register bitstr_t *_name = name; \
  141. + register int _start = start, _stop = stop; \
  142. + register int _startbyte = _bit_byte(_start); \
  143. + register int _stopbyte = _bit_byte(_stop); \
  144. + if (_startbyte == _stopbyte) { \
  145. + _name[_startbyte] |= ((0xff << (_start&0x7)) & \
  146. + (0xff >> (7 - (_stop&0x7)))); \
  147. + } else { \
  148. + _name[_startbyte] |= 0xff << ((_start)&0x7); \
  149. + while (++_startbyte < _stopbyte) \
  150. + _name[_startbyte] = 0xff; \
  151. + _name[_stopbyte] |= 0xff >> (7 - (_stop&0x7)); \
  152. + } \
  153. +}
  154. +
  155. + /* find first bit clear in name */
  156. +#define bit_ffc(name, nbits, value) { \
  157. + register bitstr_t *_name = name; \
  158. + register int _byte, _nbits = nbits; \
  159. + register int _stopbyte = _bit_byte(_nbits), _value = -1; \
  160. + for (_byte = 0; _byte <= _stopbyte; ++_byte) \
  161. + if (_name[_byte] != 0xff) { \
  162. + _value = _byte << 3; \
  163. + for (_stopbyte = _name[_byte]; (_stopbyte&0x1); \
  164. + ++_value, _stopbyte >>= 1); \
  165. + break; \
  166. + } \
  167. + *(value) = _value; \
  168. +}
  169. +
  170. + /* find first bit set in name */
  171. +#define bit_ffs(name, nbits, value) { \
  172. + register bitstr_t *_name = name; \
  173. + register int _byte, _nbits = nbits; \
  174. + register int _stopbyte = _bit_byte(_nbits), _value = -1; \
  175. + for (_byte = 0; _byte <= _stopbyte; ++_byte) \
  176. + if (_name[_byte]) { \
  177. + _value = _byte << 3; \
  178. + for (_stopbyte = _name[_byte]; !(_stopbyte&0x1); \
  179. + ++_value, _stopbyte >>= 1); \
  180. + break; \
  181. + } \
  182. + *(value) = _value; \
  183. +}
  184. +
  185. +#endif /* !_BITSTRING_H_ */
  186. diff --git a/include/hfs/hfs_format.h b/include/hfs/hfs_format.h
  187. new file mode 100644
  188. index 0000000..d820329
  189. --- /dev/null
  190. +++ b/include/hfs/hfs_format.h
  191. @@ -0,0 +1,689 @@
  192. +/*
  193. + * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
  194. + *
  195. + * @APPLE_LICENSE_HEADER_START@
  196. + *
  197. + * The contents of this file constitute Original Code as defined in and
  198. + * are subject to the Apple Public Source License Version 1.1 (the
  199. + * "License"). You may not use this file except in compliance with the
  200. + * License. Please obtain a copy of the License at
  201. + * http://www.apple.com/publicsource and read it before using this file.
  202. + *
  203. + * This Original Code and all software distributed under the License are
  204. + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  205. + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  206. + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  207. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
  208. + * License for the specific language governing rights and limitations
  209. + * under the License.
  210. + *
  211. + * @APPLE_LICENSE_HEADER_END@
  212. + */
  213. +#ifndef __HFS_FORMAT__
  214. +#define __HFS_FORMAT__
  215. +
  216. +#include "missing.h"
  217. +
  218. +#include <sys/appleapiopts.h>
  219. +
  220. +/*
  221. + * hfs_format.c
  222. + *
  223. + * This file describes the on-disk format for HFS and HFS Plus volumes.
  224. + * The HFS Plus volume format is desciibed in detail in Apple Technote 1150.
  225. + *
  226. + * http://developer.apple.com/technotes/tn/tn1150.html
  227. + *
  228. + */
  229. +
  230. +#ifdef __cplusplus
  231. +extern "C" {
  232. +#endif
  233. +
  234. +/* some on-disk hfs structures have 68K alignment (misaligned) */
  235. +
  236. +#define PACKED_S __attribute__((packed))
  237. +
  238. +/* Signatures used to differentiate between HFS and HFS Plus volumes */
  239. +enum {
  240. + kHFSSigWord = 0x4244, /* 'BD' in ASCII */
  241. + kHFSPlusSigWord = 0x482B, /* 'H+' in ASCII */
  242. + kHFSXSigWord = 0x4858, /* 'HX' in ASCII */
  243. +
  244. + kHFSPlusVersion = 0x0004, /* 'H+' volumes are version 4 only */
  245. + kHFSXVersion = 0x0005, /* 'HX' volumes start with version 5 */
  246. +
  247. + kHFSPlusMountVersion = 0x31302E30, /* '10.0' for Mac OS X */
  248. + kHFSJMountVersion = 0x4846534a, /* 'HFSJ' for journaled HFS+ on OS X */
  249. + kFSKMountVersion = 0x46534b21 /* 'FSK!' for failed journal replay */
  250. +}PACKED_S;
  251. +
  252. +
  253. +#if 1
  254. +/*
  255. + * Mac OS X has a special directory for linked and unlinked files (HFS Plus only).
  256. + * This directory and its contents are never exported from the filesystem under
  257. + * Mac OS X.
  258. + *
  259. + * To make this folder name sort last, it has embedded null prefix.
  260. + * (0xC0, 0x80 in UTF-8)
  261. + */
  262. +#define HFSPLUSMETADATAFOLDER "\xC0\x80\xC0\x80\xC0\x80\xC0\x80HFS+ Private Data"
  263. +
  264. +/*
  265. + * Files in the HFS Private Data folder have one of the following prefixes
  266. + * followed by a decimal number (no leading zeros). For indirect nodes this
  267. + * number is a 32 bit random number. For unlinked (deleted) files that are
  268. + * still open, the number is the file ID for that file.
  269. + *
  270. + * e.g. iNode7182000 and temp3296
  271. + */
  272. +#define HFS_INODE_PREFIX "iNode"
  273. +#define HFS_DELETE_PREFIX "temp"
  274. +
  275. +#endif /* __APPLE_API_PRIVATE */
  276. +
  277. +/*
  278. + * Indirect link files (hard links) have the following type/creator.
  279. + */
  280. +enum {
  281. + kHardLinkFileType = 0x686C6E6B, /* 'hlnk' */
  282. + kHFSPlusCreator = 0x6866732B /* 'hfs+' */
  283. +}PACKED_S;
  284. +
  285. +
  286. +#ifndef _HFSUNISTR255_DEFINED_
  287. +#define _HFSUNISTR255_DEFINED_
  288. +/* Unicode strings are used for HFS Plus file and folder names */
  289. +struct HFSUniStr255 {
  290. + u_int16_t length; /* number of unicode characters */
  291. + u_int16_t unicode[255]; /* unicode characters */
  292. +} PACKED_S;
  293. +typedef struct HFSUniStr255 HFSUniStr255;
  294. +typedef const HFSUniStr255 *ConstHFSUniStr255Param;
  295. +#endif /* _HFSUNISTR255_DEFINED_ */
  296. +
  297. +enum {
  298. + kHFSMaxVolumeNameChars = 27,
  299. + kHFSMaxFileNameChars = 31,
  300. + kHFSPlusMaxFileNameChars = 255
  301. +}PACKED_S;
  302. +
  303. +
  304. +/* Extent overflow file data structures */
  305. +
  306. +/* HFS Extent key */
  307. +struct HFSExtentKey {
  308. + u_int8_t keyLength; /* length of key, excluding this field */
  309. + u_int8_t forkType; /* 0 = data fork, FF = resource fork */
  310. + u_int32_t fileID; /* file ID */
  311. + u_int16_t startBlock; /* first file allocation block number in this extent */
  312. +}PACKED_S;
  313. +typedef struct HFSExtentKey HFSExtentKey;
  314. +
  315. +/* HFS Plus Extent key */
  316. +struct HFSPlusExtentKey {
  317. + u_int16_t keyLength; /* length of key, excluding this field */
  318. + u_int8_t forkType; /* 0 = data fork, FF = resource fork */
  319. + u_int8_t pad; /* make the other fields align on 32-bit boundary */
  320. + u_int32_t fileID; /* file ID */
  321. + u_int32_t startBlock; /* first file allocation block number in this extent */
  322. +}PACKED_S;
  323. +typedef struct HFSPlusExtentKey HFSPlusExtentKey;
  324. +
  325. +/* Number of extent descriptors per extent record */
  326. +enum {
  327. + kHFSExtentDensity = 3,
  328. + kHFSPlusExtentDensity = 8
  329. +}PACKED_S;
  330. +
  331. +/* HFS extent descriptor */
  332. +struct HFSExtentDescriptor {
  333. + u_int16_t startBlock; /* first allocation block */
  334. + u_int16_t blockCount; /* number of allocation blocks */
  335. +}PACKED_S;
  336. +typedef struct HFSExtentDescriptor HFSExtentDescriptor;
  337. +
  338. +/* HFS Plus extent descriptor */
  339. +struct HFSPlusExtentDescriptor {
  340. + u_int32_t startBlock; /* first allocation block */
  341. + u_int32_t blockCount; /* number of allocation blocks */
  342. +}PACKED_S;
  343. +typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor;
  344. +
  345. +/* HFS extent record */
  346. +typedef HFSExtentDescriptor HFSExtentRecord[3];
  347. +
  348. +/* HFS Plus extent record */
  349. +typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[8];
  350. +
  351. +
  352. +/* Finder information */
  353. +struct FndrFileInfo {
  354. + u_int32_t fdType; /* file type */
  355. + u_int32_t fdCreator; /* file creator */
  356. + u_int16_t fdFlags; /* Finder flags */
  357. + struct {
  358. + int16_t v; /* file's location */
  359. + int16_t h;
  360. + } PACKED_S fdLocation;
  361. + int16_t opaque;
  362. +}PACKED_S;
  363. +typedef struct FndrFileInfo FndrFileInfo;
  364. +
  365. +struct FndrDirInfo {
  366. + struct { /* folder's window rectangle */
  367. + int16_t top;
  368. + int16_t left;
  369. + int16_t bottom;
  370. + int16_t right;
  371. + }PACKED_S frRect;
  372. + unsigned short frFlags; /* Finder flags */
  373. + struct {
  374. + u_int16_t v; /* folder's location */
  375. + u_int16_t h;
  376. + }PACKED_S frLocation;
  377. + int16_t opaque;
  378. +}PACKED_S;
  379. +typedef struct FndrDirInfo FndrDirInfo;
  380. +
  381. +struct FndrOpaqueInfo {
  382. + int8_t opaque[16];
  383. +}PACKED_S;
  384. +typedef struct FndrOpaqueInfo FndrOpaqueInfo;
  385. +
  386. +
  387. +/* HFS Plus Fork data info - 80 bytes */
  388. +struct HFSPlusForkData {
  389. + u_int64_t logicalSize; /* fork's logical size in bytes */
  390. + u_int32_t clumpSize; /* fork's clump size in bytes */
  391. + u_int32_t totalBlocks; /* total blocks used by this fork */
  392. + HFSPlusExtentRecord extents; /* initial set of extents */
  393. +}PACKED_S;
  394. +typedef struct HFSPlusForkData HFSPlusForkData;
  395. +
  396. +
  397. +/* Mac OS X has 16 bytes worth of "BSD" info.
  398. + *
  399. + * Note: Mac OS 9 implementations and applications
  400. + * should preserve, but not change, this information.
  401. + */
  402. +struct HFSPlusBSDInfo {
  403. + u_int32_t ownerID; /* user or group ID of file/folder owner */
  404. + u_int32_t groupID; /* additional user of group ID */
  405. + u_int8_t adminFlags; /* super-user changeable flags */
  406. + u_int8_t ownerFlags; /* owner changeable flags */
  407. + u_int16_t fileMode; /* file type and permission bits */
  408. + union {
  409. + u_int32_t iNodeNum; /* indirect node number (hard links only) */
  410. + u_int32_t linkCount; /* links that refer to this indirect node */
  411. + u_int32_t rawDevice; /* special file device (FBLK and FCHR only) */
  412. + }PACKED_S special;
  413. +}PACKED_S;
  414. +typedef struct HFSPlusBSDInfo HFSPlusBSDInfo;
  415. +
  416. +
  417. +/* Catalog file data structures */
  418. +
  419. +enum {
  420. + kHFSRootParentID = 1, /* Parent ID of the root folder */
  421. + kHFSRootFolderID = 2, /* Folder ID of the root folder */
  422. + kHFSExtentsFileID = 3, /* File ID of the extents file */
  423. + kHFSCatalogFileID = 4, /* File ID of the catalog file */
  424. + kHFSBadBlockFileID = 5, /* File ID of the bad allocation block file */
  425. + kHFSAllocationFileID = 6, /* File ID of the allocation file (HFS Plus only) */
  426. + kHFSStartupFileID = 7, /* File ID of the startup file (HFS Plus only) */
  427. + kHFSAttributesFileID = 8, /* File ID of the attribute file (HFS Plus only) */
  428. + kHFSRepairCatalogFileID = 14, /* Used when rebuilding Catalog B-tree */
  429. + kHFSBogusExtentFileID = 15, /* Used for exchanging extents in extents file */
  430. + kHFSFirstUserCatalogNodeID = 16
  431. +}PACKED_S;
  432. +
  433. +/* HFS catalog key */
  434. +struct HFSCatalogKey {
  435. + u_int8_t keyLength; /* key length (in bytes) */
  436. + u_int8_t reserved; /* reserved (set to zero) */
  437. + u_int32_t parentID; /* parent folder ID */
  438. + u_int8_t nodeName[kHFSMaxFileNameChars + 1]; /* catalog node name */
  439. +}PACKED_S;
  440. +typedef struct HFSCatalogKey HFSCatalogKey;
  441. +
  442. +/* HFS Plus catalog key */
  443. +struct HFSPlusCatalogKey {
  444. + u_int16_t keyLength; /* key length (in bytes) */
  445. + u_int32_t parentID; /* parent folder ID */
  446. + HFSUniStr255 nodeName; /* catalog node name */
  447. +}PACKED_S;
  448. +typedef struct HFSPlusCatalogKey HFSPlusCatalogKey;
  449. +
  450. +/* Catalog record types */
  451. +enum {
  452. + /* HFS Catalog Records */
  453. + kHFSFolderRecord = 0x0100, /* Folder record */
  454. + kHFSFileRecord = 0x0200, /* File record */
  455. + kHFSFolderThreadRecord = 0x0300, /* Folder thread record */
  456. + kHFSFileThreadRecord = 0x0400, /* File thread record */
  457. +
  458. + /* HFS Plus Catalog Records */
  459. + kHFSPlusFolderRecord = 1, /* Folder record */
  460. + kHFSPlusFileRecord = 2, /* File record */
  461. + kHFSPlusFolderThreadRecord = 3, /* Folder thread record */
  462. + kHFSPlusFileThreadRecord = 4 /* File thread record */
  463. +}PACKED_S;
  464. +
  465. +
  466. +/* Catalog file record flags */
  467. +enum {
  468. + kHFSFileLockedBit = 0x0000, /* file is locked and cannot be written to */
  469. + kHFSFileLockedMask = 0x0001,
  470. +
  471. + kHFSThreadExistsBit = 0x0001, /* a file thread record exists for this file */
  472. + kHFSThreadExistsMask = 0x0002,
  473. +
  474. + kHFSHasAttributesBit = 0x0002, /* object has extended attributes */
  475. + kHFSHasAttributesMask = 0x0004,
  476. +
  477. + kHFSHasSecurityBit = 0x0003, /* object has security data (ACLs) */
  478. + kHFSHasSecurityMask = 0x0008
  479. +}PACKED_S;
  480. +
  481. +
  482. +/* HFS catalog folder record - 70 bytes */
  483. +struct HFSCatalogFolder {
  484. + int16_t recordType; /* == kHFSFolderRecord */
  485. + u_int16_t flags; /* folder flags */
  486. + u_int16_t valence; /* folder valence */
  487. + u_int32_t folderID; /* folder ID */
  488. + u_int32_t createDate; /* date and time of creation */
  489. + u_int32_t modifyDate; /* date and time of last modification */
  490. + u_int32_t backupDate; /* date and time of last backup */
  491. + FndrDirInfo userInfo; /* Finder information */
  492. + FndrOpaqueInfo finderInfo; /* additional Finder information */
  493. + u_int32_t reserved[4]; /* reserved - initialized as zero */
  494. +}PACKED_S;
  495. +typedef struct HFSCatalogFolder HFSCatalogFolder;
  496. +
  497. +/* HFS Plus catalog folder record - 88 bytes */
  498. +struct HFSPlusCatalogFolder {
  499. + int16_t recordType; /* == kHFSPlusFolderRecord */
  500. + u_int16_t flags; /* file flags */
  501. + u_int32_t valence; /* folder's valence (limited to 2^16 in Mac OS) */
  502. + u_int32_t folderID; /* folder ID */
  503. + u_int32_t createDate; /* date and time of creation */
  504. + u_int32_t contentModDate; /* date and time of last content modification */
  505. + u_int32_t attributeModDate; /* date and time of last attribute modification */
  506. + u_int32_t accessDate; /* date and time of last access (MacOS X only) */
  507. + u_int32_t backupDate; /* date and time of last backup */
  508. + HFSPlusBSDInfo bsdInfo; /* permissions (for MacOS X) */
  509. + FndrDirInfo userInfo; /* Finder information */
  510. + FndrOpaqueInfo finderInfo; /* additional Finder information */
  511. + u_int32_t textEncoding; /* hint for name conversions */
  512. + u_int32_t attrBlocks; /* cached count of attribute data blocks */
  513. +}PACKED_S;
  514. +typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder;
  515. +
  516. +/* HFS catalog file record - 102 bytes */
  517. +struct HFSCatalogFile {
  518. + int16_t recordType; /* == kHFSFileRecord */
  519. + u_int8_t flags; /* file flags */
  520. + int8_t fileType; /* file type (unused ?) */
  521. + FndrFileInfo userInfo; /* Finder information */
  522. + u_int32_t fileID; /* file ID */
  523. + u_int16_t dataStartBlock; /* not used - set to zero */
  524. + int32_t dataLogicalSize; /* logical EOF of data fork */
  525. + int32_t dataPhysicalSize; /* physical EOF of data fork */
  526. + u_int16_t rsrcStartBlock; /* not used - set to zero */
  527. + int32_t rsrcLogicalSize; /* logical EOF of resource fork */
  528. + int32_t rsrcPhysicalSize; /* physical EOF of resource fork */
  529. + u_int32_t createDate; /* date and time of creation */
  530. + u_int32_t modifyDate; /* date and time of last modification */
  531. + u_int32_t backupDate; /* date and time of last backup */
  532. + FndrOpaqueInfo finderInfo; /* additional Finder information */
  533. + u_int16_t clumpSize; /* file clump size (not used) */
  534. + HFSExtentRecord dataExtents; /* first data fork extent record */
  535. + HFSExtentRecord rsrcExtents; /* first resource fork extent record */
  536. + u_int32_t reserved; /* reserved - initialized as zero */
  537. +}PACKED_S;
  538. +typedef struct HFSCatalogFile HFSCatalogFile;
  539. +
  540. +/* HFS Plus catalog file record - 248 bytes */
  541. +struct HFSPlusCatalogFile {
  542. + int16_t recordType; /* == kHFSPlusFileRecord */
  543. + u_int16_t flags; /* file flags */
  544. + u_int32_t reserved1; /* reserved - initialized as zero */
  545. + u_int32_t fileID; /* file ID */
  546. + u_int32_t createDate; /* date and time of creation */
  547. + u_int32_t contentModDate; /* date and time of last content modification */
  548. + u_int32_t attributeModDate; /* date and time of last attribute modification */
  549. + u_int32_t accessDate; /* date and time of last access (MacOS X only) */
  550. + u_int32_t backupDate; /* date and time of last backup */
  551. + HFSPlusBSDInfo bsdInfo; /* permissions (for MacOS X) */
  552. + FndrFileInfo userInfo; /* Finder information */
  553. + FndrOpaqueInfo finderInfo; /* additional Finder information */
  554. + u_int32_t textEncoding; /* hint for name conversions */
  555. + u_int32_t attrBlocks; /* cached count of attribute data blocks */
  556. +
  557. + /* Note: these start on double long (64 bit) boundary */
  558. + HFSPlusForkData dataFork; /* size and block data for data fork */
  559. + HFSPlusForkData resourceFork; /* size and block data for resource fork */
  560. +}PACKED_S;
  561. +typedef struct HFSPlusCatalogFile HFSPlusCatalogFile;
  562. +
  563. +/* HFS catalog thread record - 46 bytes */
  564. +struct HFSCatalogThread {
  565. + int16_t recordType; /* == kHFSFolderThreadRecord or kHFSFileThreadRecord */
  566. + int32_t reserved[2]; /* reserved - initialized as zero */
  567. + u_int32_t parentID; /* parent ID for this catalog node */
  568. + u_int8_t nodeName[kHFSMaxFileNameChars + 1]; /* name of this catalog node */
  569. +}PACKED_S;
  570. +typedef struct HFSCatalogThread HFSCatalogThread;
  571. +
  572. +/* HFS Plus catalog thread record -- 264 bytes */
  573. +struct HFSPlusCatalogThread {
  574. + int16_t recordType; /* == kHFSPlusFolderThreadRecord or kHFSPlusFileThreadRecord */
  575. + int16_t reserved; /* reserved - initialized as zero */
  576. + u_int32_t parentID; /* parent ID for this catalog node */
  577. + HFSUniStr255 nodeName; /* name of this catalog node (variable length) */
  578. +}PACKED_S;
  579. +typedef struct HFSPlusCatalogThread HFSPlusCatalogThread;
  580. +
  581. +#ifdef __APPLE_API_UNSTABLE
  582. +/*
  583. + These are the types of records in the attribute B-tree. The values were
  584. + chosen so that they wouldn't conflict with the catalog record types.
  585. +*/
  586. +enum {
  587. + kHFSPlusAttrInlineData = 0x10, /* if size < kAttrOverflowSize */
  588. + kHFSPlusAttrForkData = 0x20, /* if size >= kAttrOverflowSize */
  589. + kHFSPlusAttrExtents = 0x30 /* overflow extents for large attributes */
  590. +}PACKED_S;
  591. +
  592. +
  593. +/*
  594. + HFSPlusAttrForkData
  595. + For larger attributes, whose value is stored in allocation blocks.
  596. + If the attribute has more than 8 extents, there will be additional
  597. + records (of type HFSPlusAttrExtents) for this attribute.
  598. +*/
  599. +struct HFSPlusAttrForkData {
  600. + u_int32_t recordType; /* == kHFSPlusAttrForkData*/
  601. + u_int32_t reserved;
  602. + HFSPlusForkData theFork; /* size and first extents of value*/
  603. +}PACKED_S;
  604. +typedef struct HFSPlusAttrForkData HFSPlusAttrForkData;
  605. +
  606. +/*
  607. + HFSPlusAttrExtents
  608. + This record contains information about overflow extents for large,
  609. + fragmented attributes.
  610. +*/
  611. +struct HFSPlusAttrExtents {
  612. + u_int32_t recordType; /* == kHFSPlusAttrExtents*/
  613. + u_int32_t reserved;
  614. + HFSPlusExtentRecord extents; /* additional extents*/
  615. +}PACKED_S;
  616. +typedef struct HFSPlusAttrExtents HFSPlusAttrExtents;
  617. +
  618. +/*
  619. + * Atrributes B-tree Data Record
  620. + *
  621. + * For small attributes, whose entire value is stored
  622. + * within a single B-tree record.
  623. + */
  624. +struct HFSPlusAttrData {
  625. + u_int32_t recordType; /* == kHFSPlusAttrInlineData */
  626. + u_int32_t reserved[2];
  627. + u_int32_t attrSize; /* size of attribute data in bytes */
  628. + u_int8_t attrData[2]; /* variable length */
  629. +}PACKED_S;
  630. +typedef struct HFSPlusAttrData HFSPlusAttrData;
  631. +
  632. +
  633. +/* HFSPlusAttrInlineData is obsolete use HFSPlusAttrData instead */
  634. +struct HFSPlusAttrInlineData {
  635. + u_int32_t recordType;
  636. + u_int32_t reserved;
  637. + u_int32_t logicalSize;
  638. + u_int8_t userData[2];
  639. +}PACKED_S;
  640. +typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData;
  641. +
  642. +
  643. +/* A generic Attribute Record*/
  644. +union HFSPlusAttrRecord {
  645. + u_int32_t recordType;
  646. + HFSPlusAttrInlineData inlineData; /* NOT USED */
  647. + HFSPlusAttrData attrData;
  648. + HFSPlusAttrForkData forkData;
  649. + HFSPlusAttrExtents overflowExtents;
  650. +}PACKED_S;
  651. +typedef union HFSPlusAttrRecord HFSPlusAttrRecord;
  652. +
  653. +/* Attribute key */
  654. +enum { kHFSMaxAttrNameLen = 127 };
  655. +struct HFSPlusAttrKey {
  656. + u_int16_t keyLength; /* key length (in bytes) */
  657. + u_int16_t pad; /* set to zero */
  658. + u_int32_t fileID; /* file associated with attribute */
  659. + u_int32_t startBlock; /* first attribue allocation block number for extents */
  660. + u_int16_t attrNameLen; /* number of unicode characters */
  661. + u_int16_t attrName[127]; /* attribute name (Unicode) */
  662. +}PACKED_S;
  663. +typedef struct HFSPlusAttrKey HFSPlusAttrKey;
  664. +
  665. +#define kHFSPlusAttrKeyMaximumLength (sizeof(HFSPlusAttrKey) - sizeof(u_int16_t))
  666. +#define kHFSPlusAttrKeyMinimumLength (kHFSPlusAttrKeyMaximumLength - (127 * sizeof(u_int16_t)))
  667. +
  668. +#endif /* __APPLE_API_UNSTABLE */
  669. +
  670. +
  671. +/* Key and node lengths */
  672. +enum {
  673. + kHFSPlusExtentKeyMaximumLength = sizeof(HFSPlusExtentKey) - sizeof(u_int16_t),
  674. + kHFSExtentKeyMaximumLength = sizeof(HFSExtentKey) - sizeof(u_int8_t),
  675. + kHFSPlusCatalogKeyMaximumLength = sizeof(HFSPlusCatalogKey) - sizeof(u_int16_t),
  676. + kHFSPlusCatalogKeyMinimumLength = kHFSPlusCatalogKeyMaximumLength - sizeof(HFSUniStr255) + sizeof(u_int16_t),
  677. + kHFSCatalogKeyMaximumLength = sizeof(HFSCatalogKey) - sizeof(u_int8_t),
  678. + kHFSCatalogKeyMinimumLength = kHFSCatalogKeyMaximumLength - (kHFSMaxFileNameChars + 1) + sizeof(u_int8_t),
  679. + kHFSPlusCatalogMinNodeSize = 4096,
  680. + kHFSPlusExtentMinNodeSize = 512,
  681. + kHFSPlusAttrMinNodeSize = 4096
  682. +}PACKED_S;
  683. +
  684. +/* HFS and HFS Plus volume attribute bits */
  685. +enum {
  686. + /* Bits 0-6 are reserved (always cleared by MountVol call) */
  687. + kHFSVolumeHardwareLockBit = 7, /* volume is locked by hardware */
  688. + kHFSVolumeUnmountedBit = 8, /* volume was successfully unmounted */
  689. + kHFSVolumeSparedBlocksBit = 9, /* volume has bad blocks spared */
  690. + kHFSVolumeNoCacheRequiredBit = 10, /* don't cache volume blocks (i.e. RAM or ROM disk) */
  691. + kHFSBootVolumeInconsistentBit = 11, /* boot volume is inconsistent (System 7.6 and later) */
  692. + kHFSCatalogNodeIDsReusedBit = 12,
  693. + kHFSVolumeJournaledBit = 13, /* this volume has a journal on it */
  694. + kHFSVolumeInconsistentBit = 14, /* serious inconsistencies detected at runtime */
  695. + kHFSVolumeSoftwareLockBit = 15, /* volume is locked by software */
  696. +
  697. + kHFSVolumeHardwareLockMask = 1 << kHFSVolumeHardwareLockBit,
  698. + kHFSVolumeUnmountedMask = 1 << kHFSVolumeUnmountedBit,
  699. + kHFSVolumeSparedBlocksMask = 1 << kHFSVolumeSparedBlocksBit,
  700. + kHFSVolumeNoCacheRequiredMask = 1 << kHFSVolumeNoCacheRequiredBit,
  701. + kHFSBootVolumeInconsistentMask = 1 << kHFSBootVolumeInconsistentBit,
  702. + kHFSCatalogNodeIDsReusedMask = 1 << kHFSCatalogNodeIDsReusedBit,
  703. + kHFSVolumeJournaledMask = 1 << kHFSVolumeJournaledBit,
  704. + kHFSVolumeInconsistentMask = 1 << kHFSVolumeInconsistentBit,
  705. + kHFSVolumeSoftwareLockMask = 1 << kHFSVolumeSoftwareLockBit,
  706. + kHFSMDBAttributesMask = 0x8380
  707. +}PACKED_S;
  708. +
  709. +
  710. +/* HFS Master Directory Block - 162 bytes */
  711. +/* Stored at sector #2 (3rd sector) and second-to-last sector. */
  712. +struct HFSMasterDirectoryBlock {
  713. + u_int16_t drSigWord; /* == kHFSSigWord */
  714. + u_int32_t drCrDate; /* date and time of volume creation */
  715. + u_int32_t drLsMod; /* date and time of last modification */
  716. + u_int16_t drAtrb; /* volume attributes */
  717. + u_int16_t drNmFls; /* number of files in root folder */
  718. + u_int16_t drVBMSt; /* first block of volume bitmap */
  719. + u_int16_t drAllocPtr; /* start of next allocation search */
  720. + u_int16_t drNmAlBlks; /* number of allocation blocks in volume */
  721. + u_int32_t drAlBlkSiz; /* size (in bytes) of allocation blocks */
  722. + u_int32_t drClpSiz; /* default clump size */
  723. + u_int16_t drAlBlSt; /* first allocation block in volume */
  724. + u_int32_t drNxtCNID; /* next unused catalog node ID */
  725. + u_int16_t drFreeBks; /* number of unused allocation blocks */
  726. + u_int8_t drVN[kHFSMaxVolumeNameChars + 1]; /* volume name */
  727. + u_int32_t drVolBkUp; /* date and time of last backup */
  728. + u_int16_t drVSeqNum; /* volume backup sequence number */
  729. + u_int32_t drWrCnt; /* volume write count */
  730. + u_int32_t drXTClpSiz; /* clump size for extents overflow file */
  731. + u_int32_t drCTClpSiz; /* clump size for catalog file */
  732. + u_int16_t drNmRtDirs; /* number of directories in root folder */
  733. + u_int32_t drFilCnt; /* number of files in volume */
  734. + u_int32_t drDirCnt; /* number of directories in volume */
  735. + u_int32_t drFndrInfo[8]; /* information used by the Finder */
  736. + u_int16_t drEmbedSigWord; /* embedded volume signature (formerly drVCSize) */
  737. + HFSExtentDescriptor drEmbedExtent; /* embedded volume location and size (formerly drVBMCSize and drCtlCSize) */
  738. + u_int32_t drXTFlSize; /* size of extents overflow file */
  739. + HFSExtentRecord drXTExtRec; /* extent record for extents overflow file */
  740. + u_int32_t drCTFlSize; /* size of catalog file */
  741. + HFSExtentRecord drCTExtRec; /* extent record for catalog file */
  742. +}PACKED_S;
  743. +typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock;
  744. +
  745. +
  746. +#ifdef __APPLE_API_UNSTABLE
  747. +#define SET_HFS_TEXT_ENCODING(hint) \
  748. + (0x656e6300 | ((hint) & 0xff))
  749. +#define GET_HFS_TEXT_ENCODING(hint) \
  750. + (((hint) & 0xffffff00) == 0x656e6300 ? (hint) & 0x000000ff : 0xffffffffU)
  751. +#endif /* __APPLE_API_UNSTABLE */
  752. +
  753. +
  754. +/* HFS Plus Volume Header - 512 bytes */
  755. +/* Stored at sector #2 (3rd sector) and second-to-last sector. */
  756. +struct HFSPlusVolumeHeader {
  757. + u_int16_t signature; /* == kHFSPlusSigWord */
  758. + u_int16_t version; /* == kHFSPlusVersion */
  759. + u_int32_t attributes; /* volume attributes */
  760. + u_int32_t lastMountedVersion; /* implementation version which last mounted volume */
  761. + u_int32_t journalInfoBlock; /* block addr of journal info (if volume is journaled, zero otherwise) */
  762. +
  763. + u_int32_t createDate; /* date and time of volume creation */
  764. + u_int32_t modifyDate; /* date and time of last modification */
  765. + u_int32_t backupDate; /* date and time of last backup */
  766. + u_int32_t checkedDate; /* date and time of last disk check */
  767. +
  768. + u_int32_t fileCount; /* number of files in volume */
  769. + u_int32_t folderCount; /* number of directories in volume */
  770. +
  771. + u_int32_t blockSize; /* size (in bytes) of allocation blocks */
  772. + u_int32_t totalBlocks; /* number of allocation blocks in volume (includes this header and VBM*/
  773. + u_int32_t freeBlocks; /* number of unused allocation blocks */
  774. +
  775. + u_int32_t nextAllocation; /* start of next allocation search */
  776. + u_int32_t rsrcClumpSize; /* default resource fork clump size */
  777. + u_int32_t dataClumpSize; /* default data fork clump size */
  778. + u_int32_t nextCatalogID; /* next unused catalog node ID */
  779. +
  780. + u_int32_t writeCount; /* volume write count */
  781. + u_int64_t encodingsBitmap; /* which encodings have been use on this volume */
  782. +
  783. + u_int8_t finderInfo[32]; /* information used by the Finder */
  784. +
  785. + HFSPlusForkData allocationFile; /* allocation bitmap file */
  786. + HFSPlusForkData extentsFile; /* extents B-tree file */
  787. + HFSPlusForkData catalogFile; /* catalog B-tree file */
  788. + HFSPlusForkData attributesFile; /* extended attributes B-tree file */
  789. + HFSPlusForkData startupFile; /* boot file (secondary loader) */
  790. +}PACKED_S;
  791. +typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader;
  792. +
  793. +
  794. +/* B-tree structures */
  795. +
  796. +enum BTreeKeyLimits{
  797. + kMaxKeyLength = 520
  798. +}PACKED_S;
  799. +
  800. +union BTreeKey{
  801. + u_int8_t length8;
  802. + u_int16_t length16;
  803. + u_int8_t rawData [kMaxKeyLength+2];
  804. +}PACKED_S;
  805. +typedef union BTreeKey BTreeKey;
  806. +
  807. +/* BTNodeDescriptor -- Every B-tree node starts with these fields. */
  808. +struct BTNodeDescriptor {
  809. + u_int32_t fLink; /* next node at this level*/
  810. + u_int32_t bLink; /* previous node at this level*/
  811. + int8_t kind; /* kind of node (leaf, index, header, map)*/
  812. + u_int8_t height; /* zero for header, map; child is one more than parent*/
  813. + u_int16_t numRecords; /* number of records in this node*/
  814. + u_int16_t reserved; /* reserved - initialized as zero */
  815. +}PACKED_S;
  816. +typedef struct BTNodeDescriptor BTNodeDescriptor;
  817. +
  818. +/* Constants for BTNodeDescriptor kind */
  819. +enum {
  820. + kBTLeafNode = -1,
  821. + kBTIndexNode = 0,
  822. + kBTHeaderNode = 1,
  823. + kBTMapNode = 2
  824. +}PACKED_S;
  825. +
  826. +/* BTHeaderRec -- The first record of a B-tree header node */
  827. +struct BTHeaderRec {
  828. + u_int16_t treeDepth; /* maximum height (usually leaf nodes) */
  829. + u_int32_t rootNode; /* node number of root node */
  830. + u_int32_t leafRecords; /* number of leaf records in all leaf nodes */
  831. + u_int32_t firstLeafNode; /* node number of first leaf node */
  832. + u_int32_t lastLeafNode; /* node number of last leaf node */
  833. + u_int16_t nodeSize; /* size of a node, in bytes */
  834. + u_int16_t maxKeyLength; /* reserved */
  835. + u_int32_t totalNodes; /* total number of nodes in tree */
  836. + u_int32_t freeNodes; /* number of unused (free) nodes in tree */
  837. + u_int16_t reserved1; /* unused */
  838. + u_int32_t clumpSize; /* reserved */
  839. + u_int8_t btreeType; /* reserved */
  840. + u_int8_t keyCompareType; /* Key string Comparison Type */
  841. + u_int32_t attributes; /* persistent attributes about the tree */
  842. + u_int32_t reserved3[16]; /* reserved */
  843. +}PACKED_S;
  844. +typedef struct BTHeaderRec BTHeaderRec;
  845. +
  846. +/* Constants for BTHeaderRec attributes */
  847. +enum {
  848. + kBTBadCloseMask = 0x00000001, /* reserved */
  849. + kBTBigKeysMask = 0x00000002, /* key length field is 16 bits */
  850. + kBTVariableIndexKeysMask = 0x00000004 /* keys in index nodes are variable length */
  851. +}PACKED_S;
  852. +
  853. +
  854. +/* Catalog Key Name Comparison Type */
  855. +enum {
  856. + kHFSCaseFolding = 0xCF, /* case folding (case-insensitive) */
  857. + kHFSBinaryCompare = 0xBC /* binary compare (case-sensitive) */
  858. +}PACKED_S;
  859. +
  860. +/* JournalInfoBlock - Structure that describes where our journal lives */
  861. +struct JournalInfoBlock {
  862. + u_int32_t flags;
  863. + u_int32_t device_signature[8]; // signature used to locate our device.
  864. + u_int64_t offset; // byte offset to the journal on the device
  865. + u_int64_t size; // size in bytes of the journal
  866. + u_int32_t reserved[32];
  867. +}PACKED_S;
  868. +typedef struct JournalInfoBlock JournalInfoBlock;
  869. +
  870. +enum {
  871. + kJIJournalInFSMask = 0x00000001,
  872. + kJIJournalOnOtherDeviceMask = 0x00000002,
  873. + kJIJournalNeedInitMask = 0x00000004
  874. +}PACKED_S;
  875. +
  876. +#ifdef __cplusplus
  877. +}
  878. +#endif
  879. +
  880. +#endif /* __HFS_FORMAT__ */
  881. diff --git a/include/hfs/hfs_mount.h b/include/hfs/hfs_mount.h
  882. new file mode 100644
  883. index 0000000..ad729f2
  884. --- /dev/null
  885. +++ b/include/hfs/hfs_mount.h
  886. @@ -0,0 +1,78 @@
  887. +/*
  888. + * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
  889. + *
  890. + * @APPLE_LICENSE_HEADER_START@
  891. + *
  892. + * The contents of this file constitute Original Code as defined in and
  893. + * are subject to the Apple Public Source License Version 1.1 (the
  894. + * "License"). You may not use this file except in compliance with the
  895. + * License. Please obtain a copy of the License at
  896. + * http://www.apple.com/publicsource and read it before using this file.
  897. + *
  898. + * This Original Code and all software distributed under the License are
  899. + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  900. + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  901. + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  902. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
  903. + * License for the specific language governing rights and limitations
  904. + * under the License.
  905. + *
  906. + * @APPLE_LICENSE_HEADER_END@
  907. + */
  908. +/*
  909. + * Copyright (c) 1997-2002 Apple Computer, Inc. All Rights Reserved
  910. + *
  911. + */
  912. +
  913. +#ifndef _HFS_MOUNT_H_
  914. +#define _HFS_MOUNT_H_
  915. +
  916. +#include <sys/appleapiopts.h>
  917. +
  918. +#include <sys/mount.h>
  919. +#include <sys/time.h>
  920. +
  921. +/*
  922. + * Arguments to mount HFS-based filesystems
  923. + */
  924. +
  925. +#define OVERRIDE_UNKNOWN_PERMISSIONS 0
  926. +
  927. +#define UNKNOWNUID ((uid_t)99)
  928. +#define UNKNOWNGID ((gid_t)99)
  929. +#define UNKNOWNPERMISSIONS (S_IRWXU | S_IROTH | S_IXOTH) /* 705 */
  930. +
  931. +#ifdef __APPLE_API_UNSTABLE
  932. +struct hfs_mount_args {
  933. +#ifndef KERNEL
  934. + char *fspec; /* block special device to mount */
  935. +#endif
  936. + uid_t hfs_uid; /* uid that owns hfs files (standard HFS only) */
  937. + gid_t hfs_gid; /* gid that owns hfs files (standard HFS only) */
  938. + mode_t hfs_mask; /* mask to be applied for hfs perms (standard HFS only) */
  939. + u_int32_t hfs_encoding; /* encoding for this volume (standard HFS only) */
  940. + struct timezone hfs_timezone; /* user time zone info (standard HFS only) */
  941. + int flags; /* mounting flags, see below */
  942. + int journal_tbuffer_size; /* size in bytes of the journal transaction buffer */
  943. + int journal_flags; /* flags to pass to journal_open/create */
  944. + int journal_disable; /* don't use journaling (potentially dangerous) */
  945. +};
  946. +
  947. +#define HFSFSMNT_NOXONFILES 0x1 /* disable execute permissions for files */
  948. +#define HFSFSMNT_WRAPPER 0x2 /* mount HFS wrapper (if it exists) */
  949. +#define HFSFSMNT_EXTENDED_ARGS 0x4 /* indicates new fields after "flags" are valid */
  950. +
  951. +/*
  952. + * Sysctl values for HFS
  953. + */
  954. +#define HFS_ENCODINGBIAS 1 /* encoding matching CJK bias */
  955. +#define HFS_EXTEND_FS 2
  956. +#define HFS_ENCODINGHINT 3 /* guess encoding for string */
  957. +#define HFS_ENABLE_JOURNALING 0x082969
  958. +#define HFS_DISABLE_JOURNALING 0x031272
  959. +#define HFS_GET_JOURNAL_INFO 0x6a6e6c69
  960. +#define HFS_SET_PKG_EXTENSIONS 0x121031
  961. +
  962. +#endif /* __APPLE_API_UNSTABLE */
  963. +
  964. +#endif /* ! _HFS_MOUNT_H_ */
  965. diff --git a/include/sys/appleapiopts.h b/include/sys/appleapiopts.h
  966. new file mode 100644
  967. index 0000000..4d2061f
  968. --- /dev/null
  969. +++ b/include/sys/appleapiopts.h
  970. @@ -0,0 +1,52 @@
  971. +/*
  972. + * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
  973. + *
  974. + * @APPLE_LICENSE_HEADER_START@
  975. + *
  976. + * The contents of this file constitute Original Code as defined in and
  977. + * are subject to the Apple Public Source License Version 1.1 (the
  978. + * "License"). You may not use this file except in compliance with the
  979. + * License. Please obtain a copy of the License at
  980. + * http://www.apple.com/publicsource and read it before using this file.
  981. + *
  982. + * This Original Code and all software distributed under the License are
  983. + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  984. + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  985. + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  986. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
  987. + * License for the specific language governing rights and limitations
  988. + * under the License.
  989. + *
  990. + * @APPLE_LICENSE_HEADER_END@
  991. + */
  992. +
  993. +#ifndef __SYS_APPLEAPIOPTS_H__
  994. +#define __SYS_APPLEAPIOPTS_H__
  995. +
  996. +
  997. +#ifndef __APPLE_API_STANDARD
  998. +#define __APPLE_API_STANDARD
  999. +#endif /* __APPLE_API_STANDARD */
  1000. +
  1001. +#ifndef __APPLE_API_STABLE
  1002. +#define __APPLE_API_STABLE
  1003. +#endif /* __APPLE_API_STABLE */
  1004. +
  1005. +#ifndef __APPLE_API_STRICT_CONFORMANCE
  1006. +
  1007. +#ifndef __APPLE_API_EVOLVING
  1008. +#define __APPLE_API_EVOLVING
  1009. +#endif /* __APPLE_API_EVOLVING */
  1010. +
  1011. +#ifndef __APPLE_API_UNSTABLE
  1012. +#define __APPLE_API_UNSTABLE
  1013. +#endif /* __APPLE_API_UNSTABLE */
  1014. +
  1015. +#ifndef __APPLE_API_OBSOLETE
  1016. +#define __APPLE_API_OBSOLETE
  1017. +#endif /* __APPLE_API_OBSOLETE */
  1018. +
  1019. +#endif /* __APPLE_API_STRICT_CONFORMANCE */
  1020. +
  1021. +#endif /* __SYS_APPLEAPIOPTS_H__ */
  1022. +