PageRenderTime 58ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/packages/sysutils/diskdev_cmds/patches/diskdev_cmds-332.14-main.patch

http://github.com/OpenELEC/OpenELEC.tv
Patch | 2713 lines | 2554 code | 159 blank | 0 comment | 0 complexity | 26a2fbca3cb0cb14e8109b25084f81d1 MD5 | raw file
Possible License(s): CC0-1.0
  1. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/cache.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/cache.c
  2. --- diskdev_cmds-332.14/fsck_hfs.tproj/cache.c 2006-02-20 22:45:15.000000000 +0100
  3. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/cache.c 2008-07-01 22:30:11.000000000 +0200
  4. @@ -26,7 +26,11 @@
  5. #include <stdlib.h>
  6. #include <sys/mman.h>
  7. #include <sys/stat.h>
  8. +#if LINUX
  9. +#include "missing.h"
  10. +#else
  11. #include <sys/types.h>
  12. +#endif /* __LINUX__ */
  13. #include <sys/uio.h>
  14. #include <unistd.h>
  15. #include <string.h>
  16. Files diskdev_cmds-332.14/fsck_hfs.tproj/cache.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/cache.o differ
  17. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BlockCache.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BlockCache.c
  18. --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BlockCache.c 2006-02-20 22:45:15.000000000 +0100
  19. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BlockCache.c 2008-07-01 22:30:11.000000000 +0200
  20. @@ -20,6 +20,9 @@
  21. * @APPLE_LICENSE_HEADER_END@
  22. */
  23. +#if LINUX
  24. +#include "missing.h"
  25. +#endif
  26. #include "SRuntime.h"
  27. #include "Scavenger.h"
  28. #include "../cache.h"
  29. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BlockCache.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BlockCache.o differ
  30. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTreeAllocate.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTreeAllocate.o differ
  31. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTree.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTree.c
  32. --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTree.c 2006-02-20 22:45:15.000000000 +0100
  33. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTree.c 2008-07-01 22:30:11.000000000 +0200
  34. @@ -1705,7 +1705,9 @@
  35. UInt16 version,
  36. BTreeInfoRec *info )
  37. {
  38. +#if !LINUX
  39. #pragma unused (version)
  40. +#endif
  41. BTreeControlBlockPtr btreePtr;
  42. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTreeMiscOps.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTreeMiscOps.o differ
  43. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTreeNodeOps.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTreeNodeOps.o differ
  44. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTree.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTree.o differ
  45. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTreeScanner.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTreeScanner.o differ
  46. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTreeTreeOps.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTreeTreeOps.c
  47. --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTreeTreeOps.c 2006-02-20 22:45:15.000000000 +0100
  48. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTreeTreeOps.c 2008-07-01 22:30:11.000000000 +0200
  49. @@ -223,7 +223,7 @@
  50. //
  51. if (curNodeNum == 0)
  52. {
  53. -// Panic("\pSearchTree: curNodeNum is zero!");
  54. + Panic("SearchTree: curNodeNum is zero!");
  55. err = fsBTInvalidNodeErr;
  56. goto ErrorExit;
  57. }
  58. @@ -433,7 +433,7 @@
  59. M_ExitOnError (err);
  60. if ( DEBUG_BUILD && updateParent && newRoot )
  61. - DebugStr("\p InsertLevel: New root from primary key, update from secondary key...");
  62. + DebugStr("InsertLevel: New root from primary key, update from secondary key...");
  63. }
  64. //////////////////////// Update Parent(s) ///////////////////////////////
  65. @@ -448,7 +448,7 @@
  66. secondaryKey = nil;
  67. - PanicIf ( (level == btreePtr->treeDepth), "\p InsertLevel: unfinished insert!?");
  68. + PanicIf ( (level == btreePtr->treeDepth), "InsertLevel: unfinished insert!?");
  69. ++level;
  70. @@ -456,7 +456,7 @@
  71. index = treePathTable [level].index;
  72. parentNodeNum = treePathTable [level].node;
  73. - PanicIf ( parentNodeNum == 0, "\p InsertLevel: parent node is zero!?");
  74. + PanicIf ( parentNodeNum == 0, "InsertLevel: parent node is zero!?");
  75. err = GetNode (btreePtr, parentNodeNum, &parentNode); // released as target node in next level up
  76. M_ExitOnError (err);
  77. @@ -470,7 +470,7 @@
  78. {
  79. //ее╩debug: check if ptr == targetNodeNum
  80. GetRecordByIndex (btreePtr, parentNode.buffer, index, &keyPtr, &recPtr, &recSize);
  81. - PanicIf( (*(UInt32 *) recPtr) != targetNodeNum, "\p InsertLevel: parent ptr doesn't match target node!");
  82. + PanicIf( (*(UInt32 *) recPtr) != targetNodeNum, "InsertLevel: parent ptr doesn't match target node!");
  83. // need to delete and re-insert this parent key/ptr
  84. // we delete it here and it gets re-inserted in the
  85. @@ -532,7 +532,7 @@
  86. (void) ReleaseNode (btreePtr, targetNode);
  87. (void) ReleaseNode (btreePtr, &siblingNode);
  88. - Panic ("\p InsertLevel: an error occured!");
  89. + Panic ("InsertLevel: an error occured!");
  90. return err;
  91. @@ -566,7 +566,7 @@
  92. *rootSplit = false;
  93. - PanicIf ( targetNode->buffer == siblingNode->buffer, "\p InsertNode: targetNode == siblingNode, huh?");
  94. + PanicIf ( targetNode->buffer == siblingNode->buffer, "InsertNode: targetNode == siblingNode, huh?");
  95. leftNodeNum = ((NodeDescPtr) targetNode->buffer)->bLink;
  96. rightNodeNum = ((NodeDescPtr) targetNode->buffer)->fLink;
  97. @@ -606,7 +606,7 @@
  98. if ( leftNodeNum > 0 )
  99. {
  100. - PanicIf ( siblingNode->buffer != nil, "\p InsertNode: siblingNode already aquired!");
  101. + PanicIf ( siblingNode->buffer != nil, "InsertNode: siblingNode already aquired!");
  102. if ( siblingNode->buffer == nil )
  103. {
  104. @@ -614,7 +614,7 @@
  105. M_ExitOnError (err);
  106. }
  107. - PanicIf ( ((NodeDescPtr) siblingNode->buffer)->fLink != nodeNum, "\p InsertNode, RotateLeft: invalid sibling link!" );
  108. + PanicIf ( ((NodeDescPtr) siblingNode->buffer)->fLink != nodeNum, "InsertNode, RotateLeft: invalid sibling link!" );
  109. if ( !key->skipRotate ) // are rotates allowed?
  110. {
  111. @@ -703,7 +703,7 @@
  112. targetNodeNum = treePathTable[level].node;
  113. targetNodePtr = targetNode->buffer;
  114. - PanicIf (targetNodePtr == nil, "\pDeleteTree: targetNode has nil buffer!");
  115. + PanicIf (targetNodePtr == nil, "DeleteTree: targetNode has nil buffer!");
  116. DeleteRecord (btreePtr, targetNodePtr, index);
  117. @@ -797,7 +797,7 @@
  118. //ее╩debug: check if ptr == targetNodeNum
  119. GetRecordByIndex (btreePtr, parentNode.buffer, index, &keyPtr, &recPtr, &recSize);
  120. - PanicIf( (*(UInt32 *) recPtr) != targetNodeNum, "\p DeleteTree: parent ptr doesn't match targetNodeNum!!");
  121. + PanicIf( (*(UInt32 *) recPtr) != targetNodeNum, " DeleteTree: parent ptr doesn't match targetNodeNum!!");
  122. // need to delete and re-insert this parent key/ptr
  123. DeleteRecord (btreePtr, parentNode.buffer, index);
  124. @@ -1018,7 +1018,7 @@
  125. keyPtr, keyLength, recPtr, recSize);
  126. if ( !didItFit )
  127. {
  128. - Panic ("\pRotateLeft: InsertKeyRecord (left) returned false!");
  129. + Panic ("RotateLeft: InsertKeyRecord (left) returned false!");
  130. err = fsBTBadRotateErr;
  131. goto ErrorExit;
  132. }
  133. @@ -1031,7 +1031,7 @@
  134. didItFit = RotateRecordLeft (btreePtr, leftNode, rightNode);
  135. if ( !didItFit )
  136. {
  137. - Panic ("\pRotateLeft: RotateRecordLeft returned false!");
  138. + Panic ("RotateLeft: RotateRecordLeft returned false!");
  139. err = fsBTBadRotateErr;
  140. goto ErrorExit;
  141. }
  142. @@ -1048,7 +1048,7 @@
  143. keyPtr, keyLength, recPtr, recSize);
  144. if ( !didItFit )
  145. {
  146. - Panic ("\pRotateLeft: InsertKeyRecord (right) returned false!");
  147. + Panic ("RotateLeft: InsertKeyRecord (right) returned false!");
  148. err = fsBTBadRotateErr;
  149. goto ErrorExit;
  150. }
  151. @@ -1117,7 +1117,7 @@
  152. right = rightNode->buffer;
  153. left = leftNode->buffer;
  154. - PanicIf ( right->bLink != 0 && left == 0, "\p SplitLeft: left sibling missing!?" );
  155. + PanicIf ( right->bLink != 0 && left == 0, " SplitLeft: left sibling missing!?" );
  156. //ее type should be kLeafNode or kIndexNode
  157. @@ -1240,8 +1240,8 @@
  158. Boolean didItFit;
  159. UInt16 keyLength;
  160. - PanicIf (leftNode == nil, "\pAddNewRootNode: leftNode == nil");
  161. - PanicIf (rightNode == nil, "\pAddNewRootNode: rightNode == nil");
  162. + PanicIf (leftNode == nil, "AddNewRootNode: leftNode == nil");
  163. + PanicIf (rightNode == nil, "AddNewRootNode: rightNode == nil");
  164. /////////////////////// Initialize New Root Node ////////////////////////////
  165. @@ -1264,7 +1264,7 @@
  166. didItFit = InsertKeyRecord ( btreePtr, rootNode.buffer, 0, keyPtr, keyLength,
  167. (UInt8 *) &rightNode->bLink, 4 );
  168. - PanicIf ( !didItFit, "\pAddNewRootNode:InsertKeyRecord failed for left index record");
  169. + PanicIf ( !didItFit, "AddNewRootNode:InsertKeyRecord failed for left index record");
  170. //////////////////// Insert Right Node Index Record /////////////////////////
  171. @@ -1275,7 +1275,7 @@
  172. didItFit = InsertKeyRecord ( btreePtr, rootNode.buffer, 1, keyPtr, keyLength,
  173. (UInt8 *) &leftNode->fLink, 4 );
  174. - PanicIf ( !didItFit, "\pAddNewRootNode:InsertKeyRecord failed for right index record");
  175. + PanicIf ( !didItFit, "AddNewRootNode:InsertKeyRecord failed for right index record");
  176. #if DEBUG_TREEOPS
  177. @@ -1355,7 +1355,7 @@
  178. }
  179. rightPtr = rightNodePtr->buffer;
  180. - PanicIf ( leftPtr->fLink != 0 && rightPtr == 0, "\p SplitRight: right sibling missing!?" );
  181. + PanicIf ( leftPtr->fLink != 0 && rightPtr == 0, "SplitRight: right sibling missing!?" );
  182. //ее type should be kLeafNode or kIndexNode
  183. @@ -1557,7 +1557,7 @@
  184. keyPtr, keyLength, recPtr, recSize);
  185. if ( !didItFit )
  186. {
  187. - Panic ("\pRotateRight: InsertKeyRecord (left) returned false!");
  188. + Panic ("RotateRight: InsertKeyRecord (left) returned false!");
  189. err = fsBTBadRotateErr;
  190. goto ErrorExit;
  191. }
  192. @@ -1572,7 +1572,7 @@
  193. didItFit = RotateRecordRight( btreePtr, leftNodePtr, rightNodePtr );
  194. if ( !didItFit )
  195. {
  196. - Panic ("\pRotateRight: RotateRecordRight returned false!");
  197. + Panic ("RotateRight: RotateRecordRight returned false!");
  198. err = fsBTBadRotateErr;
  199. goto ErrorExit;
  200. }
  201. @@ -1583,7 +1583,7 @@
  202. keyPtr, keyLength, recPtr, recSize);
  203. if ( !didItFit )
  204. {
  205. - Panic ("\pRotateRight: InsertKeyRecord (left) returned false!");
  206. + Panic ("RotateRight: InsertKeyRecord (left) returned false!");
  207. err = fsBTBadRotateErr;
  208. goto ErrorExit;
  209. }
  210. @@ -1607,7 +1607,7 @@
  211. keyPtr, keyLength, recPtr, recSize);
  212. if ( !didItFit )
  213. {
  214. - Panic ("\pRotateRight: InsertKeyRecord (right) returned false!");
  215. + Panic ("RotateRight: InsertKeyRecord (right) returned false!");
  216. err = fsBTBadRotateErr;
  217. goto ErrorExit;
  218. }
  219. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTreeTreeOps.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTreeTreeOps.o differ
  220. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/CatalogCheck.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/CatalogCheck.o differ
  221. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/HardLinkCheck.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/HardLinkCheck.o differ
  222. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/hfs_endian.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/hfs_endian.c
  223. --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/hfs_endian.c 2006-02-20 22:45:15.000000000 +0100
  224. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/hfs_endian.c 2008-07-02 00:10:48.000000000 +0200
  225. @@ -31,7 +31,11 @@
  226. #include <sys/types.h>
  227. #include <sys/stat.h>
  228. +#if LINUX
  229. +#include "missing.h"
  230. +#else
  231. #include <architecture/byte_order.h>
  232. +#endif
  233. #include <hfs/hfs_format.h>
  234. #include "Scavenger.h"
  235. @@ -194,7 +198,7 @@
  236. BTNodeDescriptor *srcDesc = src->buffer;
  237. BTreeControlBlockPtr btcb = fcb->fcbBtree;
  238. UInt16 *srcOffs = NULL;
  239. - UInt32 i;
  240. + int i;
  241. int error = 0;
  242. // WriteError(fcb->fcbVolume->vcbGPtr, E_BadNode, fcb->fcbFileID, src->blockNum);
  243. @@ -433,7 +437,7 @@
  244. BTNodeDescriptor *srcDesc = src->buffer;
  245. UInt16 *srcOffs = (UInt16 *)((char *)src->buffer + (src->blockSize - (srcDesc->numRecords * sizeof (UInt16))));
  246. char *nextRecord; /* Points to start of record following current one */
  247. - UInt32 i;
  248. + int i;
  249. UInt32 j;
  250. if (fileID == kHFSExtentsFileID) {
  251. @@ -559,7 +563,7 @@
  252. /* Make sure name length is consistent with key length */
  253. if (keyLength < sizeof(srcKey->parentID) + sizeof(srcKey->nodeName.length) +
  254. srcKey->nodeName.length*sizeof(srcKey->nodeName.unicode[0])) {
  255. - if (debug) printf("hfs_swap_HFSPlusBTInternalNode: catalog record #%d keyLength=%d expected=%lu\n",
  256. + if (debug) printf("hfs_swap_HFSPlusBTInternalNode: catalog record #%d keyLength=%d expected=%i\n",
  257. srcDesc->numRecords-i, keyLength, sizeof(srcKey->parentID) + sizeof(srcKey->nodeName.length) +
  258. srcKey->nodeName.length*sizeof(srcKey->nodeName.unicode[0]));
  259. WriteError(fcb->fcbVolume->vcbGPtr, E_KeyLen, fcb->fcbFileID, src->blockNum);
  260. @@ -854,7 +858,7 @@
  261. UInt16 *srcOffs = (UInt16 *)((char *)src->buffer + (src->blockSize - (srcDesc->numRecords * sizeof (UInt16))));
  262. char *nextRecord; /* Points to start of record following current one */
  263. - UInt32 i;
  264. + int i;
  265. UInt32 j;
  266. if (fileID == kHFSExtentsFileID) {
  267. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/hfs_endian.h diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/hfs_endian.h
  268. --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/hfs_endian.h 2006-02-20 22:45:15.000000000 +0100
  269. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/hfs_endian.h 2008-07-01 22:30:11.000000000 +0200
  270. @@ -27,9 +27,14 @@
  271. *
  272. * This file prototypes endian swapping routines for the HFS/HFS Plus
  273. * volume format.
  274. - */
  275. +*/
  276. #include <hfs/hfs_format.h>
  277. +#if LINUX
  278. +#include <endian.h>
  279. +#include <byteswap.h>
  280. +#else
  281. #include <architecture/byte_order.h>
  282. +#endif
  283. #include "SRuntime.h"
  284. /*********************/
  285. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/hfs_endian.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/hfs_endian.o differ
  286. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/libdfa.a and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/libdfa.a differ
  287. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/Makefile.lnx diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/Makefile.lnx
  288. --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/Makefile.lnx 1970-01-01 01:00:00.000000000 +0100
  289. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/Makefile.lnx 2008-07-01 22:30:11.000000000 +0200
  290. @@ -0,0 +1,15 @@
  291. +CFILES = hfs_endian.c BlockCache.c\
  292. + BTree.c BTreeAllocate.c BTreeMiscOps.c \
  293. + BTreeNodeOps.c BTreeScanner.c BTreeTreeOps.c\
  294. + CatalogCheck.c HardLinkCheck.c\
  295. + SBTree.c SControl.c SVerify1.c SVerify2.c\
  296. + SRepair.c SRebuildCatalogBTree.c\
  297. + SUtils.c SKeyCompare.c SDevice.c SExtents.c SAllocate.c\
  298. + SCatalog.c SStubs.c VolumeBitmapCheck.c
  299. +OFILES = $(CFILES:.c=.o)
  300. +
  301. +libdfa.a: $(OFILES)
  302. + $(AR) rc $@ $?
  303. +
  304. +clean:
  305. + $(RM) $(OFILES) libdfa.a
  306. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SAllocate.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SAllocate.o differ
  307. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SBTree.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SBTree.c
  308. --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SBTree.c 2006-02-20 22:45:15.000000000 +0100
  309. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SBTree.c 2008-07-01 22:30:11.000000000 +0200
  310. @@ -93,7 +93,7 @@
  311. CopyMemory(&resultIterator->key, foundKey, CalcKeySize(btcb, &resultIterator->key)); //ее warning, this could overflow user's buffer!!!
  312. if ( DEBUG_BUILD && !ValidHFSRecord(data, btcb, *dataSize) )
  313. - DebugStr("\pSearchBTreeRecord: bad record?");
  314. + DebugStr("SearchBTreeRecord: bad record?");
  315. }
  316. ErrorExit:
  317. @@ -190,7 +190,7 @@
  318. CopyMemory(&iterator->key, key, CalcKeySize(btcb, &iterator->key)); //ее warning, this could overflow user's buffer!!!
  319. if ( DEBUG_BUILD && !ValidHFSRecord(data, btcb, *dataSize) )
  320. - DebugStr("\pGetBTreeRecord: bad record?");
  321. + DebugStr("GetBTreeRecord: bad record?");
  322. }
  323. @@ -222,7 +222,7 @@
  324. CopyMemory(key, &iterator.key, CalcKeySize(btcb, (BTreeKey *) key)); //ее should we range check against maxkeylen?
  325. if ( DEBUG_BUILD && !ValidHFSRecord(data, btcb, dataSize) )
  326. - DebugStr("\pInsertBTreeRecord: bad record?");
  327. + DebugStr("InsertBTreeRecord: bad record?");
  328. result = BTInsertRecord( fcb, &iterator, &btRecord, dataSize );
  329. @@ -284,7 +284,7 @@
  330. CopyMemory(key, &iterator.key, CalcKeySize(btcb, (BTreeKey *) key)); //ее should we range check against maxkeylen?
  331. if ( DEBUG_BUILD && !ValidHFSRecord(newData, btcb, dataSize) )
  332. - DebugStr("\pReplaceBTreeRecord: bad record?");
  333. + DebugStr("ReplaceBTreeRecord: bad record?");
  334. result = BTReplaceRecord( fcb, &iterator, &btRecord, dataSize );
  335. @@ -301,7 +301,9 @@
  336. OSStatus
  337. SetEndOfForkProc ( SFCB *filePtr, FSSize minEOF, FSSize maxEOF )
  338. {
  339. +#if !LINUX
  340. #pragma unused (maxEOF)
  341. +#endif
  342. OSStatus result;
  343. UInt32 actualSectorsAdded;
  344. @@ -321,7 +323,7 @@
  345. else
  346. {
  347. if ( DEBUG_BUILD )
  348. - DebugStr("\pSetEndOfForkProc: minEOF is smaller than current size!");
  349. + DebugStr("SetEndOfForkProc: minEOF is smaller than current size!");
  350. return -1;
  351. }
  352. @@ -347,7 +349,7 @@
  353. // Make sure we got at least as much space as we needed
  354. //
  355. if (filePtr->fcbLogicalSize < minEOF) {
  356. - Panic("\pSetEndOfForkProc: disk too full to extend B-tree file");
  357. + Panic("SetEndOfForkProc: disk too full to extend B-tree file");
  358. return dskFulErr;
  359. }
  360. @@ -419,7 +421,7 @@
  361. if ( (keyLen < 6) || (keyLen > btcb->maxKeyLength) )
  362. {
  363. if ( DEBUG_BUILD )
  364. - DebugStr("\pCheckBTreeKey: bad key length!");
  365. + DebugStr("CheckBTreeKey: bad key length!");
  366. return fsBTInvalidKeyLengthErr;
  367. }
  368. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SBTree.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SBTree.o differ
  369. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SCatalog.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SCatalog.o differ
  370. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/Scavenger.h diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/Scavenger.h
  371. --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/Scavenger.h 2006-02-20 22:45:15.000000000 +0100
  372. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/Scavenger.h 2008-07-01 22:30:11.000000000 +0200
  373. @@ -35,11 +35,16 @@
  374. #include "BTreeScanner.h"
  375. #include "hfs_endian.h"
  376. +#if LINUX
  377. +#define XATTR_MAXNAMELEN 127
  378. +#include <limits.h>
  379. +#else
  380. #include <sys/xattr.h>
  381. #include <sys/acl.h>
  382. #include <sys/kauth.h>
  383. -#include <sys/errno.h>
  384. #include <sys/syslimits.h>
  385. +#endif
  386. +#include <sys/errno.h>
  387. #ifdef __cplusplus
  388. extern "C" {
  389. @@ -1434,4 +1439,8 @@
  390. };
  391. #endif
  392. +#if LINUX
  393. +#undef XATTR_MAXNAMELEN
  394. +#endif
  395. +
  396. #endif /* __SCAVENGER__ */
  397. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SControl.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SControl.c
  398. --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SControl.c 2006-02-20 22:45:15.000000000 +0100
  399. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SControl.c 2008-07-01 22:30:11.000000000 +0200
  400. @@ -739,7 +739,7 @@
  401. pointer = (ScavStaticStructures *) AllocateClearMemory( sizeof(ScavStaticStructures) );
  402. if ( pointer == nil ) {
  403. if ( GPtr->logLevel >= kDebugLog ) {
  404. - printf( "\t error %d - could not allocate %ld bytes of memory \n",
  405. + printf( "\t error %d - could not allocate %i bytes of memory \n",
  406. R_NoMem, sizeof(ScavStaticStructures) );
  407. }
  408. return( R_NoMem );
  409. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SControl.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SControl.o differ
  410. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SDevice.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SDevice.c
  411. --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SDevice.c 2006-02-20 22:45:15.000000000 +0100
  412. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SDevice.c 2008-07-01 22:30:11.000000000 +0200
  413. @@ -28,24 +28,61 @@
  414. #include <unistd.h>
  415. #include <errno.h>
  416. #include <sys/ioctl.h>
  417. -
  418. +#if LINUX
  419. +#include <fcntl.h>
  420. +#include <sys/stat.h>
  421. +#else
  422. #include <IOKit/storage/IOMediaBSDClient.h>
  423. -
  424. +#endif /* LINUX */
  425. #else
  426. -
  427. #include <Files.h>
  428. #include <Device.h>
  429. #include <Disks.h>
  430. -#endif
  431. -
  432. +#endif
  433. OSErr GetDeviceSize(int driveRefNum, UInt64 *numBlocks, UInt32 *blockSize)
  434. {
  435. #if BSD
  436. UInt64 devBlockCount = 0;
  437. int devBlockSize = 0;
  438. +#if LINUX
  439. + struct stat stbuf;
  440. +
  441. + devBlockSize = 512;
  442. +#ifndef BLKGETSIZE
  443. +#define BLKGETSIZE _IO(0x12,96)
  444. +#endif
  445. +#ifndef BLKGETSIZE64
  446. +#define BLKGETSIZE64 _IOR(0x12,114,size_t)
  447. +#endif
  448. + if (fstat(driveRefNum, &stbuf) < 0){
  449. + printf("Error: %s\n", strerror(errno));
  450. + return(-1);
  451. + }
  452. +
  453. + if (S_ISREG(stbuf.st_mode)) {
  454. + devBlockCount = stbuf.st_size / 512;
  455. + }
  456. + else if (S_ISBLK(stbuf.st_mode)) {
  457. + unsigned long size;
  458. + u_int64_t size64;
  459. + if (!ioctl(driveRefNum, BLKGETSIZE64, &size64))
  460. + devBlockCount = size64 / 512;
  461. + else if (!ioctl(driveRefNum, BLKGETSIZE, &size))
  462. + devBlockCount = size;
  463. + else{
  464. + printf("Error: %s\n", strerror(errno));
  465. + return(-1);
  466. + }
  467. +
  468. + }
  469. + else{
  470. + printf("Device is not a block device");
  471. + return(-1);
  472. + }
  473. +#elif BSD
  474. if (ioctl(driveRefNum, DKIOCGETBLOCKCOUNT, &devBlockCount) < 0) {
  475. printf("ioctl(DKIOCGETBLOCKCOUNT) for fd %d: %s\n", driveRefNum, strerror(errno));
  476. return (-1);
  477. @@ -55,6 +92,7 @@
  478. printf("ioctl(DKIOCGETBLOCKSIZE) for fd %d: %s\n", driveRefNum, strerror(errno));
  479. return (-1);
  480. }
  481. +#endif /* BSD */
  482. if (devBlockSize != 512) {
  483. *numBlocks = (devBlockCount * (UInt64)devBlockSize) / 512;
  484. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SDevice.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SDevice.o differ
  485. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SExtents.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SExtents.o differ
  486. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SKeyCompare.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SKeyCompare.c
  487. --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SKeyCompare.c 2006-02-20 22:45:15.000000000 +0100
  488. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SKeyCompare.c 2008-07-01 22:30:11.000000000 +0200
  489. @@ -454,7 +454,9 @@
  490. * The name portion of the key is compared using a 16-bit binary comparison.
  491. * This is called from the b-tree code.
  492. */
  493. +#if !LINUX
  494. __private_extern__
  495. +#endif
  496. SInt32
  497. CompareAttributeKeys(const AttributeKey *searchKey, const AttributeKey *trialKey)
  498. {
  499. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SKeyCompare.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SKeyCompare.o differ
  500. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SRebuildCatalogBTree.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SRebuildCatalogBTree.o differ
  501. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SRepair.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SRepair.c
  502. --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SRepair.c 2006-02-20 22:45:15.000000000 +0100
  503. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SRepair.c 2008-07-01 22:30:11.000000000 +0200
  504. @@ -1593,7 +1593,9 @@
  505. static OSErr FixWrapperExtents( SGlobPtr GPtr, RepairOrderPtr p )
  506. {
  507. +#if !LINUX
  508. #pragma unused (p)
  509. +#endif
  510. OSErr err;
  511. HFSMasterDirectoryBlock *mdb;
  512. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SRepair.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SRepair.o differ
  513. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SRuntime.h diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SRuntime.h
  514. --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SRuntime.h 2006-02-20 22:45:15.000000000 +0100
  515. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SRuntime.h 2008-07-01 22:30:11.000000000 +0200
  516. @@ -27,8 +27,11 @@
  517. #define __SRUNTIME__
  518. #if BSD
  519. -
  520. +#if LINUX
  521. +#include "missing.h"
  522. +#else
  523. #include <sys/types.h>
  524. +#endif
  525. #include <stdlib.h>
  526. #include <string.h>
  527. #include <stdio.h>
  528. @@ -91,10 +94,12 @@
  529. typedef u_int32_t HFSCatalogNodeID;
  530. +#if !LINUX
  531. enum {
  532. false = 0,
  533. true = 1
  534. };
  535. +#endif
  536. /* OS error codes */
  537. enum {
  538. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SStubs.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SStubs.o differ
  539. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SUtils.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SUtils.c
  540. --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SUtils.c 2006-02-20 22:45:15.000000000 +0100
  541. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SUtils.c 2008-07-01 22:30:11.000000000 +0200
  542. @@ -380,7 +380,8 @@
  543. // GPtr->realVCB Real in-memory vcb
  544. //------------------------------------------------------------------------------
  545. -#if !BSD
  546. +#if BSD
  547. +#if !LINUX
  548. OSErr GetVolumeFeatures( SGlobPtr GPtr )
  549. {
  550. OSErr err;
  551. @@ -418,7 +419,7 @@
  552. return( noErr );
  553. }
  554. #endif
  555. -
  556. +#endif
  557. /*-------------------------------------------------------------------------------
  558. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SUtils.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SUtils.o differ
  559. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SVerify1.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SVerify1.o differ
  560. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SVerify2.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SVerify2.c
  561. --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SVerify2.c 2006-02-20 22:45:15.000000000 +0100
  562. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SVerify2.c 2008-07-01 22:30:11.000000000 +0200
  563. @@ -32,7 +32,9 @@
  564. */
  565. #include <sys/ioctl.h>
  566. +#if !LINUX
  567. #include <sys/disk.h>
  568. +#endif
  569. #include "BTree.h"
  570. #include "BTreePrivate.h"
  571. @@ -1240,8 +1242,13 @@
  572. * clump size for read-only media is irrelevant we skip the clump size
  573. * check to avoid non useful warnings.
  574. */
  575. +#if LINUX
  576. + // FIXME
  577. + isWriteable = 1;
  578. +#else
  579. isWriteable = 0;
  580. ioctl( GPtr->DrvNum, DKIOCISWRITABLE, &isWriteable );
  581. +#endif
  582. if ( isWriteable != 0 &&
  583. volumeHeader->catalogFile.clumpSize != vcb->vcbCatalogFile->fcbClumpSize ) {
  584. PrintError(GPtr, E_InvalidClumpSize, 0);
  585. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SVerify2.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SVerify2.o differ
  586. Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/VolumeBitmapCheck.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/VolumeBitmapCheck.o differ
  587. Files diskdev_cmds-332.14/fsck_hfs.tproj/fsck_hfs and diskdev_cmds-332.14-patched/fsck_hfs.tproj/fsck_hfs differ
  588. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/fsck_hfs.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/fsck_hfs.c
  589. --- diskdev_cmds-332.14/fsck_hfs.tproj/fsck_hfs.c 2006-02-20 22:45:15.000000000 +0100
  590. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/fsck_hfs.c 2008-07-01 22:36:12.000000000 +0200
  591. @@ -24,10 +24,14 @@
  592. #include <sys/types.h>
  593. #include <sys/stat.h>
  594. #include <sys/param.h>
  595. +#if !LINUX
  596. #include <sys/ucred.h>
  597. +#endif
  598. #include <sys/mount.h>
  599. #include <sys/ioctl.h>
  600. +#if !LINUX
  601. #include <sys/disk.h>
  602. +#endif
  603. #include <hfs/hfs_mount.h>
  604. @@ -105,7 +109,7 @@
  605. else
  606. progname = *argv;
  607. - while ((ch = getopt(argc, argv, "dfglm:npqruy")) != EOF) {
  608. + while ((ch = getopt(argc, argv, "dfglm:napqruy")) != EOF) {
  609. switch (ch) {
  610. case 'd':
  611. debug++;
  612. @@ -141,6 +145,7 @@
  613. yflag = 0;
  614. break;
  615. + case 'a':
  616. case 'p':
  617. preen++;
  618. break;
  619. @@ -170,10 +175,12 @@
  620. if (guiControl)
  621. debug = 0; /* debugging is for command line only */
  622. -
  623. +#if LINUX
  624. +// FIXME
  625. +#else
  626. if (signal(SIGINT, SIG_IGN) != SIG_IGN)
  627. (void)signal(SIGINT, catch);
  628. -
  629. +#endif
  630. if (argc < 1) {
  631. (void) fprintf(stderr, "%s: missing special-device\n", progname);
  632. usage();
  633. @@ -194,7 +201,9 @@
  634. int chkLev, repLev, logLev;
  635. int blockDevice_fd, canWrite;
  636. char *unraw, *mntonname;
  637. +#if !LINUX
  638. struct statfs *fsinfo;
  639. +#endif
  640. int fs_fd=-1; // fd to the root-dir of the fs we're checking (only w/lfag == 1)
  641. flags = 0;
  642. @@ -203,7 +212,9 @@
  643. canWrite = 0;
  644. unraw = NULL;
  645. mntonname = NULL;
  646. -
  647. +#if LINUX
  648. + // FIXME
  649. +#else
  650. if (lflag) {
  651. result = getmntinfo(&fsinfo, MNT_NOWAIT);
  652. @@ -233,7 +244,7 @@
  653. }
  654. }
  655. }
  656. -
  657. +#endif
  658. if (debug && preen)
  659. pwarn("starting\n");
  660. @@ -306,6 +317,9 @@
  661. }
  662. }
  663. } else {
  664. +#if LINUX
  665. + // FIXME
  666. +#else
  667. struct statfs stfs_buf;
  668. /*
  669. * Check to see if root is mounted read-write.
  670. @@ -315,18 +329,24 @@
  671. else
  672. flags = 0;
  673. ckfini(flags & MNT_RDONLY);
  674. +#endif
  675. }
  676. /* XXX free any allocated memory here */
  677. if (hotroot && fsmodified) {
  678. +#if !LINUX
  679. struct hfs_mount_args args;
  680. +#endif
  681. /*
  682. * We modified the root. Do a mount update on
  683. * it, unless it is read-write, so we can continue.
  684. */
  685. if (!preen)
  686. printf("\n***** FILE SYSTEM WAS MODIFIED *****\n");
  687. +#if LINUX
  688. + // FIXME
  689. +#else
  690. if (flags & MNT_RDONLY) {
  691. bzero(&args, sizeof(args));
  692. flags |= MNT_UPDATE | MNT_RELOAD;
  693. @@ -335,6 +355,7 @@
  694. goto ExitThisRoutine;
  695. }
  696. }
  697. +#endif
  698. if (!preen)
  699. printf("\n***** REBOOT NOW *****\n");
  700. sync();
  701. @@ -380,11 +401,13 @@
  702. printf("Can't stat %s: %s\n", dev, strerror(errno));
  703. return (0);
  704. }
  705. +#if !LINUX
  706. if ((statb.st_mode & S_IFMT) != S_IFCHR) {
  707. pfatal("%s is not a character device", dev);
  708. if (reply("CONTINUE") == 0)
  709. return (0);
  710. }
  711. +#endif
  712. if ((fsreadfd = open(dev, O_RDONLY)) < 0) {
  713. printf("Can't open %s: %s\n", dev, strerror(errno));
  714. return (0);
  715. @@ -407,10 +430,14 @@
  716. printf("\n");
  717. /* Get device block size to initialize cache */
  718. +#if LINUX
  719. + devBlockSize = 512;
  720. +#else
  721. if (ioctl(fsreadfd, DKIOCGETBLOCKSIZE, &devBlockSize) < 0) {
  722. pfatal ("Can't get device block size\n");
  723. return (0);
  724. }
  725. +#endif
  726. /* Initialize the cache */
  727. if (CacheInit (&fscache, fsreadfd, fswritefd, devBlockSize,
  728. CACHE_IOSIZE, CACHE_BLOCKS, CACHE_HASHSIZE) != EOK) {
  729. @@ -431,11 +458,15 @@
  730. static void getWriteAccess( char *dev, int *blockDevice_fdPtr, int *canWritePtr )
  731. {
  732. +#if !LINUX
  733. int i;
  734. int myMountsCount;
  735. +#endif
  736. void * myPtr;
  737. char * myCharPtr;
  738. +#if !LINUX
  739. struct statfs * myBufPtr;
  740. +#endif
  741. void * myNamePtr;
  742. myPtr = NULL;
  743. @@ -456,18 +487,19 @@
  744. *canWritePtr = 1;
  745. goto ExitThisRoutine;
  746. }
  747. -
  748. // get count of mounts then get the info for each
  749. +#if LINUX
  750. + // FIXME
  751. +#else
  752. myMountsCount = getfsstat( NULL, 0, MNT_NOWAIT );
  753. if ( myMountsCount < 0 )
  754. goto ExitThisRoutine;
  755. -
  756. myPtr = (void *) malloc( sizeof(struct statfs) * myMountsCount );
  757. if ( myPtr == NULL )
  758. goto ExitThisRoutine;
  759. myMountsCount = getfsstat( myPtr,
  760. - (sizeof(struct statfs) * myMountsCount),
  761. - MNT_NOWAIT );
  762. + (sizeof(struct statfs) * myMountsCount),
  763. + MNT_NOWAIT );
  764. if ( myMountsCount < 0 )
  765. goto ExitThisRoutine;
  766. @@ -481,8 +513,8 @@
  767. }
  768. myBufPtr++;
  769. }
  770. +#endif
  771. *canWritePtr = 1; // single user will get us here, f_mntfromname is not /dev/diskXXXX
  772. -
  773. ExitThisRoutine:
  774. if ( myPtr != NULL )
  775. free( myPtr );
  776. @@ -504,7 +536,7 @@
  777. (void) fprintf(stderr, " l = live fsck (lock down and test-only)\n");
  778. (void) fprintf(stderr, " m arg = octal mode used when creating lost+found directory \n");
  779. (void) fprintf(stderr, " n = assume a no response \n");
  780. - (void) fprintf(stderr, " p = just fix normal inconsistencies \n");
  781. + (void) fprintf(stderr, " p, a = just fix normal inconsistencies \n");
  782. (void) fprintf(stderr, " q = quick check returns clean, dirty, or failure \n");
  783. (void) fprintf(stderr, " r = rebuild catalog btree \n");
  784. (void) fprintf(stderr, " u = usage \n");
  785. Files diskdev_cmds-332.14/fsck_hfs.tproj/fsck_hfs.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/fsck_hfs.o differ
  786. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/Makefile.lnx diskdev_cmds-332.14-patched/fsck_hfs.tproj/Makefile.lnx
  787. --- diskdev_cmds-332.14/fsck_hfs.tproj/Makefile.lnx 1970-01-01 01:00:00.000000000 +0100
  788. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/Makefile.lnx 2008-07-01 22:30:11.000000000 +0200
  789. @@ -0,0 +1,15 @@
  790. +CFILES = fsck_hfs.c strings.c utilities.c cache.c
  791. +OFILES = $(CFILES:.c=.o)
  792. +
  793. +all: fsck_hfs
  794. +
  795. +fsck_hfs: $(OFILES) dfalib/libdfa.a
  796. +
  797. +dfalib/libdfa.a: FORCE
  798. + $(MAKE) -C dfalib -f Makefile.lnx libdfa.a
  799. +
  800. +clean:
  801. + $(RM) fsck_hfs $(OFILES)
  802. + $(MAKE) -C dfalib -f Makefile.lnx clean
  803. +
  804. +.PHONY : FORCE clean
  805. Files diskdev_cmds-332.14/fsck_hfs.tproj/strings.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/strings.o differ
  806. diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/utilities.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/utilities.c
  807. --- diskdev_cmds-332.14/fsck_hfs.tproj/utilities.c 2006-02-20 22:45:15.000000000 +0100
  808. +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/utilities.c 2008-07-01 22:30:11.000000000 +0200
  809. @@ -183,12 +183,14 @@
  810. printf("Can't stat %s\n", raw);
  811. return (origname);
  812. }
  813. +#if !LINUX
  814. if ((stchar.st_mode & S_IFMT) == S_IFCHR) {
  815. return (raw);
  816. } else {
  817. printf("%s is not a character device\n", raw);
  818. return (origname);
  819. }
  820. +#endif
  821. } else if ((stblock.st_mode & S_IFMT) == S_IFCHR && !retried) {
  822. newname = unrawname(newname);
  823. retried++;
  824. @@ -214,7 +216,11 @@
  825. *dp = 0;
  826. (void)strcpy(rawbuf, name);
  827. *dp = '/';
  828. - (void)strcat(rawbuf, "/r");
  829. +#if LINUX
  830. + (void)strcat(rawbuf, "/");
  831. +#else
  832. + (void)strcat(rawbuf,"/r");
  833. +#endif
  834. (void)strcat(rawbuf, &dp[1]);
  835. return (rawbuf);
  836. Files diskdev_cmds-332.14/fsck_hfs.tproj/utilities.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/utilities.o differ
  837. diff -druN diskdev_cmds-332.14/include/bitstring.h diskdev_cmds-332.14-patched/include/bitstring.h
  838. --- diskdev_cmds-332.14/include/bitstring.h 1970-01-01 01:00:00.000000000 +0100
  839. +++ diskdev_cmds-332.14-patched/include/bitstring.h 2008-07-01 22:30:11.000000000 +0200
  840. @@ -0,0 +1,164 @@
  841. +/*
  842. + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  843. + *
  844. + * @APPLE_LICENSE_HEADER_START@
  845. + *
  846. + * The contents of this file constitute Original Code as defined in and
  847. + * are subject to the Apple Public Source License Version 1.1 (the
  848. + * "License"). You may not use this file except in compliance with the
  849. + * License. Please obtain a copy of the License at
  850. + * http://www.apple.com/publicsource and read it before using this file.
  851. + *
  852. + * This Original Code and all software distributed under the License are
  853. + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  854. + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  855. + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  856. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
  857. + * License for the specific language governing rights and limitations
  858. + * under the License.
  859. + *
  860. + * @APPLE_LICENSE_HEADER_END@
  861. + */
  862. +/*
  863. + * Copyright (c) 1989, 1993
  864. + * The Regents of the University of California. All rights reserved.
  865. + *
  866. + * This code is derived from software contributed to Berkeley by
  867. + * Paul Vixie.
  868. + *
  869. + * Redistribution and use in source and binary forms, with or without
  870. + * modification, are permitted provided that the following conditions
  871. + * are met:
  872. + * 1. Redistributions of source code must retain the above copyright
  873. + * notice, this list of conditions and the following disclaimer.
  874. + * 2. Redistributions in binary form must reproduce the above copyright
  875. + * notice, this list of conditions and the following disclaimer in the
  876. + * documentation and/or other materials provided with the distribution.
  877. + * 3. All advertising materials mentioning features or use of this software
  878. + * must display the following acknowledgement:
  879. + * This product includes software developed by the University of
  880. + * California, Berkeley and its contributors.
  881. + * 4. Neither the name of the University nor the names of its contributors
  882. + * may be used to endorse or promote products derived from this software
  883. + * without specific prior written permission.
  884. + *
  885. + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  886. + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  887. + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  888. + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  889. + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  890. + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  891. + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  892. + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  893. + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  894. + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  895. + * SUCH DAMAGE.
  896. + *
  897. + * @(#)bitstring.h 8.1 (Berkeley) 7/19/93
  898. + */
  899. +
  900. +#ifndef _BITSTRING_H_
  901. +#define _BITSTRING_H_
  902. +
  903. +typedef unsigned char bitstr_t;
  904. +
  905. +/* internal macros */
  906. + /* byte of the bitstring bit is in */
  907. +#define _bit_byte(bit) \
  908. + ((bit) >> 3)
  909. +
  910. + /* mask for the bit within its byte */
  911. +#define _bit_mask(bit) \
  912. + (1 << ((bit)&0x7))
  913. +
  914. +/* external macros */
  915. + /* bytes in a bitstring of nbits bits */
  916. +#define bitstr_size(nbits) \
  917. + ((((nbits) - 1) >> 3) + 1)
  918. +
  919. + /* allocate a bitstring */
  920. +#define bit_alloc(nbits) \
  921. + (bitstr_t *)calloc(1, \
  922. + (unsigned int)bitstr_size(nbits) * sizeof(bitstr_t))
  923. +
  924. + /* allocate a bitstring on the stack */
  925. +#define bit_decl(name, nbits) \
  926. + (name)[bitstr_size(nbits)]
  927. +
  928. + /* is bit N of bitstring name set? */
  929. +#define bit_test(name, bit) \
  930. + ((name)[_bit_byte(bit)] & _bit_mask(bit))
  931. +
  932. + /* set bit N of bitstring name */
  933. +#define bit_set(name, bit) \
  934. + (name)[_bit_byte(bit)] |= _bit_mask(bit)
  935. +
  936. + /* clear bit N of bitstring name */
  937. +#define bit_clear(name, bit) \
  938. + (name)[_bit_byte(bit)] &= ~_bit_mask(bit)
  939. +
  940. + /* clear bits start ... stop in bitstring */
  941. +#define bit_nclear(name, start, stop) { \
  942. + register bitstr_t *_name = name; \
  943. + register int _start = start, _stop = stop; \
  944. + register int _startbyte = _bit_byte(_start); \
  945. + register int _stopbyte = _bit_byte(_stop); \
  946. + if (_startbyte == _stopbyte) { \
  947. + _name[_startbyte] &= ((0xff >> (8 - (_start&0x7))) | \
  948. + (0xff << ((_stop&0x7) + 1))); \
  949. + } else { \
  950. + _name[_startbyte] &= 0xff >> (8 - (_start&0x7)); \
  951. + while (++_startbyte < _stopbyte) \
  952. + _name[_startbyte] = 0; \
  953. + _name[_stopbyte] &= 0xff << ((_stop&0x7) + 1); \
  954. + } \
  955. +}
  956. +
  957. + /* set bits start ... stop in bitstring */
  958. +#define bit_nset(name, start, stop) { \
  959. + register bitstr_t *_name = name; \
  960. + register int _start = start, _stop = stop; \
  961. + register int _startbyte = _bit_byte(_start); \
  962. + register int _stopbyte = _bit_byte(_stop); \
  963. + if (_startbyte == _stopbyte) { \
  964. + _name[_startbyte] |= ((0xff << (_start&0x7)) & \
  965. + (0xff >> (7 - (_stop&0x7)))); \
  966. + } else { \
  967. + _name[_startbyte] |= 0xff << ((_start)&0x7); \
  968. + while (++_startbyte < _stopbyte) \
  969. + _name[_startbyte] = 0xff; \
  970. + _name[_stopbyte] |= 0xff >> (7 - (_stop&0x7)); \
  971. + } \
  972. +}
  973. +
  974. + /* find first bit clear in name */
  975. +#define bit_ffc(name, nbits, value) { \
  976. + register bitstr_t *_name = name; \
  977. + register int _byte, _nbits = nbits; \
  978. + register int _stopbyte = _bit_byte(_nbits), _value = -1; \
  979. + for (_byte = 0; _byte <= _stopbyte; ++_byte) \
  980. + if (_name[_byte] != 0xff) { \
  981. + _value = _byte << 3; \
  982. + for (_stopbyte = _name[_byte]; (_stopbyte&0x1); \
  983. + ++_value, _stopbyte >>= 1); \
  984. + break; \
  985. + } \
  986. + *(value) = _value; \
  987. +}
  988. +
  989. + /* find first bit set in name */
  990. +#define bit_ffs(name, nbits, value) { \
  991. + register bitstr_t *_name = name; \
  992. + register int _byte, _nbits = nbits; \
  993. + register int _stopbyte = _bit_byte(_nbits), _value = -1; \
  994. + for (_byte = 0; _byte <= _stopbyte; ++_byte) \
  995. + if (_name[_byte]) { \
  996. + _value = _byte << 3; \
  997. + for (_stopbyte = _name[_byte]; !(_stopbyte&0x1); \
  998. + ++_value, _stopbyte >>= 1); \
  999. + break; \
  1000. + } \
  1001. + *(value) = _value; \
  1002. +}
  1003. +
  1004. +#endif /* !_BITSTRING_H_ */
  1005. diff -druN diskdev_cmds-332.14/include/hfs/hfs_format.h diskdev_cmds-332.14-patched/include/hfs/hfs_format.h
  1006. --- diskdev_cmds-332.14/include/hfs/hfs_format.h 1970-01-01 01:00:00.000000000 +0100
  1007. +++ diskdev_cmds-332.14-patched/include/hfs/hfs_format.h 2008-07-01 22:30:11.000000000 +0200
  1008. @@ -0,0 +1,689 @@
  1009. +/*
  1010. + * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
  1011. + *
  1012. + * @APPLE_LICENSE_HEADER_START@
  1013. + *
  1014. + * The contents of this file constitute Original Code as defined in and
  1015. + * are subject to the Apple Public Source License Version 1.1 (the
  1016. + * "License"). You may not use this file except in compliance with the
  1017. + * License. Please obtain a copy of the License at
  1018. + * http://www.apple.com/publicsource and read it before using this file.
  1019. + *
  1020. + * This Original Code and all software distributed under the License are
  1021. + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  1022. + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  1023. + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  1024. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
  1025. + * License for the specific language governing rights and limitations
  1026. + * under the License.
  1027. + *
  1028. + * @APPLE_LICENSE_HEADER_END@
  1029. + */
  1030. +#ifndef __HFS_FORMAT__
  1031. +#define __HFS_FORMAT__
  1032. +
  1033. +#include "missing.h"
  1034. +
  1035. +#include <sys/appleapiopts.h>
  1036. +
  1037. +/*
  1038. + * hfs_format.c
  1039. + *
  1040. + * This file describes the on-disk format for HFS and HFS Plus volumes.
  1041. + * The HFS Plus volume format is desciibed in detail in Apple Technote 1150.
  1042. + *
  1043. + * http://developer.apple.com/technotes/tn/tn1150.html
  1044. + *
  1045. + */
  1046. +
  1047. +#ifdef __cplusplus
  1048. +extern "C" {
  1049. +#endif
  1050. +
  1051. +/* some on-disk hfs structures have 68K alignment (misaligned) */
  1052. +
  1053. +#define PACKED_S __attribute__((packed))
  1054. +
  1055. +/* Signatures used to differentiate between HFS and HFS Plus volumes */
  1056. +enum {
  1057. + kHFSSigWord = 0x4244, /* 'BD' in ASCII */
  1058. + kHFSPlusSigWord = 0x482B, /* 'H+' in ASCII */
  1059. + kHFSXSigWord = 0x4858, /* 'HX' in ASCII */
  1060. +
  1061. + kHFSPlusVersion = 0x0004, /* 'H+' volumes are version 4 only */
  1062. + kHFSXVersion = 0x0005, /* 'HX' volumes start with version 5 */
  1063. +
  1064. + kHFSPlusMountVersion = 0x31302E30, /* '10.0' for Mac OS X */
  1065. + kHFSJMountVersion = 0x4846534a, /* 'HFSJ' for journaled HFS+ on OS X */
  1066. + kFSKMountVersion = 0x46534b21 /* 'FSK!' for failed journal replay */
  1067. +}PACKED_S;
  1068. +
  1069. +
  1070. +#ifdef __APPLE_API_PRIVATE
  1071. +/*
  1072. + * Mac OS X has a special directory for linked and unlinked files (HFS Plus only).
  1073. + * This directory and its contents are never exported from the filesystem under
  1074. + * Mac OS X.
  1075. + *
  1076. + * To make this folder name sort last, it has embedded null prefix.
  1077. + * (0xC0, 0x80 in UTF-8)
  1078. + */
  1079. +#define HFSPLUSMETADATAFOLDER "\xC0\x80\xC0\x80\xC0\x80\xC0\x80HFS+ Private Data"
  1080. +
  1081. +/*
  1082. + * Files in the HFS Private Data folder have one of the following prefixes
  1083. + * followed by a decimal number (no leading zeros). For indirect nodes this
  1084. + * number is a 32 bit random number. For unlinked (deleted) files that are
  1085. + * still open, the number is the file ID for that file.
  1086. + *
  1087. + * e.g. iNode7182000 and temp3296
  1088. + */
  1089. +#define HFS_INODE_PREFIX "iNode"
  1090. +#define HFS_DELETE_PREFIX "temp"
  1091. +
  1092. +#endif /* __APPLE_API_PRIVATE */
  1093. +
  1094. +/*
  1095. + * Indirect link files (hard links) have the following type/creator.
  1096. + */
  1097. +enum {
  1098. + kHardLinkFileType = 0x686C6E6B, /* 'hlnk' */
  1099. + kHFSPlusCreator = 0x6866732B /* 'hfs+' */
  1100. +}PACKED_S;
  1101. +
  1102. +
  1103. +#ifndef _HFSUNISTR255_DEFINED_
  1104. +#define _HFSUNISTR255_DEFINED_
  1105. +/* Unicode strings are used for HFS Plus file and folder names */
  1106. +struct HFSUniStr255 {
  1107. + u_int16_t length; /* number of unicode characters */
  1108. + u_int16_t unicode[255]; /* unicode characters */
  1109. +} PACKED_S;
  1110. +typedef struct HFSUniStr255 HFSUniStr255;
  1111. +typedef const HFSUniStr255 *ConstHFSUniStr255Param;
  1112. +#endif /* _HFSUNISTR255_DEFINED_ */
  1113. +
  1114. +enum {
  1115. + kHFSMaxVolumeNameChars = 27,
  1116. + kHFSMaxFileNameChars = 31,
  1117. + kHFSPlusMaxFileNameChars = 255
  1118. +}PACKED_S;
  1119. +
  1120. +
  1121. +/* Extent overflow file data structures */
  1122. +
  1123. +/* HFS Extent key */
  1124. +struct HFSExtentKey {
  1125. + u_int8_t keyLength; /* length of key, excluding this field */
  1126. + u_int8_t forkType; /* 0 = data fork, FF = resource fork */
  1127. + u_int32_t fileID; /* file ID */
  1128. + u_int16_t startBlock; /* first file allocation block number in this extent */
  1129. +}PACKED_S;
  1130. +typedef struct HFSExtentKey HFSExtentKey;
  1131. +
  1132. +/* HFS Plus Extent key */
  1133. +struct HFSPlusExtentKey {
  1134. + u_int16_t keyLength; /* length of key, excluding this field */
  1135. + u_int8_t forkType; /* 0 = data fork, FF = resource fork */
  1136. + u_int8_t pad; /* make the other fields align on 32-bit boundary */
  1137. + u_int32_t fileID; /* file ID */
  1138. + u_int32_t startBlock; /* first file allocation block number in this extent */
  1139. +}PACKED_S;
  1140. +typedef struct HFSPlusExtentKey HFSPlusExtentKey;
  1141. +
  1142. +/* Number of extent descriptors per extent record */
  1143. +enum {
  1144. + kHFSExtentDensity = 3,
  1145. + kHFSPlusExtentDensity = 8
  1146. +}PACKED_S;
  1147. +
  1148. +/* HFS extent descriptor */
  1149. +struct HFSExtentDescriptor {
  1150. + u_int16_t startBlock; /* first allocation block */
  1151. + u_int16_t blockCount; /* number of allocation blocks */
  1152. +}PACKED_S;
  1153. +typedef struct HFSExtentDescriptor HFSExtentDescriptor;
  1154. +
  1155. +/* HFS Plus extent descriptor */
  1156. +struct HFSPlusExtentDescriptor {
  1157. + u_int32_t startBlock; /* first allocation block */
  1158. + u_int32_t blockCount; /* number of allocation blocks */
  1159. +}PACKED_S;
  1160. +typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor;
  1161. +
  1162. +/* HFS extent record */
  1163. +typedef HFSExtentDescriptor HFSExtentRecord[3];
  1164. +
  1165. +/* HFS Plus extent record */
  1166. +typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[8];
  1167. +
  1168. +
  1169. +/* Finder information */
  1170. +struct FndrFileInfo {
  1171. + u_int32_t fdType; /* file type */
  1172. + u_int32_t fdCreator; /* file creator */
  1173. + u_int16_t fdFlags; /* Finder flags */
  1174. + struct {
  1175. + int16_t v; /* file's location */
  1176. + int16_t h;
  1177. + } PACKED_S fdLocation;
  1178. + int16_t opaque;
  1179. +}PACKED_S;
  1180. +typedef struct FndrFileInfo FndrFileInfo;
  1181. +
  1182. +struct FndrDirInfo {
  1183. + struct { /* folder's window rectangle */
  1184. + int16_t top;
  1185. + int16_t left;
  1186. + int16_t bottom;
  1187. + int16_t right;
  1188. + }PACKED_S frRect;
  1189. + unsigned short frFlags; /* Finder flags */
  1190. + struct {
  1191. + u_int16_t v; /* folder's location */
  1192. + u_int16_t h;
  1193. + }PACKED_S frLocation;
  1194. + int16_t opaque;
  1195. +}PACKED_S;
  1196. +typedef struct FndrDirInfo FndrDirInfo;
  1197. +
  1198. +struct FndrOpaqueInfo {
  1199. + int8_t opaque[16];
  1200. +}PACKED_S;
  1201. +typedef struct FndrOpaqueInfo FndrOpaqueInfo;
  1202. +
  1203. +
  1204. +/* HFS Plus Fork data info - 80 bytes */
  1205. +struct HFSPlusForkData {
  1206. + u_int64_t logicalSize; /* fork's logical size in bytes */
  1207. + u_int32_t clumpSize; /* fork's clump size in bytes */
  1208. + u_int32_t totalBlocks; /* total blocks used by this fork */
  1209. + HFSPlusExtentRecord extents; /* initial set of extents */
  1210. +}PACKED_S;
  1211. +typedef struct HFSPlusForkData HFSPlusForkData;
  1212. +
  1213. +
  1214. +/* Mac OS X has 16 bytes worth of "BSD" info.
  1215. + *
  1216. + * Note: Mac OS 9 implementations and applications
  1217. + * should preserve, but not change, this information.
  1218. + */
  1219. +struct HFSPlusBSDInfo {
  1220. + u_int32_t ownerID; /* user or group ID of file/folder owner */
  1221. + u_int32_t groupID; /* additional user of group ID */
  1222. + u_int8_t adminFlags; /* super-user changeable flags */
  1223. + u_int8_t ownerFlags; /* owner changeable flags */
  1224. + u_int16_t fileMode; /* file type and permission bits */
  1225. + union {
  1226. + u_int32_t iNodeNum; /* indirect node number (hard links only) */
  1227. + u_int32_t linkCount; /* links that refer to this indirect node */
  1228. + u_int32_t rawDevice; /* special file device (FBLK and FCHR only) */
  1229. + }PACKED_S special;
  1230. +}PACKED_S;
  1231. +typedef struct HFSPlusBSDInfo HFSPlusBSDInfo;
  1232. +
  1233. +
  1234. +/* Catalog file data structures */
  1235. +
  1236. +enum {
  1237. + kHFSRootParentID = 1, /* Parent ID of the root folder */
  1238. + kHFSRootFolderID = 2, /* Folder ID of the root folder */
  1239. + kHFSExtentsFileID = 3, /* File ID of the extents file */
  1240. + kHFSCatalogFileID = 4, /* File ID of the catalog file */
  1241. + kHFSBadBlockFileID = 5, /* File ID of the bad allocation block file */
  1242. + kHFSAllocationFileID = 6, /* File ID of the allocation file (HFS Plus only) */
  1243. + kHFSStartupFileID = 7, /* File ID of the startup file (HFS Plus only) */
  1244. + kHFSAttributesFileID = 8, /* File ID of the attribute file (HFS Plus only) */
  1245. + kHFSRepairCatalogFileID = 14, /* Used when rebuilding Catalog B-tree */
  1246. + kHFSBogusExtentFileID = 15, /* Used for exchanging extents in extents file */
  1247. + kHFSFirstUserCatalogNodeID = 16
  1248. +}PACKED_S;
  1249. +
  1250. +/* HFS catalog key */
  1251. +struct HFSCatalogKey {
  1252. + u_int8_t keyLength; /* key length (in bytes) */
  1253. + u_int8_t reserved; /* reserved (set to zero) */
  1254. + u_int32_t parentID; /* parent folder ID */
  1255. + u_int8_t nodeName[kHFSMaxFileNameChars + 1]; /* catalog node name */
  1256. +}PACKED_S;
  1257. +typedef struct HFSCatalogKey HFSCatalogKey;
  1258. +
  1259. +/* HFS Plus catalog key */
  1260. +struct HFSPlusCatalogKey {
  1261. + u_int16_t keyLength; /* key length (in bytes) */
  1262. + u_int32_t parentID; /* parent folder ID */
  1263. + HFSUniStr255 nodeName; /* catalog node name */
  1264. +}PACKED_S;
  1265. +typedef struct HFSPlusCatalogKey HFSPlusCatalogKey;
  1266. +
  1267. +/* Catalog record types */
  1268. +enum {
  1269. + /* HFS Catalog Records */
  1270. + kHFSFolderRecord = 0x0100, /* Folder record */
  1271. + kHFSFileRecord = 0x0200, /* File record */
  1272. + kHFSFolderThreadRecord = 0x0300, /* Folder thread record */
  1273. + kHFSFileThreadRecord = 0x0400, /* File thread record */
  1274. +
  1275. + /* HFS Plus Catalog Records */
  1276. + kHFSPlusFolderRecord = 1, /* Folder record */
  1277. + kHFSPlusFileRecord = 2, /* File record */
  1278. + kHFSPlusFolderThreadRecord = 3, /* Folder thread record */
  1279. + kHFSPlusFileThreadRecord = 4 /* File thread record */
  1280. +}PACKED_S;
  1281. +
  1282. +
  1283. +/* Catalog file record flags */
  1284. +enum {
  1285. + kHFSFileLockedBit = 0x0000, /* file is locked and cannot be written to */
  1286. + kHFSFileLockedMask = 0x0001,
  1287. +
  1288. + kHFSThreadExistsBit = 0x0001, /* a file thread record exists for this file */
  1289. + kHFSThreadExistsMask = 0x0002,
  1290. +
  1291. + kHFSHasAttributesBit = 0x0002, /* object has extended attributes */
  1292. + kHFSHasAttributesMask = 0x0004,
  1293. +
  1294. + kHFSHasSecurityBit = 0x0003, /* object has security data (ACLs) */
  1295. + kHFSHasSecurityMask = 0x0008
  1296. +}PACKED_S;
  1297. +
  1298. +
  1299. +/* HFS catalog folder record - 70 bytes */
  1300. +struct HFSCatalogFolder {
  1301. + int16_t recordType; /* == kHFSFolderRecord */
  1302. + u_int16_t flags; /* folder flags */
  1303. + u_int16_t valence; /* folder valence */
  1304. + u_int32_t folderID; /* folder ID */
  1305. + u_int32_t createDate; /* date and time of creation */
  1306. + u_int32_t modifyDate; /* date and time of last modification */
  1307. + u_int32_t backupDate; /* date and time of last backup */
  1308. + FndrDirInfo userInfo; /* Finder information */
  1309. + FndrOpaqueInfo finderInfo; /* additional Finder information */
  1310. + u_int32_t reserved[4]; /* reserved - initialized as zero */
  1311. +}PACKED_S;
  1312. +typedef struct HFSCatalogFolder HFSCatalogFolder;
  1313. +
  1314. +/* HFS Plus catalog folder record - 88 bytes */
  1315. +struct HFSPlusCatalogFolder {
  1316. + int16_t recordType; /* == kHFSPlusFolderRecord */
  1317. + u_int16_t flags; /* file flags */
  1318. + u_int32_t valence; /* folder's valence (limited to 2^16 in Mac OS) */
  1319. + u_int32_t folderID; /* folder ID */
  1320. + u_int32_t createDate; /* date and time of creation */
  1321. + u_int32_t contentModDate; /* date and time of last content modification */
  1322. + u_int32_t attributeModDate; /* date and time of last attribute modification */
  1323. + u_int32_t accessDate; /* date and time of last access (MacOS X only) */
  1324. + u_int32_t backupDate; /* date and time of last backup */
  1325. + HFSPlusBSDInfo bsdInfo; /* permissions (for MacOS X) */
  1326. + FndrDirInfo userInfo; /* Finder information */
  1327. + FndrOpaqueInfo finderInfo; /* additional Finder information */
  1328. + u_int32_t textEncoding; /* hint for name conversions */
  1329. + u_int32_t attrBlocks; /* cached count of attribute data blocks */
  1330. +}PACKED_S;
  1331. +typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder;
  1332. +
  1333. +/* HFS catalog file record - 102 bytes */
  1334. +struct HFSCatalogFile {
  1335. + int16_t recordType; /* == kHFSFileRecord */
  1336. + u_int8_t flags; /* file flags */
  1337. + int8_t fileType; /* file type (unused ?) */
  1338. + FndrFileInfo userInfo; /* Finder information */
  1339. + u_int32_t fileID; /* file ID */
  1340. + u_int16_t dataStartBlock; /* not used - set to zero */
  1341. + int32_t dataLogicalSize; /* logical EOF of data fork */
  1342. + int32_t dataPhysicalSize; /* physical EOF of data fork */
  1343. + u_int16_t rsrcStartBlock; /* not used - set to zero */
  1344. + int32_t rsrcLogicalSize; /* logical EOF of resource fork */
  1345. + int32_t rsrcPhysicalSize; /* physical EOF of resource fork */
  1346. + u_int32_t createDate; /* date and time of creation */
  1347. + u_int32_t modifyDate; /* date and time of last modification */
  1348. + u_int32_t backupDate; /* date and time of last backup */
  1349. + FndrOpaqueInfo finderInfo; /* additional Finder information */
  1350. + u_int16_t clumpSize; /* file clump size (not used) */
  1351. + HFSExtentRecord dataExtents; /* first data fork extent record */
  1352. + HFSExtentRecord rsrcExtents; /* first resource fork extent record */
  1353. + u_int32_t reserved; /* reserved - initialized as zero */
  1354. +}PACKED_S;
  1355. +typedef struct HFSCatalogFile HFSCatalogFile;
  1356. +
  1357. +/* HFS Plus catalog file record - 248 bytes */
  1358. +struct HFSPlusCatalogFile {
  1359. + int16_t recordType; /* == kHFSPlusFileRecord */
  1360. + u_int16_t flags; /* file flags */
  1361. + u_int32_t reserved1; /* reserved - initialized as zero */
  1362. + u_int32_t fileID; /* file ID */
  1363. + u_int32_t createDate; /* date and time of creation */
  1364. + u_int32_t contentModDate; /* date and time of last content modification */
  1365. + u_int32_t attributeModDate; /* date and time of last attribute modification */
  1366. + u_int32_t accessDate; /* date and time of last access (MacOS X only) */
  1367. + u_int32_t backupDate; /* date and time of last backup */
  1368. + HFSPlusBSDInfo bsdInfo; /* permissions (for MacOS X) */
  1369. + FndrFileInfo userInfo; /* Finder information */
  1370. + FndrOpaqueInfo finderInfo; /* additional Finder information */
  1371. + u_int32_t textEncoding; /* hint for name conversions */
  1372. + u_int32_t attrBlocks; /* cached count of attribute data blocks */
  1373. +
  1374. + /* Note: these start on double long (64 bit) boundry */
  1375. + HFSPlusForkData dataFork; /* size and block data for data fork */
  1376. + HFSPlusForkData resourceFork; /* size and block data for resource fork */
  1377. +}PACKED_S;
  1378. +typedef struct HFSPlusCatalogFile HFSPlusCatalogFile;
  1379. +
  1380. +/* HFS catalog thread record - 46 bytes */
  1381. +struct HFSCatalogThread {
  1382. + int16_t recordType; /* == kHFSFolderThreadRecord or kHFSFileThreadRecord */
  1383. + int32_t reserved[2]; /* reserved - initialized as zero */
  1384. + u_int32_t parentID; /* parent ID for this catalog node */
  1385. + u_int8_t nodeName[kHFSMaxFileNameChars + 1]; /* name of this catalog node */
  1386. +}PACKED_S;
  1387. +typedef struct HFSCatalogThread HFSCatalogThread;
  1388. +
  1389. +/* HFS Plus catalog thread record -- 264 bytes */
  1390. +struct HFSPlusCatalogThread {
  1391. + int16_t recordType; /* == kHFSPlusFolderThreadRecord or kHFSPlusFileThreadRecord */
  1392. + int16_t reserved; /* reserved - initialized as zero */
  1393. + u_int32_t parentID; /* parent ID for this catalog node */
  1394. + HFSUniStr255 nodeName; /* name of this catalog node (variable length) */
  1395. +}PACKED_S;
  1396. +typedef struct HFSPlusCatalogThread HFSPlusCatalogThread;
  1397. +
  1398. +#ifdef __APPLE_API_UNSTABLE
  1399. +/*
  1400. + These are the types of records in the attribute B-tree. The values were
  1401. + chosen so that they wouldn't conflict with the catalog record types.
  1402. +*/
  1403. +enum {
  1404. + kHFSPlusAttrInlineData = 0x10, /* if size < kAttrOverflowSize */
  1405. + kHFSPlusAttrForkData = 0x20, /* if size >= kAttrOverflowSize */
  1406. + kHFSPlusAttrExtents = 0x30 /* overflow extents for large attributes */
  1407. +}PACKED_S;
  1408. +
  1409. +
  1410. +/*
  1411. + HFSPlusAttrForkData
  1412. + For larger attributes, whose value is stored in allocation blocks.
  1413. + If the attribute has more than 8 extents, there will be additonal
  1414. + records (of type HFSPlusAttrExtents) for this attribute.
  1415. +*/
  1416. +struct HFSPlusAttrForkData {
  1417. + u_int32_t recordType; /* == kHFSPlusAttrForkData*/
  1418. + u_int32_t reserved;
  1419. + HFSPlusForkData theFork; /* size and first extents of value*/
  1420. +}PACKED_S;
  1421. +typedef struct HFSPlusAttrForkData HFSPlusAttrForkData;
  1422. +
  1423. +/*
  1424. + HFSPlusAttrExtents
  1425. + This record contains information about overflow extents for large,
  1426. + fragmented attributes.
  1427. +*/
  1428. +struct HFSPlusAttrExtents {
  1429. + u_int32_t recordType; /* == kHFSPlusAttrExtents*/
  1430. + u_int32_t reserved;
  1431. + HFSPlusExtentRecord extents; /* additional extents*/
  1432. +}PACKED_S;
  1433. +typedef struct HFSPlusAttrExtents HFSPlusAttrExtents;
  1434. +
  1435. +/*
  1436. + * Atrributes B-tree Data Record
  1437. + *
  1438. + * For small attributes, whose entire value is stored
  1439. + * within a single B-tree record.
  1440. + */
  1441. +struct HFSPlusAttrData {
  1442. + u_int32_t recordType; /* == kHFSPlusAttrInlineData */
  1443. + u_int32_t reserved[2];
  1444. + u_int32_t attrSize; /* size of attribute data in bytes */
  1445. + u_int8_t attrData[2]; /* variable length */
  1446. +}PACKED_S;
  1447. +typedef struct HFSPlusAttrData HFSPlusAttrData;
  1448. +
  1449. +
  1450. +/* HFSPlusAttrInlineData is obsolete use HFSPlusAttrData instead */
  1451. +struct HFSPlusAttrInlineData {
  1452. + u_int32_t recordType;
  1453. + u_int32_t reserved;
  1454. + u_int32_t logicalSize;
  1455. + u_int8_t userData[2];
  1456. +}PACKED_S;
  1457. +typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData;
  1458. +
  1459. +
  1460. +/* A generic Attribute Record*/
  1461. +union HFSPlusAttrRecord {
  1462. + u_int32_t recordType;
  1463. + HFSPlusAttrInlineData inlineData; /* NOT USED */
  1464. + HFSPlusAttrData attrData;
  1465. + HFSPlusAttrForkData forkData;
  1466. + HFSPlusAttrExtents overflowExtents;
  1467. +}PACKED_S;
  1468. +typedef union HFSPlusAttrRecord HFSPlusAttrRecord;
  1469. +
  1470. +/* Attribute key */
  1471. +enum { kHFSMaxAttrNameLen = 127 };
  1472. +struct HFSPlusAttrKey {
  1473. + u_int16_t keyLength; /* key length (in bytes) */
  1474. + u_int16_t pad; /* set to zero */
  1475. + u_int32_t fileID; /* file associated with attribute */
  1476. + u_int32_t startBlock; /* first attribue allocation block number for extents */
  1477. + u_int16_t attrNameLen; /* number of unicode characters */
  1478. + u_int16_t attrName[127]; /* attribute name (Unicode) */
  1479. +}PACKED_S;
  1480. +typedef struct HFSPlusAttrKey HFSPlusAttrKey;
  1481. +
  1482. +#define kHFSPlusAttrKeyMaximumLength (sizeof(HFSPlusAttrKey) - sizeof(u_int16_t))
  1483. +#define kHFSPlusAttrKeyMinimumLength (kHFSPlusAttrKeyMaximumLength - (127 * sizeof(u_int16_t)))
  1484. +
  1485. +#endif /* __APPLE_API_UNSTABLE */
  1486. +
  1487. +
  1488. +/* Key and node lengths */
  1489. +enum {
  1490. + kHFSPlusExtentKeyMaximumLength = sizeof(HFSPlusExtentKey) - sizeof(u_int16_t),
  1491. + kHFSExtentKeyMaximumLength = sizeof(HFSExtentKey) - sizeof(u_int8_t),
  1492. + kHFSPlusCatalogKeyMaximumLength = sizeof(HFSPlusCatalogKey) - sizeof(u_int16_t),
  1493. + kHFSPlusCatalogKeyMinimumLength = kHFSPlusCatalogKeyMaximumLength - sizeof(HFSUniStr255) + sizeof(u_int16_t),
  1494. + kHFSCatalogKeyMaximumLength = sizeof(HFSCatalogKey) - sizeof(u_int8_t),
  1495. + kHFSCatalogKeyMinimumLength = kHFSCatalogKeyMaximumLength - (kHFSMaxFileNameChars + 1) + sizeof(u_int8_t),
  1496. + kHFSPlusCatalogMinNodeSize = 4096,
  1497. + kHFSPlusExtentMinNodeSize = 512,
  1498. + kHFSPlusAttrMinNodeSize = 4096
  1499. +}PACKED_S;
  1500. +
  1501. +/* HFS and HFS Plus volume attribute bits */
  1502. +enum {
  1503. + /* Bits 0-6 are reserved (always cleared by MountVol call) */
  1504. + kHFSVolumeHardwareLockBit = 7, /* volume is locked by hardware */
  1505. + kHFSVolumeUnmountedBit = 8, /* volume was successfully unmounted */
  1506. + kHFSVolumeSparedBlocksBit = 9, /* volume has bad blocks spared */
  1507. + kHFSVolumeNoCacheRequiredBit = 10, /* don't cache volume blocks (i.e. RAM or ROM disk) */
  1508. + kHFSBootVolumeInconsistentBit = 11, /* boot volume is inconsistent (System 7.6 and later) */
  1509. + kHFSCatalogNodeIDsReusedBit = 12,
  1510. + kHFSVolumeJournaledBit = 13, /* this volume has a journal on it */
  1511. + kHFSVolumeInconsistentBit = 14, /* serious inconsistencies detected at runtime */
  1512. + kHFSVolumeSoftwareLockBit = 15, /* volume is locked by software */
  1513. +
  1514. + kHFSVolumeHardwareLockMask = 1 << kHFSVolumeHardwareLockBit,
  1515. + kHFSVolumeUnmountedMask = 1 << kHFSVolumeUnmountedBit,
  1516. + kHFSVolumeSparedBlocksMask = 1 << kHFSVolumeSparedBlocksBit,
  1517. + kHFSVolumeNoCacheRequiredMask = 1 << kHFSVolumeNoCacheRequiredBit,
  1518. + kHFSBootVolumeInconsistentMask = 1 << kHFSBootVolumeInconsistentBit,
  1519. + kHFSCatalogNodeIDsReusedMask = 1 << kHFSCatalogNodeIDsReusedBit,
  1520. + kHFSVolumeJournaledMask = 1 << kHFSVolumeJournaledBit,
  1521. + kHFSVolumeInconsistentMask = 1 << kHFSVolumeInconsistentBit,
  1522. + kHFSVolumeSoftwareLockMask = 1 << kHFSVolumeSoftwareLockBit,
  1523. + kHFSMDBAttributesMask = 0x8380
  1524. +}PACKED_S;
  1525. +
  1526. +
  1527. +/* HFS Master Directory Block - 162 bytes */
  1528. +/* Stored at sector #2 (3rd sector) and second-to-last sector. */
  1529. +struct HFSMasterDirectoryBlock {
  1530. + u_int16_t drSigWord; /* == kHFSSigWord */
  1531. + u_int32_t drCrDate; /* date and time of volume creation */
  1532. + u_int32_t drLsMod; /* date and time of last modification */
  1533. + u_int16_t drAtrb; /* volume attributes */
  1534. + u_int16_t drNmFls; /* number of files in root folder */
  1535. + u_int16_t drVBMSt; /* first block of volume bitmap */
  1536. + u_int16_t drAllocPtr; /* start of next allocation search */
  1537. + u_int16_t drNmAlBlks; /* number of allocation blocks in volume */
  1538. + u_int32_t drAlBlkSiz; /* size (in bytes) of allocation blocks */
  1539. + u_int32_t drClpSiz; /* default clump size */
  1540. + u_int16_t drAlBlSt; /* first allocation block in volume */
  1541. + u_int32_t drNxtCNID; /* next unused catalog node ID */
  1542. + u_int16_t drFreeBks; /* number of unused allocation blocks */
  1543. + u_int8_t drVN[kHFSMaxVolumeNameChars + 1]; /* volume name */
  1544. + u_int32_t drVolBkUp; /* date and time of last backup */
  1545. + u_int16_t drVSeqNum; /* volume backup sequence number */
  1546. + u_int32_t drWrCnt; /* volume write count */
  1547. + u_int32_t drXTClpSiz; /* clump size for extents overflow file */
  1548. + u_int32_t drCTClpSiz; /* clump size for catalog file */
  1549. + u_int16_t drNmRtDirs; /* number of directories in root folder */
  1550. + u_int32_t drFilCnt; /* number of files in volume */
  1551. + u_int32_t drDirCnt; /* number of directories in volume */
  1552. + u_int32_t drFndrInfo[8]; /* information used by the Finder */
  1553. + u_int16_t drEmbedSigWord; /* embedded volume signature (formerly drVCSize) */
  1554. + HFSExtentDescriptor drEmbedExtent; /* embedded volume location and size (formerly drVBMCSize and drCtlCSize) */
  1555. + u_int32_t drXTFlSize; /* size of extents overflow file */
  1556. + HFSExtentRecord drXTExtRec; /* extent record for extents overflow file */
  1557. + u_int32_t drCTFlSize; /* size of catalog file */
  1558. + HFSExtentRecord drCTExtRec; /* extent record for catalog file */
  1559. +}PACKED_S;
  1560. +typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock;
  1561. +
  1562. +
  1563. +#ifdef __APPLE_API_UNSTABLE
  1564. +#define SET_HFS_TEXT_ENCODING(hint) \
  1565. + (0x656e6300 | ((hint) & 0xff))
  1566. +#define GET_HFS_TEXT_ENCODING(hint) \
  1567. + (((hint) & 0xffffff00) == 0x656e6300 ? (hint) & 0x000000ff : 0xffffffffU)
  1568. +#endif /* __APPLE_API_UNSTABLE */
  1569. +
  1570. +
  1571. +/* HFS Plus Volume Header - 512 bytes */
  1572. +/* Stored at sector #2 (3rd sector) and second-to-last sector. */
  1573. +struct HFSPlusVolumeHeader {
  1574. + u_int16_t signature; /* == kHFSPlusSigWord */
  1575. + u_int16_t version; /* == kHFSPlusVersion */
  1576. + u_int32_t attributes; /* volume attributes */
  1577. + u_int32_t lastMountedVersion; /* implementation version which last mounted volume */
  1578. + u_int32_t journalInfoBlock; /* block addr of journal info (if volume is journaled, zero otherwise) */
  1579. +
  1580. + u_int32_t createDate; /* date and time of volume creation */
  1581. + u_int32_t modifyDate; /* date and time of last modification */
  1582. + u_int32_t backupDate; /* date and time of last backup */
  1583. + u_int32_t checkedDate; /* date and time of last disk check */
  1584. +
  1585. + u_int32_t fileCount; /* number of files in volume */
  1586. + u_int32_t folderCount; /* number of directories in volume */
  1587. +
  1588. + u_int32_t blockSize; /* size (in bytes) of allocation blocks */
  1589. + u_int32_t totalBlocks; /* number of allocation blocks in volume (includes this header and VBM*/
  1590. + u_int32_t freeBlocks; /* number of unused allocation blocks */
  1591. +
  1592. + u_int32_t nextAllocation; /* start of next allocation search */
  1593. + u_int32_t rsrcClumpSize; /* default resource fork clump size */
  1594. + u_int32_t dataClumpSize; /* default data fork clump size */
  1595. + u_int32_t nextCatalogID; /* next unused catalog node ID */
  1596. +
  1597. + u_int32_t writeCount; /* volume write count */
  1598. + u_int64_t encodingsBitmap; /* which encodings have been use on this volume */
  1599. +
  1600. + u_int8_t finderInfo[32]; /* information used by the Finder */
  1601. +
  1602. + HFSPlusForkData allocationFile; /* allocation bitmap file */
  1603. + HFSPlusForkData extentsFile; /* extents B-tree file */
  1604. + HFSPlusForkData catalogFile; /* catalog B-tree file */
  1605. + HFSPlusForkData attributesFile; /* extended attributes B-tree file */
  1606. + HFSPlusForkData startupFile; /* boot file (secondary loader) */
  1607. +}PACKED_S;
  1608. +typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader;
  1609. +
  1610. +
  1611. +/* B-tree structures */
  1612. +
  1613. +enum BTreeKeyLimits{
  1614. + kMaxKeyLength = 520
  1615. +}PACKED_S;
  1616. +
  1617. +union BTreeKey{
  1618. + u_int8_t length8;
  1619. + u_int16_t length16;
  1620. + u_int8_t rawData [kMaxKeyLength+2];
  1621. +}PACKED_S;
  1622. +typedef union BTreeKey BTreeKey;
  1623. +
  1624. +/* BTNodeDescriptor -- Every B-tree node starts with these fields. */
  1625. +struct BTNodeDescriptor {
  1626. + u_int32_t fLink; /* next node at this level*/
  1627. + u_int32_t bLink; /* previous node at this level*/
  1628. + int8_t kind; /* kind of node (leaf, index, header, map)*/
  1629. + u_int8_t height; /* zero for header, map; child is one more than parent*/
  1630. + u_int16_t numRecords; /* number of records in this node*/
  1631. + u_int16_t reserved; /* reserved - initialized as zero */
  1632. +}PACKED_S;
  1633. +typedef struct BTNodeDescriptor BTNodeDescriptor;
  1634. +
  1635. +/* Constants for BTNodeDescriptor kind */
  1636. +enum {
  1637. + kBTLeafNode = -1,
  1638. + kBTIndexNode = 0,
  1639. + kBTHeaderNode = 1,
  1640. + kBTMapNode = 2
  1641. +}PACKED_S;
  1642. +
  1643. +/* BTHeaderRec -- The first record of a B-tree header node */
  1644. +struct BTHeaderRec {
  1645. + u_int16_t treeDepth; /* maximum height (usually leaf nodes) */
  1646. + u_int32_t rootNode; /* node number of root node */
  1647. + u_int32_t leafRecords; /* number of leaf records in all leaf nodes */
  1648. + u_int32_t firstLeafNode; /* node number of first leaf node */
  1649. + u_int32_t lastLeafNode; /* node number of last leaf node */
  1650. + u_int16_t nodeSize; /* size of a node, in bytes */
  1651. + u_int16_t maxKeyLength; /* reserved */
  1652. + u_int32_t totalNodes; /* total number of nodes in tree */
  1653. + u_int32_t freeNodes; /* number of unused (free) nodes in tree */
  1654. + u_int16_t reserved1; /* unused */
  1655. + u_int32_t clumpSize; /* reserved */
  1656. + u_int8_t btreeType; /* reserved */
  1657. + u_int8_t keyCompareType; /* Key string Comparison Type */
  1658. + u_int32_t attributes; /* persistent attributes about the tree */
  1659. + u_int32_t reserved3[16]; /* reserved */
  1660. +}PACKED_S;
  1661. +typedef struct BTHeaderRec BTHeaderRec;
  1662. +
  1663. +/* Constants for BTHeaderRec attributes */
  1664. +enum {
  1665. + kBTBadCloseMask = 0x00000001, /* reserved */
  1666. + kBTBigKeysMask = 0x00000002, /* key length field is 16 bits */
  1667. + kBTVariableIndexKeysMask = 0x00000004 /* keys in index nodes are variable length */
  1668. +}PACKED_S;
  1669. +
  1670. +
  1671. +/* Catalog Key Name Comparison Type */
  1672. +enum {
  1673. + kHFSCaseFolding = 0xCF, /* case folding (case-insensitive) */
  1674. + kHFSBinaryCompare = 0xBC /* binary compare (case-sensitive) */
  1675. +}PACKED_S;
  1676. +
  1677. +/* JournalInfoBlock - Structure that describes where our journal lives */
  1678. +struct JournalInfoBlock {
  1679. + u_int32_t flags;
  1680. + u_int32_t device_signature[8]; // signature used to locate our device.
  1681. + u_int64_t offset; // byte offset to the journal on the device
  1682. + u_int64_t size; // size in bytes of the journal
  1683. + u_int32_t reserved[32];
  1684. +}PACKED_S;
  1685. +typedef struct JournalInfoBlock JournalInfoBlock;
  1686. +
  1687. +enum {
  1688. + kJIJournalInFSMask = 0x00000001,
  1689. + kJIJournalOnOtherDeviceMask = 0x00000002,
  1690. + kJIJournalNeedInitMask = 0x00000004
  1691. +}PACKED_S;
  1692. +
  1693. +#ifdef __cplusplus
  1694. +}
  1695. +#endif
  1696. +
  1697. +#endif /* __HFS_FORMAT__ */
  1698. diff -druN diskdev_cmds-332.14/include/hfs/hfs_mount.h diskdev_cmds-332.14-patched/include/hfs/hfs_mount.h
  1699. --- diskdev_cmds-332.14/include/hfs/hfs_mount.h 1970-01-01 01:00:00.000000000 +0100
  1700. +++ diskdev_cmds-332.14-patched/include/hfs/hfs_mount.h 2008-07-01 22:30:11.000000000 +0200
  1701. @@ -0,0 +1,78 @@
  1702. +/*
  1703. + * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
  1704. + *
  1705. + * @APPLE_LICENSE_HEADER_START@
  1706. + *
  1707. + * The contents of this file constitute Original Code as defined in and
  1708. + * are subject to the Apple Public Source License Version 1.1 (the
  1709. + * "License"). You may not use this file except in compliance with the
  1710. + * License. Please obtain a copy of the License at
  1711. + * http://www.apple.com/publicsource and read it before using this file.
  1712. + *
  1713. + * This Original Code and all software distributed under the License are
  1714. + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  1715. + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  1716. + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  1717. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
  1718. + * License for the specific language governing rights and limitations
  1719. + * under the License.
  1720. + *
  1721. + * @APPLE_LICENSE_HEADER_END@
  1722. + */
  1723. +/*
  1724. + * Copyright (c) 1997-2002 Apple Computer, Inc. All Rights Reserved
  1725. + *
  1726. + */
  1727. +
  1728. +#ifndef _HFS_MOUNT_H_
  1729. +#define _HFS_MOUNT_H_
  1730. +
  1731. +#include <sys/appleapiopts.h>
  1732. +
  1733. +#include <sys/mount.h>
  1734. +#include <sys/time.h>
  1735. +
  1736. +/*
  1737. + * Arguments to mount HFS-based filesystems
  1738. + */
  1739. +
  1740. +#define OVERRIDE_UNKNOWN_PERMISSIONS 0
  1741. +
  1742. +#define UNKNOWNUID ((uid_t)99)
  1743. +#define UNKNOWNGID ((gid_t)99)
  1744. +#define UNKNOWNPERMISSIONS (S_IRWXU | S_IROTH | S_IXOTH) /* 705 */
  1745. +
  1746. +#ifdef __APPLE_API_UNSTABLE
  1747. +struct hfs_mount_args {
  1748. +#ifndef KERNEL
  1749. + char *fspec; /* block special device to mount */
  1750. +#endif
  1751. + uid_t hfs_uid; /* uid that owns hfs files (standard HFS only) */
  1752. + gid_t hfs_gid; /* gid that owns hfs files (standard HFS only) */
  1753. + mode_t hfs_mask; /* mask to be applied for hfs perms (standard HFS only) */
  1754. + u_int32_t hfs_encoding; /* encoding for this volume (standard HFS only) */
  1755. + struct timezone hfs_timezone; /* user time zone info (standard HFS only) */
  1756. + int flags; /* mounting flags, see below */
  1757. + int journal_tbuffer_size; /* size in bytes of the journal transaction buffer */
  1758. + int journal_flags; /* flags to pass to journal_open/create */
  1759. + int journal_disable; /* don't use journaling (potentially dangerous) */
  1760. +};
  1761. +
  1762. +#define HFSFSMNT_NOXONFILES 0x1 /* disable execute permissions for files */
  1763. +#define HFSFSMNT_WRAPPER 0x2 /* mount HFS wrapper (if it exists) */
  1764. +#define HFSFSMNT_EXTENDED_ARGS 0x4 /* indicates new fields after "flags" are valid */
  1765. +
  1766. +/*
  1767. + * Sysctl values for HFS
  1768. + */
  1769. +#define HFS_ENCODINGBIAS 1 /* encoding matching CJK bias */
  1770. +#define HFS_EXTEND_FS 2
  1771. +#define HFS_ENCODINGHINT 3 /* guess encoding for string */
  1772. +#define HFS_ENABLE_JOURNALING 0x082969
  1773. +#define HFS_DISABLE_JOURNALING 0x031272
  1774. +#define HFS_GET_JOURNAL_INFO 0x6a6e6c69
  1775. +#define HFS_SET_PKG_EXTENSIONS 0x121031
  1776. +
  1777. +#endif /* __APPLE_API_UNSTABLE */
  1778. +
  1779. +#endif /* ! _HFS_MOUNT_H_ */
  1780. diff -druN diskdev_cmds-332.14/include/missing.h diskdev_cmds-332.14-patched/include/missing.h
  1781. --- diskdev_cmds-332.14/include/missing.h 1970-01-01 01:00:00.000000000 +0100
  1782. +++ diskdev_cmds-332.14-patched/include/missing.h 2008-07-01 22:30:11.000000000 +0200
  1783. @@ -0,0 +1,113 @@
  1784. +#ifndef _MISSING_H_
  1785. +#define _MISSING_H_
  1786. +
  1787. +#include <endian.h>
  1788. +#include <byteswap.h>
  1789. +#include <errno.h>
  1790. +#include <stdint.h>
  1791. +
  1792. +#define MAXBSIZE (256 * 4096)
  1793. +
  1794. +#ifndef true
  1795. +#define true 1
  1796. +#endif
  1797. +#ifndef false
  1798. +#define false 0
  1799. +#endif
  1800. +
  1801. +/* Mac types */
  1802. +
  1803. +/* 8 Bit */
  1804. +#ifndef UInt8
  1805. +#define UInt8 uint8_t
  1806. +#endif
  1807. +#ifndef u_int8_t
  1808. +#define u_int8_t UInt8
  1809. +#endif
  1810. +#ifndef SInt8
  1811. +#define SInt8 int8_t
  1812. +#endif
  1813. +
  1814. +/* 16 Bit */
  1815. +#ifndef UInt16
  1816. +#define UInt16 uint16_t
  1817. +#endif
  1818. +#ifndef u_int16_t
  1819. +#define u_int16_t UInt16
  1820. +#endif
  1821. +#ifndef SInt16
  1822. +#define SInt16 int16_t
  1823. +#endif
  1824. +
  1825. +/* 32 Bit */
  1826. +#ifndef UInt32
  1827. +#define UInt32 uint32_t
  1828. +#endif
  1829. +#ifndef u_int32_t
  1830. +#define u_int32_t UInt32
  1831. +#endif
  1832. +#ifndef SInt32
  1833. +#define SInt32 int32_t
  1834. +#endif
  1835. +
  1836. +/* 64 Bit */
  1837. +#ifndef UInt64
  1838. +#define UInt64 uint64_t
  1839. +#endif
  1840. +#ifndef u_int64_t
  1841. +#define u_int64_t UInt64
  1842. +#endif
  1843. +#ifndef SInt64
  1844. +#define SInt64 int64_t
  1845. +#endif
  1846. +
  1847. +#define UniChar u_int16_t
  1848. +#define Boolean u_int8_t
  1849. +
  1850. +#define UF_NODUMP 0x00000001
  1851. +
  1852. +/* syslimits.h */
  1853. +#define NAME_MAX 255
  1854. +
  1855. +/* Byteswap stuff */
  1856. +#define NXSwapHostLongToBig(x) cpu_to_be64(x)
  1857. +#define NXSwapBigShortToHost(x) be16_to_cpu(x)
  1858. +#define OSSwapBigToHostInt16(x) be16_to_cpu(x)
  1859. +#define NXSwapBigLongToHost(x) be32_to_cpu(x)
  1860. +#define OSSwapBigToHostInt32(x) be32_to_cpu(x)
  1861. +#define NXSwapBigLongLongToHost(x) be64_to_cpu(x)
  1862. +#define OSSwapBigToHostInt64(x) be64_to_cpu(x)
  1863. +
  1864. +#if __BYTE_ORDER == __LITTLE_ENDIAN
  1865. +/* Big Endian Swaps */
  1866. +#ifndef be16_to_cpu
  1867. +#define be16_to_cpu(x) bswap_16(x)
  1868. +#endif
  1869. +#ifndef be32_to_cpu
  1870. +#define be32_to_cpu(x) bswap_32(x)
  1871. +#endif
  1872. +#ifndef be64_to_cpu
  1873. +#define be64_to_cpu(x) bswap_64(x)
  1874. +#endif
  1875. +#ifndef cpu_to_be64
  1876. +#define cpu_to_be64(x) bswap_64(x)
  1877. +#endif
  1878. +#elif __BYTE_ORDER == __BIG_ENDIAN
  1879. +/* Big endian doesn't swap */
  1880. +#ifndef be16_to_cpu
  1881. +#define be16_to_cpu(x) (x)
  1882. +#endif
  1883. +#ifndef be32_to_cpu
  1884. +#define be32_to_cpu(x) (x)
  1885. +#endif
  1886. +#ifndef be64_to_cpu
  1887. +#define be64_to_cpu(x) (x)
  1888. +#endif
  1889. +#ifndef cpu_to_be64
  1890. +#define cpu_to_be64(x) (x)
  1891. +#endif
  1892. +#endif
  1893. +
  1894. +#define KAUTH_FILESEC_XATTR "com.apple.system.Security"
  1895. +
  1896. +#endif
  1897. diff -druN diskdev_cmds-332.14/include/sys/appleapiopts.h diskdev_cmds-332.14-patched/include/sys/appleapiopts.h
  1898. --- diskdev_cmds-332.14/include/sys/appleapiopts.h 1970-01-01 01:00:00.000000000 +0100
  1899. +++ diskdev_cmds-332.14-patched/include/sys/appleapiopts.h 2008-07-01 22:30:11.000000000 +0200
  1900. @@ -0,0 +1,56 @@
  1901. +/*
  1902. + * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
  1903. + *
  1904. + * @APPLE_LICENSE_HEADER_START@
  1905. + *
  1906. + * The contents of this file constitute Original Code as defined in and
  1907. + * are subject to the Apple Public Source License Version 1.1 (the
  1908. + * "License"). You may not use this file except in compliance with the
  1909. + * License. Please obtain a copy of the License at
  1910. + * http://www.apple.com/publicsource and read it before using this file.
  1911. + *
  1912. + * This Original Code and all software distributed under the License are
  1913. + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  1914. + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  1915. + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  1916. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
  1917. + * License for the specific language governing rights and limitations
  1918. + * under the License.
  1919. + *
  1920. + * @APPLE_LICENSE_HEADER_END@
  1921. + */
  1922. +
  1923. +#ifndef __SYS_APPLEAPIOPTS_H__
  1924. +#define __SYS_APPLEAPIOPTS_H__
  1925. +
  1926. +
  1927. +#ifndef __APPLE_API_STANDARD
  1928. +#define __APPLE_API_STANDARD
  1929. +#endif /* __APPLE_API_STANDARD */
  1930. +
  1931. +#ifndef __APPLE_API_STABLE
  1932. +#define __APPLE_API_STABLE
  1933. +#endif /* __APPLE_API_STABLE */
  1934. +
  1935. +#ifndef __APPLE_API_STRICT_CONFORMANCE
  1936. +
  1937. +#ifndef __APPLE_API_EVOLVING
  1938. +#define __APPLE_API_EVOLVING
  1939. +#endif /* __APPLE_API_EVOLVING */
  1940. +
  1941. +#ifndef __APPLE_API_UNSTABLE
  1942. +#define __APPLE_API_UNSTABLE
  1943. +#endif /* __APPLE_API_UNSTABLE */
  1944. +
  1945. +#ifndef __APPLE_API_PRIVATE
  1946. +#define __APPLE_API_PRIVATE
  1947. +#endif /* __APPLE_API_PRIVATE */
  1948. +
  1949. +#ifndef __APPLE_API_OBSOLETE
  1950. +#define __APPLE_API_OBSOLETE
  1951. +#endif /* __APPLE_API_OBSOLETE */
  1952. +
  1953. +#endif /* __APPLE_API_STRICT_CONFORMANCE */
  1954. +
  1955. +#endif /* __SYS_APPLEAPIOPTS_H__ */
  1956. +
  1957. diff -druN diskdev_cmds-332.14/Makefile.lnx diskdev_cmds-332.14-patched/Makefile.lnx
  1958. --- diskdev_cmds-332.14/Makefile.lnx 1970-01-01 01:00:00.000000000 +0100
  1959. +++ diskdev_cmds-332.14-patched/Makefile.lnx 2008-07-01 22:30:11.000000000 +0200
  1960. @@ -0,0 +1,8 @@
  1961. +CC := gcc
  1962. +CFLAGS := -g3 -Wall -I$(PWD)/include -DDEBUG_BUILD=0 -D_FILE_OFFSET_BITS=64 -D LINUX=1 -D BSD=1
  1963. +SUBDIRS := newfs_hfs.tproj fsck_hfs.tproj
  1964. +
  1965. +all clean:
  1966. + for d in $(SUBDIRS); do $(MAKE) -C $$d -f Makefile.lnx $@; done
  1967. +
  1968. +export CC CFLAGS
  1969. diff -druN diskdev_cmds-332.14/newfs_hfs.tproj/hfs_endian.c diskdev_cmds-332.14-patched/newfs_hfs.tproj/hfs_endian.c
  1970. --- diskdev_cmds-332.14/newfs_hfs.tproj/hfs_endian.c 2006-02-20 22:45:15.000000000 +0100
  1971. +++ diskdev_cmds-332.14-patched/newfs_hfs.tproj/hfs_endian.c 2008-07-01 22:30:11.000000000 +0200
  1972. @@ -30,7 +30,12 @@
  1973. #include <sys/types.h>
  1974. #include <sys/stat.h>
  1975. +#if LINUX
  1976. +#include "missing.h"
  1977. +#else
  1978. #include <architecture/byte_order.h>
  1979. +#endif
  1980. +
  1981. #include <hfs/hfs_format.h>
  1982. #include "hfs_endian.h"
  1983. diff -druN diskdev_cmds-332.14/newfs_hfs.tproj/hfs_endian.h diskdev_cmds-332.14-patched/newfs_hfs.tproj/hfs_endian.h
  1984. --- diskdev_cmds-332.14/newfs_hfs.tproj/hfs_endian.h 2006-02-20 22:45:15.000000000 +0100
  1985. +++ diskdev_cmds-332.14-patched/newfs_hfs.tproj/hfs_endian.h 2008-07-01 22:30:11.000000000 +0200
  1986. @@ -29,7 +29,12 @@
  1987. * volume format.
  1988. */
  1989. #include <hfs/hfs_format.h>
  1990. +#if LINUX
  1991. +#include <endian.h>
  1992. +#include <byteswap.h>
  1993. +#else
  1994. #include <architecture/byte_order.h>
  1995. +#endif
  1996. /*********************/
  1997. /* BIG ENDIAN Macros */
  1998. Files diskdev_cmds-332.14/newfs_hfs.tproj/hfs_endian.o and diskdev_cmds-332.14-patched/newfs_hfs.tproj/hfs_endian.o differ
  1999. diff -druN diskdev_cmds-332.14/newfs_hfs.tproj/Makefile.lnx diskdev_cmds-332.14-patched/newfs_hfs.tproj/Makefile.lnx
  2000. --- diskdev_cmds-332.14/newfs_hfs.tproj/Makefile.lnx 1970-01-01 01:00:00.000000000 +0100
  2001. +++ diskdev_cmds-332.14-patched/newfs_hfs.tproj/Makefile.lnx 2008-07-01 22:30:11.000000000 +0200
  2002. @@ -0,0 +1,12 @@
  2003. +CFILES = hfs_endian.c makehfs.c newfs_hfs.c
  2004. +OFILES = $(CFILES:.c=.o)
  2005. +
  2006. +all: newfs_hfs
  2007. +
  2008. +newfs_hfs: $(OFILES)
  2009. + ${CC} ${CFLAGS} -o newfs_hfs ${OFILES} -lcrypto
  2010. +
  2011. +clean:
  2012. + $(RM) newfs_hfs $(OFILES)
  2013. +
  2014. +.PHONY : FORCE clean
  2015. diff -druN diskdev_cmds-332.14/newfs_hfs.tproj/makehfs.c diskdev_cmds-332.14-patched/newfs_hfs.tproj/makehfs.c
  2016. --- diskdev_cmds-332.14/newfs_hfs.tproj/makehfs.c 2006-02-20 22:45:15.000000000 +0100
  2017. +++ diskdev_cmds-332.14-patched/newfs_hfs.tproj/makehfs.c 2008-07-01 22:36:05.000000000 +0200
  2018. @@ -31,10 +31,16 @@
  2019. #include <sys/param.h>
  2020. #include <sys/types.h>
  2021. #include <sys/time.h>
  2022. +#if LINUX
  2023. +#include <time.h>
  2024. +#include "missing.h"
  2025. +#endif
  2026. #include <sys/errno.h>
  2027. #include <sys/stat.h>
  2028. #include <sys/sysctl.h>
  2029. +#if !LINUX
  2030. #include <sys/vmmeter.h>
  2031. +#endif
  2032. #include <err.h>
  2033. #include <errno.h>
  2034. @@ -47,13 +53,14 @@
  2035. #include <openssl/sha.h>
  2036. +#if !LINUX
  2037. #include <architecture/byte_order.h>
  2038. #include <CoreFoundation/CFString.h>
  2039. #include <CoreFoundation/CFStringEncodingExt.h>
  2040. extern Boolean _CFStringGetFileSystemRepresentation(CFStringRef string, UInt8 *buffer, CFIndex maxBufLen);
  2041. -
  2042. +#endif
  2043. #include <hfs/hfs_format.h>
  2044. #include <hfs/hfs_mount.h>
  2045. @@ -63,7 +70,7 @@
  2046. #include "readme.h"
  2047. -#define HFS_BOOT_DATA "/usr/share/misc/hfsbootdata"
  2048. +#define HFS_BOOT_DATA "/usr/share/hfsprogs/hfsbootdata"
  2049. #define HFS_JOURNAL_FILE ".journal"
  2050. #define HFS_JOURNAL_INFO ".journal_info_block"
  2051. @@ -129,7 +136,9 @@
  2052. static void MarkBitInAllocationBuffer __P((HFSPlusVolumeHeader *header,
  2053. UInt32 allocationBlock, void* sectorBuffer, UInt32 *sector));
  2054. +#if !LINUX
  2055. static UInt32 GetDefaultEncoding();
  2056. +#endif
  2057. static UInt32 UTCToLocal __P((UInt32 utcTime));
  2058. @@ -158,11 +167,14 @@
  2059. #define ROUNDUP(x, u) (((x) % (u) == 0) ? (x) : ((x)/(u) + 1) * (u))
  2060. -#define ENCODING_TO_BIT(e) \
  2061. +#if LINUX
  2062. +#define ENCODING_TO_BIT(e) (e)
  2063. +#else
  2064. +#define ENCODING_TO_BIT(e)
  2065. ((e) < 48 ? (e) : \
  2066. ((e) == kCFStringEncodingMacUkrainian ? 48 : \
  2067. ((e) == kCFStringEncodingMacFarsi ? 49 : 0)))
  2068. -
  2069. +#endif
  2070. /*
  2071. * make_hfs
  2072. *
  2073. @@ -528,6 +540,7 @@
  2074. * Map UTF-8 input into a Mac encoding.
  2075. * On conversion errors "untitled" is used as a fallback.
  2076. */
  2077. +#if !LINUX
  2078. {
  2079. UniChar unibuf[kHFSMaxVolumeNameChars];
  2080. CFStringRef cfstr;
  2081. @@ -553,7 +566,11 @@
  2082. bcopy(&mdbp->drVN[1], defaults->volumeName, mdbp->drVN[0]);
  2083. defaults->volumeName[mdbp->drVN[0]] = '\0';
  2084. }
  2085. +#endif
  2086. /* Save the encoding hint in the Finder Info (field 4). */
  2087. + mdbp->drVN[0] = strlen(defaults->volumeName);
  2088. + bcopy(defaults->volumeName,&mdbp->drVN[1],mdbp->drVN[0]);
  2089. +
  2090. mdbp->drFndrInfo[4] = SET_HFS_TEXT_ENCODING(defaults->encodingHint);
  2091. mdbp->drWrCnt = kWriteSeqNum;
  2092. @@ -1100,9 +1117,11 @@
  2093. UInt16 nodeSize;
  2094. SInt16 offset;
  2095. UInt32 unicodeBytes;
  2096. +#if !LINUX
  2097. UInt8 canonicalName[256];
  2098. CFStringRef cfstr;
  2099. Boolean cfOK;
  2100. +#endif
  2101. int index = 0;
  2102. nodeSize = dp->catalogNodeSize;
  2103. @@ -1122,7 +1141,9 @@
  2104. * First record is always the root directory...
  2105. */
  2106. ckp = (HFSPlusCatalogKey *)((UInt8 *)buffer + offset);
  2107. -
  2108. +#if LINUX
  2109. + ConvertUTF8toUnicode(dp->volumeName, sizeof(ckp->nodeName.unicode), ckp->nodeName.unicode, &ckp->nodeName.length);
  2110. +#else
  2111. /* Use CFString functions to get a HFSPlus Canonical name */
  2112. cfstr = CFStringCreateWithCString(kCFAllocatorDefault, (char *)dp->volumeName, kCFStringEncodingUTF8);
  2113. cfOK = _CFStringGetFileSystemRepresentation(cfstr, canonicalName, sizeof(canonicalName));
  2114. @@ -1139,6 +1160,7 @@
  2115. dp->volumeName, kDefaultVolumeNameStr);
  2116. }
  2117. CFRelease(cfstr);
  2118. +#endif
  2119. ckp->nodeName.length = SWAP_BE16 (ckp->nodeName.length);
  2120. unicodeBytes = sizeof(UniChar) * SWAP_BE16 (ckp->nodeName.length);
  2121. @@ -1821,15 +1843,15 @@
  2122. off_t sector;
  2123. if ((byteCount % driveInfo->sectorSize) != 0)
  2124. - errx(1, "WriteBuffer: byte count %ld is not sector size multiple", byteCount);
  2125. + errx(1, "WriteBuffer: byte count %i is not sector size multiple", byteCount);
  2126. sector = driveInfo->sectorOffset + startingSector;
  2127. if (lseek(driveInfo->fd, sector * driveInfo->sectorSize, SEEK_SET) < 0)
  2128. - err(1, "seek (sector %qd)", sector);
  2129. + err(1, "seek (sector %lld)", sector);
  2130. if (write(driveInfo->fd, buffer, byteCount) != byteCount)
  2131. - err(1, "write (sector %qd, %ld bytes)", sector, byteCount);
  2132. + err(1, "write (sector %lld, %i bytes)", sector, byteCount);
  2133. }
  2134. @@ -1913,7 +1935,7 @@
  2135. return quotient;
  2136. }
  2137. -
  2138. +#if !LINUX
  2139. #define __kCFUserEncodingFileName ("/.CFUserTextEncoding")
  2140. static UInt32
  2141. @@ -1939,7 +1961,7 @@
  2142. }
  2143. return 0;
  2144. }
  2145. -
  2146. +#endif
  2147. static int
  2148. ConvertUTF8toUnicode(const UInt8* source, UInt32 bufsize, UniChar* unibuf,
  2149. @@ -2006,6 +2028,9 @@
  2150. static int
  2151. getencodinghint(unsigned char *name)
  2152. {
  2153. +#if LINUX
  2154. + return(0);
  2155. +#else
  2156. int mib[3];
  2157. size_t buflen = sizeof(int);
  2158. struct vfsconf vfc;
  2159. @@ -2023,7 +2048,8 @@
  2160. return (hint);
  2161. error:
  2162. hint = GetDefaultEncoding();
  2163. - return (hint);
  2164. + return (0);
  2165. +#endif
  2166. }
  2167. @@ -2034,12 +2060,14 @@
  2168. unsigned char digest[20];
  2169. time_t now;
  2170. clock_t uptime;
  2171. - int mib[2];
  2172. - int sysdata;
  2173. - char sysctlstring[128];
  2174. size_t datalen;
  2175. double sysloadavg[3];
  2176. +#if !LINUX
  2177. + int sysdata;
  2178. + int mib[2];
  2179. + char sysctlstring[128];
  2180. struct vmtotal sysvmtotal;
  2181. +#endif
  2182. do {
  2183. /* Initialize the SHA-1 context for processing: */
  2184. @@ -2052,52 +2080,58 @@
  2185. SHA1_Update(&context, &uptime, sizeof(uptime));
  2186. /* The kernel's boot time: */
  2187. +#if !LINUX
  2188. mib[0] = CTL_KERN;
  2189. mib[1] = KERN_BOOTTIME;
  2190. datalen = sizeof(sysdata);
  2191. sysctl(mib, 2, &sysdata, &datalen, NULL, 0);
  2192. SHA1_Update(&context, &sysdata, datalen);
  2193. -
  2194. +#endif
  2195. /* The system's host id: */
  2196. +#if !LINUX
  2197. mib[0] = CTL_KERN;
  2198. mib[1] = KERN_HOSTID;
  2199. datalen = sizeof(sysdata);
  2200. sysctl(mib, 2, &sysdata, &datalen, NULL, 0);
  2201. SHA1_Update(&context, &sysdata, datalen);
  2202. -
  2203. +#endif
  2204. /* The system's host name: */
  2205. +#if !LINUX
  2206. mib[0] = CTL_KERN;
  2207. mib[1] = KERN_HOSTNAME;
  2208. datalen = sizeof(sysctlstring);
  2209. sysctl(mib, 2, sysctlstring, &datalen, NULL, 0);
  2210. SHA1_Update(&context, sysctlstring, datalen);
  2211. -
  2212. +#endif
  2213. /* The running kernel's OS release string: */
  2214. +#if !LINUX
  2215. mib[0] = CTL_KERN;
  2216. mib[1] = KERN_OSRELEASE;
  2217. datalen = sizeof(sysctlstring);
  2218. sysctl(mib, 2, sysctlstring, &datalen, NULL, 0);
  2219. SHA1_Update(&context, sysctlstring, datalen);
  2220. -
  2221. +#endif
  2222. /* The running kernel's version string: */
  2223. +#if !LINUX
  2224. mib[0] = CTL_KERN;
  2225. mib[1] = KERN_VERSION;
  2226. datalen = sizeof(sysctlstring);
  2227. sysctl(mib, 2, sysctlstring, &datalen, NULL, 0);
  2228. SHA1_Update(&context, sysctlstring, datalen);
  2229. -
  2230. +#endif
  2231. /* The system's load average: */
  2232. datalen = sizeof(sysloadavg);
  2233. getloadavg(sysloadavg, 3);
  2234. SHA1_Update(&context, &sysloadavg, datalen);
  2235. /* The system's VM statistics: */
  2236. +#if !LINUX
  2237. mib[0] = CTL_VM;
  2238. mib[1] = VM_METER;
  2239. datalen = sizeof(sysvmtotal);
  2240. sysctl(mib, 2, &sysvmtotal, &datalen, NULL, 0);
  2241. SHA1_Update(&context, &sysvmtotal, datalen);
  2242. -
  2243. +#endif
  2244. /* The current GMT (26 ASCII characters): */
  2245. time(&now);
  2246. strncpy(randomInputBuffer, asctime(gmtime(&now)), 26); /* "Mon Mar 27 13:46:26 2000" */
  2247. Files diskdev_cmds-332.14/newfs_hfs.tproj/makehfs.o and diskdev_cmds-332.14-patched/newfs_hfs.tproj/makehfs.o differ
  2248. Files diskdev_cmds-332.14/newfs_hfs.tproj/newfs_hfs and diskdev_cmds-332.14-patched/newfs_hfs.tproj/newfs_hfs differ
  2249. diff -druN diskdev_cmds-332.14/newfs_hfs.tproj/newfs_hfs.8 diskdev_cmds-332.14-patched/newfs_hfs.tproj/newfs_hfs.8
  2250. --- diskdev_cmds-332.14/newfs_hfs.tproj/newfs_hfs.8 2006-02-20 22:45:15.000000000 +0100
  2251. +++ diskdev_cmds-332.14-patched/newfs_hfs.tproj/newfs_hfs.8 2008-07-01 22:35:53.000000000 +0200
  2252. @@ -93,7 +93,7 @@
  2253. option followed by a comma
  2254. separated list of the form arg=blocks.
  2255. .Pp
  2256. -Example: -c c=5000,e=500
  2257. +Example: \-c c=5000,e=500
  2258. .Bl -tag -width Fl
  2259. .It Em a=blocks
  2260. Set the attribute file clump size.
  2261. @@ -126,7 +126,7 @@
  2262. size must be a power of two and no larger than
  2263. 32768 bytes.
  2264. .Pp
  2265. -Example: -n c=8192,e=4096
  2266. +Example: \-n c=8192,e=4096
  2267. .Bl -tag -width Fl
  2268. .It Em a=bytes
  2269. Set the attribute b-tree node size.
  2270. diff -druN diskdev_cmds-332.14/newfs_hfs.tproj/newfs_hfs.c diskdev_cmds-332.14-patched/newfs_hfs.tproj/newfs_hfs.c
  2271. --- diskdev_cmds-332.14/newfs_hfs.tproj/newfs_hfs.c 2006-02-20 22:45:15.000000000 +0100
  2272. +++ diskdev_cmds-332.14-patched/newfs_hfs.tproj/newfs_hfs.c 2008-07-01 22:30:11.000000000 +0200
  2273. @@ -38,8 +38,13 @@
  2274. #include <sys/mount.h>
  2275. #include <sys/param.h>
  2276. #include <sys/stat.h>
  2277. +#if LINUX
  2278. +#include <time.h>
  2279. +#endif
  2280. +#if !LINUX
  2281. #include <IOKit/storage/IOMediaBSDClient.h>
  2282. +#endif
  2283. #include <hfs/hfs_format.h>
  2284. #include "newfs_hfs.h"
  2285. @@ -73,7 +78,9 @@
  2286. char *progname;
  2287. char gVolumeName[kHFSPlusMaxFileNameChars + 1] = {kDefaultVolumeNameStr};
  2288. -char rawdevice[MAXPATHLEN];
  2289. +#if !LINUX
  2290. +char rawdevice[MAXPATHLEN];
  2291. +#endif
  2292. char blkdevice[MAXPATHLEN];
  2293. UInt32 gBlockSize = 0;
  2294. UInt32 gNextCNID = kHFSFirstUserCatalogNodeID;
  2295. @@ -137,8 +144,10 @@
  2296. extern int optind;
  2297. int ch;
  2298. int forceHFS;
  2299. +#if !LINUX
  2300. char *cp, *special;
  2301. struct statfs *mp;
  2302. +#endif
  2303. int n;
  2304. if ((progname = strrchr(*argv, '/')))
  2305. @@ -238,7 +247,9 @@
  2306. if (argc != 1)
  2307. usage();
  2308. -
  2309. +#if LINUX
  2310. + (void) sprintf(blkdevice, "%s", argv[0]);
  2311. +#else
  2312. special = argv[0];
  2313. cp = strrchr(special, '/');
  2314. if (cp != 0)
  2315. @@ -247,6 +258,7 @@
  2316. special++;
  2317. (void) sprintf(rawdevice, "%sr%s", _PATH_DEV, special);
  2318. (void) sprintf(blkdevice, "%s%s", _PATH_DEV, special);
  2319. +#endif
  2320. if (forceHFS && gJournaled) {
  2321. fprintf(stderr, "-h -J: incompatible options specified\n");
  2322. @@ -268,6 +280,9 @@
  2323. /*
  2324. * Check if target device is aready mounted
  2325. */
  2326. +#if LINUX
  2327. + // FIXME
  2328. +#else
  2329. n = getmntinfo(&mp, MNT_NOWAIT);
  2330. if (n == 0)
  2331. fatal("%s: getmntinfo: %s", blkdevice, strerror(errno));
  2332. @@ -277,14 +292,19 @@
  2333. fatal("%s is mounted on %s", blkdevice, mp->f_mntonname);
  2334. ++mp;
  2335. }
  2336. +#endif
  2337. - if (hfs_newfs(rawdevice, forceHFS, true) < 0) {
  2338. + if (hfs_newfs(blkdevice, forceHFS, true) < 0) {
  2339. +#if LINUX
  2340. + err(1, NULL);
  2341. +#else
  2342. /* On ENXIO error use the block device (to get de-blocking) */
  2343. if (errno == ENXIO) {
  2344. if (hfs_newfs(blkdevice, forceHFS, false) < 0)
  2345. err(1, NULL);
  2346. } else
  2347. err(1, NULL);
  2348. +#endif
  2349. }
  2350. exit(0);
  2351. @@ -458,7 +478,7 @@
  2352. fatal("%s: block size is too small for %lld sectors", optarg, gBlockSize, sectorCount);
  2353. if (gBlockSize < HFSOPTIMALBLKSIZE)
  2354. - warnx("Warning: %ld is a non-optimal block size (4096 would be a better choice)", gBlockSize);
  2355. + warnx("Warning: %i is a non-optimal block size (4096 would be a better choice)", gBlockSize);
  2356. }
  2357. }
  2358. @@ -472,7 +492,9 @@
  2359. int fso = 0;
  2360. int retval = 0;
  2361. hfsparams_t defaults = {0};
  2362. +#if !LINUX
  2363. u_int64_t maxSectorsPerIO;
  2364. +#endif
  2365. if (gNoCreate) {
  2366. fso = open( device, O_RDONLY | O_NDELAY, 0 );
  2367. @@ -485,7 +507,33 @@
  2368. if (fstat( fso, &stbuf) < 0)
  2369. fatal("%s: %s", device, strerror(errno));
  2370. +#if LINUX
  2371. + dip.sectorSize = 512;
  2372. + dip.sectorsPerIO = 256;
  2373. +#ifndef BLKGETSIZE
  2374. +#define BLKGETSIZE _IO(0x12,96)
  2375. +#endif
  2376. +#ifndef BLKGETSIZE64
  2377. +#define BLKGETSIZE64 _IOR(0x12,114,size_t)
  2378. +#endif
  2379. +
  2380. + if (S_ISREG(stbuf.st_mode)) {
  2381. + dip.totalSectors = stbuf.st_size / 512;
  2382. + }
  2383. + else if (S_ISBLK(stbuf.st_mode)) {
  2384. + unsigned long size;
  2385. + u_int64_t size64;
  2386. + if (!ioctl(fso, BLKGETSIZE64, &size64))
  2387. + dip.totalSectors = size64 / 512;
  2388. + else if (!ioctl(fso, BLKGETSIZE, &size))
  2389. + dip.totalSectors = size;
  2390. + else
  2391. + fatal("%s: %s", device, strerror(errno));
  2392. + }
  2393. + else
  2394. + fatal("%s: is not a block device", device);
  2395. +#else
  2396. if (ioctl(fso, DKIOCGETBLOCKCOUNT, &dip.totalSectors) < 0)
  2397. fatal("%s: %s", device, strerror(errno));
  2398. @@ -493,14 +541,17 @@
  2399. fatal("%s: %s", device, strerror(errno));
  2400. if (ioctl(fso, DKIOCGETMAXBLOCKCOUNTWRITE, &maxSectorsPerIO) < 0)
  2401. - dip.sectorsPerIO = (128 * 1024) / dip.sectorSize; /* use 128K as default */
  2402. + dip.sectorsPerIO = (128 * 1024) / dip.sectorSize; /* use 128K as default */
  2403. else
  2404. dip.sectorsPerIO = MIN(maxSectorsPerIO, (1024 * 1024) / dip.sectorSize);
  2405. +#endif
  2406. +
  2407. /*
  2408. - * The make_hfs code currentlydoes 512 byte sized I/O.
  2409. + * The make_hfs code currently does 512 byte sized I/O.
  2410. * If the sector size is bigger than 512, start over
  2411. * using the block device (to get de-blocking).
  2412. */
  2413. +#if !LINUX
  2414. if (dip.sectorSize != kBytesPerSector) {
  2415. if (isRaw) {
  2416. close(fso);
  2417. @@ -515,7 +566,8 @@
  2418. dip.sectorSize = kBytesPerSector;
  2419. }
  2420. }
  2421. -
  2422. +#endif
  2423. +
  2424. dip.fd = fso;
  2425. dip.sectorOffset = 0;
  2426. time(&createtime);
  2427. @@ -693,7 +745,7 @@
  2428. defaults->catalogClumpSize = clumpSize;
  2429. defaults->catalogNodeSize = catnodesiz;
  2430. if (gBlockSize < 4096 && gBlockSize < catnodesiz)
  2431. - warnx("Warning: block size %ld is less than catalog b-tree node size %ld", gBlockSize, catnodesiz);
  2432. + warnx("Warning: block size %i is less than catalog b-tree node size %i", gBlockSize, catnodesiz);
  2433. if (extclumpblks == 0) {
  2434. clumpSize = CalcHFSPlusBTreeClumpSize(gBlockSize, extnodesiz, sectorCount, FALSE);
  2435. @@ -706,7 +758,7 @@
  2436. defaults->extentsClumpSize = clumpSize;
  2437. defaults->extentsNodeSize = extnodesiz;
  2438. if (gBlockSize < extnodesiz)
  2439. - warnx("Warning: block size %ld is less than extents b-tree node size %ld", gBlockSize, extnodesiz);
  2440. + warnx("Warning: block size %i is less than extents b-tree node size %i", gBlockSize, extnodesiz);
  2441. if (atrclumpblks == 0) {
  2442. clumpSize = 0;
  2443. @@ -754,22 +806,22 @@
  2444. if (gNoCreate) {
  2445. if (!gWrapper)
  2446. - printf("%qd sectors (%lu bytes per sector)\n", sectorCount, sectorSize);
  2447. + printf("%lld sectors (%u bytes per sector)\n", sectorCount, sectorSize);
  2448. printf("HFS Plus format parameters:\n");
  2449. printf("\tvolume name: \"%s\"\n", gVolumeName);
  2450. - printf("\tblock-size: %lu\n", defaults->blockSize);
  2451. - printf("\ttotal blocks: %lu\n", totalBlocks);
  2452. + printf("\tblock-size: %u\n", defaults->blockSize);
  2453. + printf("\ttotal blocks: %u\n", totalBlocks);
  2454. if (gJournaled)
  2455. printf("\tjournal-size: %dk\n", (int)defaults->journalSize/1024);
  2456. - printf("\tfirst free catalog node id: %lu\n", defaults->nextFreeFileID);
  2457. - printf("\tcatalog b-tree node size: %lu\n", defaults->catalogNodeSize);
  2458. - printf("\tinitial catalog file size: %lu\n", defaults->catalogClumpSize);
  2459. - printf("\textents b-tree node size: %lu\n", defaults->extentsNodeSize);
  2460. - printf("\tinitial extents file size: %lu\n", defaults->extentsClumpSize);
  2461. - printf("\tinitial allocation file size: %lu (%lu blocks)\n",
  2462. + printf("\tfirst free catalog node id: %u\n", defaults->nextFreeFileID);
  2463. + printf("\tcatalog b-tree node size: %u\n", defaults->catalogNodeSize);
  2464. + printf("\tinitial catalog file size: %u\n", defaults->catalogClumpSize);
  2465. + printf("\textents b-tree node size: %u\n", defaults->extentsNodeSize);
  2466. + printf("\tinitial extents file size: %u\n", defaults->extentsClumpSize);
  2467. + printf("\tinitial allocation file size: %u (%u blocks)\n",
  2468. defaults->allocationClumpSize, defaults->allocationClumpSize / gBlockSize);
  2469. - printf("\tdata fork clump size: %lu\n", defaults->dataClumpSize);
  2470. - printf("\tresource fork clump size: %lu\n", defaults->rsrcClumpSize);
  2471. + printf("\tdata fork clump size: %u\n", defaults->dataClumpSize);
  2472. + printf("\tresource fork clump size: %u\n", defaults->rsrcClumpSize);
  2473. if (defaults->flags & kUseAccessPerms) {
  2474. printf("\tuser ID: %d\n", (int)defaults->owner);
  2475. printf("\tgroup ID: %d\n", (int)defaults->group);
  2476. @@ -844,17 +896,17 @@
  2477. }
  2478. if (gNoCreate) {
  2479. - printf("%ld sectors at %ld bytes per sector\n", sectorCount, sectorSize);
  2480. + printf("%i sectors at %i bytes per sector\n", sectorCount, sectorSize);
  2481. printf("%s format parameters:\n", gWrapper ? "HFS Wrapper" : "HFS");
  2482. printf("\tvolume name: \"%s\"\n", gVolumeName);
  2483. - printf("\tblock-size: %ld\n", defaults->blockSize);
  2484. - printf("\ttotal blocks: %ld\n", sectorCount / (alBlkSize / sectorSize) );
  2485. - printf("\tfirst free catalog node id: %ld\n", defaults->nextFreeFileID);
  2486. - printf("\tinitial catalog file size: %ld\n", defaults->catalogClumpSize);
  2487. - printf("\tinitial extents file size: %ld\n", defaults->extentsClumpSize);
  2488. - printf("\tfile clump size: %ld\n", defaults->dataClumpSize);
  2489. + printf("\tblock-size: %i\n", defaults->blockSize);
  2490. + printf("\ttotal blocks: %i\n", sectorCount / (alBlkSize / sectorSize) );
  2491. + printf("\tfirst free catalog node id: %i\n", defaults->nextFreeFileID);
  2492. + printf("\tinitial catalog file size: %i\n", defaults->catalogClumpSize);
  2493. + printf("\tinitial extents file size: %i\n", defaults->extentsClumpSize);
  2494. + printf("\tfile clump size: %i\n", defaults->dataClumpSize);
  2495. if (hfsgrowblks)
  2496. - printf("\twrapper growable from %ld to %ld sectors\n", sectorCount, hfsgrowblks);
  2497. + printf("\twrapper growable from %i to %i sectors\n", sectorCount, hfsgrowblks);
  2498. }
  2499. }
  2500. diff -druN diskdev_cmds-332.14/newfs_hfs.tproj/newfs_hfs.h diskdev_cmds-332.14-patched/newfs_hfs.tproj/newfs_hfs.h
  2501. --- diskdev_cmds-332.14/newfs_hfs.tproj/newfs_hfs.h 2006-02-20 22:45:15.000000000 +0100
  2502. +++ diskdev_cmds-332.14-patched/newfs_hfs.tproj/newfs_hfs.h 2008-07-01 22:30:11.000000000 +0200
  2503. @@ -19,8 +19,12 @@
  2504. *
  2505. * @APPLE_LICENSE_HEADER_END@
  2506. */
  2507. -
  2508. -#include <CoreFoundation/CFBase.h>
  2509. +
  2510. +#if LINUX
  2511. +#include "missing.h"
  2512. +#else
  2513. +#include <CoreFoundation/CFBase.h>*/
  2514. +#endif
  2515. /*
  2516. * Mac OS Finder flags
  2517. @@ -122,33 +126,33 @@
  2518. #define kDTDF_FileID 16
  2519. #define kDTDF_Name "Desktop DF"
  2520. #define kDTDF_Chars 10
  2521. -#define kDTDF_Type 'DTFL'
  2522. -#define kDTDF_Creator 'DMGR'
  2523. +#define kDTDF_Type 0x4454464C /* 'DTFL' */
  2524. +#define kDTDF_Creator 0x444D4752 /* 'DMGR' */
  2525. #define kDTDB_FileID 17
  2526. #define kDTDB_Name "Desktop DB"
  2527. #define kDTDB_Chars 10
  2528. -#define kDTDB_Type 'BTFL'
  2529. -#define kDTDB_Creator 'DMGR'
  2530. +#define kDTDB_Type 0x4254464C /* 'BTFL' */
  2531. +#define kDTDB_Creator 0x444D4752 /* 'DMGR' */
  2532. #define kDTDB_Size 1024
  2533. #define kReadMe_FileID 18
  2534. #define kReadMe_Name "ReadMe"
  2535. #define kReadMe_Chars 6
  2536. -#define kReadMe_Type 'ttro'
  2537. -#define kReadMe_Creator 'ttxt'
  2538. +#define kReadMe_Type 0x7474726F /* 'ttro' */
  2539. +#define kReadMe_Creator 0x74747974 /* 'ttxt' */
  2540. #define kFinder_FileID 19
  2541. #define kFinder_Name "Finder"
  2542. #define kFinder_Chars 6
  2543. -#define kFinder_Type 'FNDR'
  2544. -#define kFinder_Creator 'MACS'
  2545. +#define kFinder_Type 0x464E4452 /* 'FNDR' */
  2546. +#define kFinder_Creator 0x4D414353 /* 'MACS' */
  2547. #define kSystem_FileID 20
  2548. #define kSystem_Name "System"
  2549. #define kSystem_Chars 6
  2550. -#define kSystem_Type 'zsys'
  2551. -#define kSystem_Creator 'MACS'
  2552. +#define kSystem_Type 0x7A737973 /* 'zsys' */
  2553. +#define kSystem_Creator 0x4D414353 /* 'MACS' */
  2554. Files diskdev_cmds-332.14/newfs_hfs.tproj/newfs_hfs.o and diskdev_cmds-332.14-patched/newfs_hfs.tproj/newfs_hfs.o differ