PageRenderTime 45ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/darwin/diskdev_cmds/newfs_hfs/newfs_hfs.h

https://gitlab.com/stallmanifold/hfs-freebsd
C Header | 237 lines | 148 code | 43 blank | 46 comment | 1 complexity | eceec1a6fa6eb6651f1cbcd85e44aa0c MD5 | raw file
  1. /*
  2. * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved.
  3. *
  4. * @APPLE_LICENSE_HEADER_START@
  5. *
  6. * "Portions Copyright (c) 1999-2002 Apple Computer, Inc. All Rights
  7. * Reserved. This file contains Original Code and/or Modifications of
  8. * Original Code as defined in and that are subject to the Apple Public
  9. * Source License Version 1.0 (the 'License'). You may not use this file
  10. * except in compliance with the License. Please obtain a copy of the
  11. * License at http://www.apple.com/publicsource and read it before using
  12. * this file.
  13. *
  14. * The Original Code and all software distributed under the License are
  15. * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  16. * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  17. * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
  19. * License for the specific language governing rights and limitations
  20. * under the License."
  21. *
  22. * @APPLE_LICENSE_HEADER_END@
  23. */
  24. #ifndef __FreeBSD__
  25. #include <CoreFoundation/CFBase.h>
  26. #endif
  27. #ifndef __SRUNTIME__ /* SRuntime.h defines a superset of these flags */
  28. /*
  29. * Mac OS Finder flags
  30. */
  31. enum {
  32. kHasBeenInited = 0x0100, /* Files only */ /* Clear if the file contains desktop database */ /* bit 0x0200 was the letter bit for AOCE, but is now reserved for future use */
  33. kHasCustomIcon = 0x0400, /* Files and folders */
  34. kIsStationery = 0x0800, /* Files only */
  35. kNameLocked = 0x1000, /* Files and folders */
  36. kHasBundle = 0x2000, /* Files only */
  37. kIsInvisible = 0x4000, /* Files and folders */
  38. kIsAlias = 0x8000 /* Files only */
  39. };
  40. #endif
  41. /* Finder types (mostly opaque in our usage) */
  42. struct FInfo {
  43. UInt32 fileType; /* The type of the file */
  44. UInt32 fileCreator; /* The file's creator */
  45. UInt16 finderFlags; /* ex: kHasBundle, kIsInvisible... */
  46. UInt8 opaque[6]; /* If set to {0, 0}, the Finder will place the item automatically */
  47. };
  48. typedef struct FInfo FInfo;
  49. struct FXInfo {
  50. UInt8 opaque[16];
  51. };
  52. typedef struct FXInfo FXInfo;
  53. struct DInfo {
  54. UInt8 opaque[16];
  55. };
  56. typedef struct DInfo DInfo;
  57. struct DXInfo {
  58. UInt8 opaque[16];
  59. };
  60. typedef struct DXInfo DXInfo;
  61. enum {
  62. kMinHFSPlusVolumeSize = (4*1024*1024),
  63. kBytesPerSector = 512,
  64. kBitsPerSector = 4096,
  65. kBTreeHeaderUserBytes = 128,
  66. kLog2SectorSize = 9,
  67. kHFSNodeSize = 512,
  68. kHFSMaxAllocationBlks = 65536,
  69. kHFSPlusDataClumpFactor = 16,
  70. kHFSPlusRsrcClumpFactor = 16,
  71. kWriteSeqNum = 2,
  72. kHeaderBlocks = 3,
  73. kTailBlocks = 2,
  74. kMDBStart = 2,
  75. kVolBitMapStart = kHeaderBlocks,
  76. /* Desktop DB, Desktop DF, Finder, System, ReadMe */
  77. kWapperFileCount = 5,
  78. /* Maximum wrapper size is 32MB */
  79. kMaxWrapperSize = 1024 * 1024 * 32,
  80. /* Maximum volume that can be wrapped is 256GB */
  81. kMaxWrapableSectors = (kMaxWrapperSize/8) * (65536/512)
  82. };
  83. /* B-tree key descriptor */
  84. #define KD_SKIP 0
  85. #define KD_BYTE 1
  86. #define KD_SIGNBYTE 2
  87. #define KD_STRING 3
  88. #define KD_WORD 4
  89. #define KD_SIGNWORD 5
  90. #define KD_LONG 6
  91. #define KD_SIGNLONG 7
  92. #define KD_FIXLENSTR 8
  93. #define KD_DTDBSTR 9
  94. #define KD_USEPROC 10
  95. enum {
  96. kTextEncodingMacRoman = 0L,
  97. kTextEncodingMacJapanese = 1
  98. };
  99. /*
  100. * The following constant sets the default block size.
  101. * This constant must be a power of 2 and meet the following constraints:
  102. * MINBSIZE <= DFL_BLKSIZE <= MAXBSIZE
  103. * sectorsize <= DFL_BLKSIZE
  104. */
  105. #define HFSOPTIMALBLKSIZE 4096
  106. #define HFSMINBSIZE 512
  107. #define DFL_BLKSIZE HFSOPTIMALBLKSIZE
  108. #define kDTDF_FileID 16
  109. #define kDTDF_Name "Desktop DF"
  110. #define kDTDF_Chars 10
  111. #define kDTDF_Type 'DTFL'
  112. #define kDTDF_Creator 'DMGR'
  113. #define kDTDB_FileID 17
  114. #define kDTDB_Name "Desktop DB"
  115. #define kDTDB_Chars 10
  116. #define kDTDB_Type 'BTFL'
  117. #define kDTDB_Creator 'DMGR'
  118. #define kDTDB_Size 1024
  119. #define kReadMe_FileID 18
  120. #define kReadMe_Name "ReadMe"
  121. #define kReadMe_Chars 6
  122. #define kReadMe_Type 'ttro'
  123. #define kReadMe_Creator 'ttxt'
  124. #define kFinder_FileID 19
  125. #define kFinder_Name "Finder"
  126. #define kFinder_Chars 6
  127. #define kFinder_Type 'FNDR'
  128. #define kFinder_Creator 'MACS'
  129. #define kSystem_FileID 20
  130. #define kSystem_Name "System"
  131. #define kSystem_Chars 6
  132. #define kSystem_Type 'zsys'
  133. #define kSystem_Creator 'MACS'
  134. /*
  135. * The minimum HFS Plus volume is 32 MB
  136. */
  137. #define MINHFSPLUSSIZEMB 4
  138. #if !defined(FALSE) && !defined(TRUE)
  139. enum {
  140. FALSE = 0,
  141. TRUE = 1
  142. };
  143. #endif
  144. #define kDefaultVolumeNameStr "untitled"
  145. /*
  146. * This is the straight GMT conversion constant:
  147. *
  148. * 00:00:00 January 1, 1970 - 00:00:00 January 1, 1904
  149. * (3600 * 24 * ((365 * (1970 - 1904)) + (((1970 - 1904) / 4) + 1)))
  150. */
  151. #define MAC_GMT_FACTOR 2082844800UL
  152. struct DriveInfo {
  153. int fd;
  154. UInt32 sectorSize;
  155. UInt32 sectorOffset;
  156. UInt32 sectorsPerIO;
  157. UInt64 totalSectors;
  158. };
  159. typedef struct DriveInfo DriveInfo;
  160. enum {
  161. kMakeHFSWrapper = 1,
  162. kMakeMaxHFSBitmap = 2
  163. };
  164. struct hfsparams {
  165. UInt16 signature;
  166. UInt16 flags; /* kMakeHFSWrapper */
  167. UInt32 blockSize;
  168. UInt32 rsrcClumpSize;
  169. UInt32 dataClumpSize;
  170. UInt32 nextFreeFileID;
  171. UInt32 catalogClumpSize;
  172. UInt32 catalogNodeSize;
  173. UInt32 extentsClumpSize;
  174. UInt32 extentsNodeSize;
  175. UInt32 attributesClumpSize;
  176. UInt32 attributesNodeSize;
  177. UInt32 allocationClumpSize;
  178. UInt32 createDate; /* in UTC */
  179. UInt32 hfsAlignment;
  180. UInt32 hfsWrapperFreeBlks;
  181. UInt8 volumeName[64]; /* in UTF-8 */
  182. UInt32 journaledHFS;
  183. UInt32 journalSize;
  184. UInt8 *journalDevice;
  185. };
  186. typedef struct hfsparams hfsparams_t;
  187. extern int make_hfs(const DriveInfo *driveInfo, hfsparams_t *defaults,
  188. UInt32 *totalSectors, UInt32 *sectorOffset);
  189. extern int make_hfsplus(const DriveInfo *driveInfo, hfsparams_t *defaults);
  190. #if __STDC__
  191. void fatal(const char *fmt, ...);
  192. #else
  193. void fatal();
  194. #endif