blob: e65cb765caf10c68e771611dd8f696bc6e50b15d [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From: =?UTF-8?q?Rog=C3=A9rio=20Brito?= <rbrito@ime.usp.br>
2Date: Thu, 24 Oct 2013 01:11:21 -0200
3Subject: Add/exclude Darwin-specific code
4
5Modify some of the files so that they can be compiled without the
6Apple owned frameworks in a Debian system (and possibly others).
7---
8 fsck_hfs.tproj/cache.c | 4 ++
9 fsck_hfs.tproj/dfalib/BTree.c | 2 +
10 fsck_hfs.tproj/dfalib/BlockCache.c | 3 +
11 fsck_hfs.tproj/dfalib/SBTree.c | 2 +
12 fsck_hfs.tproj/dfalib/SDevice.c | 92 ++++++++++++++++++++---------
13 fsck_hfs.tproj/dfalib/SKeyCompare.c | 2 +
14 fsck_hfs.tproj/dfalib/SRepair.c | 2 +
15 fsck_hfs.tproj/dfalib/SRuntime.h | 7 ++-
16 fsck_hfs.tproj/dfalib/SUtils.c | 5 +-
17 fsck_hfs.tproj/dfalib/SVerify2.c | 7 +++
18 fsck_hfs.tproj/dfalib/Scavenger.h | 11 +++-
19 fsck_hfs.tproj/dfalib/hfs_endian.c | 4 ++
20 fsck_hfs.tproj/dfalib/hfs_endian.h | 7 ++-
21 fsck_hfs.tproj/fsck_hfs.c | 61 +++++++++++++++----
22 fsck_hfs.tproj/utilities.c | 8 ++-
23 include/missing.h | 115 ++++++++++++++++++++++++++++++++++++
24 newfs_hfs.tproj/hfs_endian.c | 5 ++
25 newfs_hfs.tproj/hfs_endian.h | 5 ++
26 newfs_hfs.tproj/makehfs.c | 72 ++++++++++++++++------
27 newfs_hfs.tproj/newfs_hfs.c | 74 ++++++++++++++++++++---
28 newfs_hfs.tproj/newfs_hfs.h | 26 ++++----
29 21 files changed, 429 insertions(+), 85 deletions(-)
30 create mode 100644 include/missing.h
31
32--- a/fsck_hfs.tproj/cache.c
33+++ b/fsck_hfs.tproj/cache.c
34@@ -26,7 +26,11 @@
35 #include <stdlib.h>
36 #include <sys/mman.h>
37 #include <sys/stat.h>
38+#if LINUX
39+#include "missing.h"
40+#else
41 #include <sys/types.h>
42+#endif /* __LINUX__ */
43 #include <sys/uio.h>
44 #include <unistd.h>
45 #include <string.h>
46--- a/fsck_hfs.tproj/dfalib/BTree.c
47+++ b/fsck_hfs.tproj/dfalib/BTree.c
48@@ -1705,7 +1705,9 @@ OSStatus BTGetInformation (SFCB *fil
49 UInt16 version,
50 BTreeInfoRec *info )
51 {
52+#if !LINUX
53 #pragma unused (version)
54+#endif
55
56 BTreeControlBlockPtr btreePtr;
57
58--- a/fsck_hfs.tproj/dfalib/BlockCache.c
59+++ b/fsck_hfs.tproj/dfalib/BlockCache.c
60@@ -20,6 +20,9 @@
61 * @APPLE_LICENSE_HEADER_END@
62 */
63
64+#if LINUX
65+#include "missing.h"
66+#endif
67 #include "SRuntime.h"
68 #include "Scavenger.h"
69 #include "../cache.h"
70--- a/fsck_hfs.tproj/dfalib/SBTree.c
71+++ b/fsck_hfs.tproj/dfalib/SBTree.c
72@@ -322,7 +322,9 @@ ErrorExit:
73 OSStatus
74 SetEndOfForkProc ( SFCB *filePtr, FSSize minEOF, FSSize maxEOF )
75 {
76+#if !LINUX
77 #pragma unused (maxEOF)
78+#endif
79
80 OSStatus result;
81 UInt32 actualSectorsAdded;
82--- a/fsck_hfs.tproj/dfalib/SDevice.c
83+++ b/fsck_hfs.tproj/dfalib/SDevice.c
84@@ -2,7 +2,7 @@
85 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
86 *
87 * @APPLE_LICENSE_HEADER_START@
88- *
89+ *
90 * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
91 * Reserved. This file contains Original Code and/or Modifications of
92 * Original Code as defined in and that are subject to the Apple Public
93@@ -10,7 +10,7 @@
94 * except in compliance with the License. Please obtain a copy of the
95 * License at http://www.apple.com/publicsource and read it before using
96 * this file.
97- *
98+ *
99 * The Original Code and all software distributed under the License are
100 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
101 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
102@@ -18,7 +18,7 @@
103 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
104 * License for the specific language governing rights and limitations
105 * under the License."
106- *
107+ *
108 * @APPLE_LICENSE_HEADER_END@
109 */
110 #include "SRuntime.h"
111@@ -28,33 +28,71 @@
112 #include <unistd.h>
113 #include <errno.h>
114 #include <sys/ioctl.h>
115-
116+#if LINUX
117+#include <fcntl.h>
118+#include <sys/stat.h>
119+#else
120 #include <IOKit/storage/IOMediaBSDClient.h>
121-
122+#endif /* LINUX */
123 #else
124-
125 #include <Files.h>
126 #include <Device.h>
127 #include <Disks.h>
128
129 #endif
130
131-
132 OSErr GetDeviceSize(int driveRefNum, UInt64 *numBlocks, UInt32 *blockSize)
133 {
134 #if BSD
135 UInt64 devBlockCount = 0;
136 int devBlockSize = 0;
137+#if LINUX
138+ struct stat stbuf;
139+
140+ devBlockSize = 512;
141
142+#ifndef BLKGETSIZE
143+#define BLKGETSIZE _IO(0x12,96)
144+#endif
145+#ifndef BLKGETSIZE64
146+#define BLKGETSIZE64 _IOR(0x12,114,size_t)
147+#endif
148+ if (fstat(driveRefNum, &stbuf) < 0){
149+ printf("Error: %s\n", strerror(errno));
150+ return(-1);
151+ }
152+
153+ if (S_ISREG(stbuf.st_mode)) {
154+ devBlockCount = stbuf.st_size / 512;
155+ }
156+ else if (S_ISBLK(stbuf.st_mode)) {
157+ unsigned long size;
158+ u_int64_t size64;
159+ if (!ioctl(driveRefNum, BLKGETSIZE64, &size64))
160+ devBlockCount = size64 / 512;
161+ else if (!ioctl(driveRefNum, BLKGETSIZE, &size))
162+ devBlockCount = size;
163+ else{
164+ printf("Error: %s\n", strerror(errno));
165+ return(-1);
166+ }
167+
168+ }
169+ else{
170+ printf("Device is not a block device");
171+ return(-1);
172+ }
173+#elif BSD
174 if (ioctl(driveRefNum, DKIOCGETBLOCKCOUNT, &devBlockCount) < 0) {
175 printf("ioctl(DKIOCGETBLOCKCOUNT) for fd %d: %s\n", driveRefNum, strerror(errno));
176 return (-1);
177 }
178-
179+
180 if (ioctl(driveRefNum, DKIOCGETBLOCKSIZE, &devBlockSize) < 0) {
181 printf("ioctl(DKIOCGETBLOCKSIZE) for fd %d: %s\n", driveRefNum, strerror(errno));
182 return (-1);
183 }
184+#endif /* BSD */
185
186 if (devBlockSize != 512) {
187 *numBlocks = (devBlockCount * (UInt64)devBlockSize) / 512;
188@@ -70,24 +108,24 @@ OSErr GetDeviceSize(int driveRefNum, UIn
189 {
190 /* return format list status code */
191 kFmtLstCode = 6,
192-
193+
194 /* reference number of .SONY driver */
195 kSonyRefNum = 0xfffb,
196-
197+
198 /* values returned by DriveStatus in DrvSts.twoSideFmt */
199 kSingleSided = 0,
200 kDoubleSided = -1,
201 kSingleSidedSize = 800, /* 400K */
202 kDoubleSidedSize = 1600, /* 800K */
203-
204+
205 /* values in DrvQEl.qType */
206 kWordDrvSiz = 0,
207 kLongDrvSiz = 1,
208-
209+
210 /* more than enough formatListRecords */
211 kMaxFormatListRecs = 16
212 };
213-
214+
215 ParamBlockRec pb;
216 FormatListRec formatListRecords[kMaxFormatListRecs];
217 DrvSts status;
218@@ -95,22 +133,22 @@ OSErr GetDeviceSize(int driveRefNum, UIn
219 OSErr result;
220 unsigned long blocks = 0;
221
222-
223+
224 /* Attempt to get the drive's format list. */
225 /* (see the Technical Note "What Your Sony Drives For You") */
226-
227+
228 pb.cntrlParam.ioVRefNum = driveQElementPtr->dQDrive;
229 pb.cntrlParam.ioCRefNum = driveQElementPtr->dQRefNum;
230 pb.cntrlParam.csCode = kFmtLstCode;
231 pb.cntrlParam.csParam[0] = kMaxFormatListRecs;
232 *(long *)&pb.cntrlParam.csParam[1] = (long)&formatListRecords[0];
233-
234+
235 result = PBStatusSync(&pb);
236-
237+
238 if ( result == noErr )
239 {
240 /* The drive supports ReturnFormatList status call. */
241-
242+
243 /* Get the current disk's size. */
244 for( formatListRecIndex = 0;
245 formatListRecIndex < pb.cntrlParam.csParam[0];
246@@ -131,7 +169,7 @@ OSErr GetDeviceSize(int driveRefNum, UIn
247 else if ( driveQElementPtr->dQRefNum == (short)kSonyRefNum )
248 {
249 /* The drive is a non-SuperDrive floppy which only supports 400K and 800K disks */
250-
251+
252 result = DriveStatus(driveQElementPtr->dQDrive, &status);
253 if ( result == noErr )
254 {
255@@ -140,11 +178,11 @@ OSErr GetDeviceSize(int driveRefNum, UIn
256 case kSingleSided:
257 blocks = kSingleSidedSize;
258 break;
259-
260+
261 case kDoubleSided:
262 blocks = kDoubleSidedSize;
263 break;
264-
265+
266 default: // This should never happen
267 result = paramErr;
268 break;
269@@ -155,20 +193,20 @@ OSErr GetDeviceSize(int driveRefNum, UIn
270 {
271 /* The drive is not a floppy and it doesn't support ReturnFormatList */
272 /* so use the dQDrvSz field(s) */
273-
274+
275 result = noErr; /* reset result */
276-
277+
278 switch ( driveQElementPtr->qType )
279 {
280 case kWordDrvSiz:
281 blocks = driveQElementPtr->dQDrvSz;
282 break;
283-
284+
285 case kLongDrvSiz:
286 blocks = ((unsigned long)driveQElementPtr->dQDrvSz2 << 16) +
287 driveQElementPtr->dQDrvSz;
288 break;
289-
290+
291 default: // This should never happen
292 result = paramErr;
293 break;
294@@ -177,7 +215,7 @@ OSErr GetDeviceSize(int driveRefNum, UIn
295
296 *numBlocks = blocks;
297 *blockSize = 512;
298-
299+
300 return( result );
301 #endif
302 }
303@@ -188,7 +226,7 @@ OSErr DeviceRead(int device, int drive,
304 #if BSD
305 off_t seek_off;
306 ssize_t nbytes;
307-
308+
309 *actBytes = 0;
310
311 seek_off = lseek(device, offset, SEEK_SET);
312--- a/fsck_hfs.tproj/dfalib/SKeyCompare.c
313+++ b/fsck_hfs.tproj/dfalib/SKeyCompare.c
314@@ -454,7 +454,9 @@ SInt32 CompareExtentKeysPlus( const HFSP
315 * The name portion of the key is compared using a 16-bit binary comparison.
316 * This is called from the b-tree code.
317 */
318+#if !LINUX
319 __private_extern__
320+#endif
321 SInt32
322 CompareAttributeKeys(const AttributeKey *searchKey, const AttributeKey *trialKey)
323 {
324--- a/fsck_hfs.tproj/dfalib/SRepair.c
325+++ b/fsck_hfs.tproj/dfalib/SRepair.c
326@@ -1617,7 +1617,9 @@ Output:
327
328 static OSErr FixWrapperExtents( SGlobPtr GPtr, RepairOrderPtr p )
329 {
330+#if !LINUX
331 #pragma unused (p)
332+#endif
333
334 OSErr err;
335 HFSMasterDirectoryBlock *mdb;
336--- a/fsck_hfs.tproj/dfalib/SRuntime.h
337+++ b/fsck_hfs.tproj/dfalib/SRuntime.h
338@@ -27,8 +27,11 @@
339 #define __SRUNTIME__
340
341 #if BSD
342-
343+#if LINUX
344+#include "missing.h"
345+#else
346 #include <sys/types.h>
347+#endif
348 #include <stdlib.h>
349 #include <string.h>
350 #include <stdio.h>
351@@ -91,10 +94,12 @@ typedef const unsigned char * ConstStr25
352
353 typedef u_int32_t HFSCatalogNodeID;
354
355+#if !LINUX
356 enum {
357 false = 0,
358 true = 1
359 };
360+#endif
361
362 /* OS error codes */
363 enum {
364--- a/fsck_hfs.tproj/dfalib/SUtils.c
365+++ b/fsck_hfs.tproj/dfalib/SUtils.c
366@@ -380,7 +380,8 @@ void InvalidateCalculatedVolumeBitMap( S
367 // GPtr->realVCB Real in-memory vcb
368 //------------------------------------------------------------------------------
369
370-#if !BSD
371+#if BSD
372+#if !LINUX
373 OSErr GetVolumeFeatures( SGlobPtr GPtr )
374 {
375 OSErr err;
376@@ -418,7 +419,7 @@ OSErr GetVolumeFeatures( SGlobPtr GPtr )
377 return( noErr );
378 }
379 #endif
380-
381+#endif
382
383
384 /*-------------------------------------------------------------------------------
385--- a/fsck_hfs.tproj/dfalib/SVerify2.c
386+++ b/fsck_hfs.tproj/dfalib/SVerify2.c
387@@ -32,7 +32,9 @@
388 */
389
390 #include <sys/ioctl.h>
391+#if !LINUX
392 #include <sys/disk.h>
393+#endif
394
395 #include "BTree.h"
396 #include "BTreePrivate.h"
397@@ -1354,8 +1356,13 @@ OSErr CompareVolumeHeader( SGlobPtr GPtr
398 * clump size for read-only media is irrelevant we skip the clump size
399 * check to avoid non useful warnings.
400 */
401+#if LINUX
402+ // FIXME
403+ isWriteable = 1;
404+#else
405 isWriteable = 0;
406 ioctl( GPtr->DrvNum, DKIOCISWRITABLE, &isWriteable );
407+#endif
408 if ( isWriteable != 0 &&
409 volumeHeader->catalogFile.clumpSize != vcb->vcbCatalogFile->fcbClumpSize ) {
410 PrintError(GPtr, E_InvalidClumpSize, 0);
411--- a/fsck_hfs.tproj/dfalib/Scavenger.h
412+++ b/fsck_hfs.tproj/dfalib/Scavenger.h
413@@ -37,11 +37,16 @@
414 #include "../fsck_debug.h"
415
416 #include <assert.h>
417+#if LINUX
418+#define XATTR_MAXNAMELEN 127
419+#include <limits.h>
420+#else
421 #include <sys/xattr.h>
422 #include <sys/acl.h>
423 #include <sys/kauth.h>
424-#include <sys/errno.h>
425 #include <sys/syslimits.h>
426+#endif
427+#include <sys/errno.h>
428
429 #ifdef __cplusplus
430 extern "C" {
431@@ -1465,4 +1470,8 @@ extern int AllocateContigBitmapBits (SV
432 };
433 #endif
434
435+/* #if LINUX
436+#undef XATTR_MAXNAMELEN
437+#endif */
438+
439 #endif /* __SCAVENGER__ */
440--- a/fsck_hfs.tproj/dfalib/hfs_endian.c
441+++ b/fsck_hfs.tproj/dfalib/hfs_endian.c
442@@ -31,7 +31,11 @@
443 #include <sys/types.h>
444 #include <sys/stat.h>
445
446+#if LINUX
447+#include "missing.h"
448+#else
449 #include <architecture/byte_order.h>
450+#endif
451 #include <hfs/hfs_format.h>
452
453 #include "Scavenger.h"
454--- a/fsck_hfs.tproj/dfalib/hfs_endian.h
455+++ b/fsck_hfs.tproj/dfalib/hfs_endian.h
456@@ -27,9 +27,14 @@
457 *
458 * This file prototypes endian swapping routines for the HFS/HFS Plus
459 * volume format.
460- */
461+*/
462 #include <hfs/hfs_format.h>
463+#if LINUX
464+#include <endian.h>
465+#include <byteswap.h>
466+#else
467 #include <architecture/byte_order.h>
468+#endif
469 #include "SRuntime.h"
470
471 /*********************/
472--- a/fsck_hfs.tproj/fsck_hfs.c
473+++ b/fsck_hfs.tproj/fsck_hfs.c
474@@ -24,10 +24,14 @@
475 #include <sys/types.h>
476 #include <sys/stat.h>
477 #include <sys/param.h>
478+#if !LINUX
479 #include <sys/ucred.h>
480+#endif
481 #include <sys/mount.h>
482 #include <sys/ioctl.h>
483+#if !LINUX
484 #include <sys/disk.h>
485+#endif
486
487 #include <hfs/hfs_mount.h>
488
489@@ -195,8 +199,12 @@ main(argc, argv)
490 if (guiControl)
491 debug = 0; /* debugging is for command line only */
492
493+#if LINUX
494+// FIXME
495+#else
496 if (signal(SIGINT, SIG_IGN) != SIG_IGN)
497 (void)signal(SIGINT, catch);
498+#endif
499
500 if (argc < 1) {
501 (void) fprintf(stderr, "%s: missing special-device\n", progname);
502@@ -218,7 +226,9 @@ checkfilesys(char * filesys)
503 int chkLev, repLev, logLev;
504 int blockDevice_fd, canWrite;
505 char *unraw, *mntonname;
506+#if !LINUX
507 struct statfs *fsinfo;
508+#endif
509 int fs_fd=-1; // fd to the root-dir of the fs we're checking (only w/lfag == 1)
510
511 flags = 0;
512@@ -227,7 +237,9 @@ checkfilesys(char * filesys)
513 canWrite = 0;
514 unraw = NULL;
515 mntonname = NULL;
516-
517+#if LINUX
518+ // FIXME
519+#else
520 if (lflag) {
521 result = getmntinfo(&fsinfo, MNT_NOWAIT);
522
523@@ -257,10 +269,10 @@ checkfilesys(char * filesys)
524 }
525 }
526 }
527-
528+#endif
529 if (debug && preen)
530 pwarn("starting\n");
531-
532+
533 if (setup( filesys, &blockDevice_fd, &canWrite ) == 0) {
534 if (preen)
535 pfatal("CAN'T CHECK FILE SYSTEM.");
536@@ -278,7 +290,7 @@ checkfilesys(char * filesys)
537 repLev = kMajorRepairs;
538 logLev = kVerboseLog;
539
540- if (yflag)
541+ if (yflag)
542 repLev = kMajorRepairs;
543
544 if (quick) {
545@@ -298,16 +310,16 @@ checkfilesys(char * filesys)
546
547 if (nflag)
548 repLev = kNeverRepair;
549-
550+
551 if ( rebuildCatalogBtree ) {
552 chkLev = kPartialCheck;
553 repLev = kForceRepairs; // this will force rebuild of catalog B-Tree file
554 }
555-
556+
557 /*
558 * go check HFS volume...
559 */
560- result = CheckHFS( fsreadfd, fswritefd, chkLev, repLev, logLev,
561+ result = CheckHFS( fsreadfd, fswritefd, chkLev, repLev, logLev,
562 guiControl, lostAndFoundMode, canWrite, &fsmodified );
563 if (!hotroot) {
564 ckfini(1);
565@@ -330,6 +342,9 @@ checkfilesys(char * filesys)
566 }
567 }
568 } else {
569+#if LINUX
570+ // FIXME
571+#else
572 struct statfs stfs_buf;
573 /*
574 * Check to see if root is mounted read-write.
575@@ -339,19 +354,25 @@ checkfilesys(char * filesys)
576 else
577 flags = 0;
578 ckfini(flags & MNT_RDONLY);
579+#endif
580 }
581
582 /* XXX free any allocated memory here */
583
584 if (hotroot && fsmodified) {
585+#if !LINUX
586 struct hfs_mount_args args;
587+#endif
588 /*
589 * We modified the root. Do a mount update on
590 * it, unless it is read-write, so we can continue.
591 */
592 if (!preen)
593 printf("\n***** FILE SYSTEM WAS MODIFIED *****\n");
594- if (flags & MNT_RDONLY) {
595+#if LINUX
596+ // FIXME
597+#else
598+ if (flags & MNT_RDONLY) {
599 bzero(&args, sizeof(args));
600 flags |= MNT_UPDATE | MNT_RELOAD;
601 if (mount("hfs", "/", flags, &args) == 0) {
602@@ -359,6 +380,7 @@ checkfilesys(char * filesys)
603 goto ExitThisRoutine;
604 }
605 }
606+#endif
607 if (!preen)
608 printf("\n***** REBOOT NOW *****\n");
609 sync();
610@@ -367,7 +389,7 @@ checkfilesys(char * filesys)
611 }
612
613 result = (result == 0) ? 0 : EEXIT;
614-
615+
616 ExitThisRoutine:
617 if (lflag) {
618 fcntl(fs_fd, F_THAW_FS, NULL);
619@@ -401,16 +423,18 @@ setup( char *dev, int *blockDevice_fdPtr
620 fswritefd = -1;
621 *blockDevice_fdPtr = -1;
622 *canWritePtr = 0;
623-
624+
625 if (stat(dev, &statb) < 0) {
626 printf("Can't stat %s: %s\n", dev, strerror(errno));
627 return (0);
628 }
629+#if !LINUX
630 if ((statb.st_mode & S_IFMT) != S_IFCHR) {
631 pfatal("%s is not a character device", dev);
632 if (reply("CONTINUE") == 0)
633 return (0);
634 }
635+#endif
636 if ((fsreadfd = open(dev, O_RDONLY)) < 0) {
637 printf("Can't open %s: %s\n", dev, strerror(errno));
638 return (0);
639@@ -419,7 +443,7 @@ setup( char *dev, int *blockDevice_fdPtr
640 /* attempt to get write access to the block device and if not check if volume is */
641 /* mounted read-only. */
642 getWriteAccess( dev, blockDevice_fdPtr, canWritePtr );
643-
644+
645 if (preen == 0 && !guiControl)
646 printf("** %s", dev);
647 if (nflag || (fswritefd = open(dev, O_WRONLY)) < 0) {
648@@ -433,10 +457,14 @@ setup( char *dev, int *blockDevice_fdPtr
649 printf("\n");
650
651 /* Get device block size to initialize cache */
652+#if LINUX
653+ devBlockSize = 512;
654+#else
655 if (ioctl(fsreadfd, DKIOCGETBLOCKSIZE, &devBlockSize) < 0) {
656 pfatal ("Can't get device block size\n");
657 return (0);
658 }
659+#endif
660
661 /* calculate the cache block size and total blocks */
662 if (CalculateCacheSize(userCacheSize, &cacheBlockSize, &cacheTotalBlocks, debug) != 0) {
663@@ -463,11 +491,15 @@ setup( char *dev, int *blockDevice_fdPtr
664
665 static void getWriteAccess( char *dev, int *blockDevice_fdPtr, int *canWritePtr )
666 {
667+#if !LINUX
668 int i;
669 int myMountsCount;
670+#endif
671 void * myPtr;
672 char * myCharPtr;
673+#if !LINUX
674 struct statfs * myBufPtr;
675+#endif
676 void * myNamePtr;
677
678 myPtr = NULL;
679@@ -490,6 +522,9 @@ static void getWriteAccess( char *dev, i
680 }
681
682 // get count of mounts then get the info for each
683+#if LINUX
684+ // FIXME
685+#else
686 myMountsCount = getfsstat( NULL, 0, MNT_NOWAIT );
687 if ( myMountsCount < 0 )
688 goto ExitThisRoutine;
689@@ -513,8 +548,8 @@ static void getWriteAccess( char *dev, i
690 }
691 myBufPtr++;
692 }
693- *canWritePtr = 1; // single user will get us here, f_mntfromname is not /dev/diskXXXX
694-
695+#endif
696+ *canWritePtr = 1; // single user will get us here, f_mntfromname is not /dev/diskXXXX
697 ExitThisRoutine:
698 if ( myPtr != NULL )
699 free( myPtr );
700--- a/fsck_hfs.tproj/utilities.c
701+++ b/fsck_hfs.tproj/utilities.c
702@@ -183,12 +183,14 @@ retry:
703 printf("Can't stat %s\n", raw);
704 return (origname);
705 }
706+#if !LINUX
707 if ((stchar.st_mode & S_IFMT) == S_IFCHR) {
708 return (raw);
709 } else {
710 printf("%s is not a character device\n", raw);
711 return (origname);
712 }
713+#endif
714 } else if ((stblock.st_mode & S_IFMT) == S_IFCHR && !retried) {
715 newname = unrawname(newname);
716 retried++;
717@@ -214,7 +216,11 @@ rawname(char *name)
718 *dp = 0;
719 (void)strcpy(rawbuf, name);
720 *dp = '/';
721- (void)strcat(rawbuf, "/r");
722+#if LINUX
723+ (void)strcat(rawbuf, "/");
724+#else
725+ (void)strcat(rawbuf,"/r");
726+#endif
727 (void)strcat(rawbuf, &dp[1]);
728
729 return (rawbuf);
730--- /dev/null
731+++ b/include/missing.h
732@@ -0,0 +1,114 @@
733+#ifndef _MISSING_H_
734+#define _MISSING_H_
735+
736+#include <endian.h>
737+#include <byteswap.h>
738+#include <errno.h>
739+#include <stdint.h>
740+#include <string.h>
741+
742+#define MAXBSIZE (256 * 4096)
743+
744+#ifndef true
745+#define true 1
746+#endif
747+#ifndef false
748+#define false 0
749+#endif
750+
751+/* Mac types */
752+
753+/* 8 Bit */
754+#ifndef UInt8
755+#define UInt8 uint8_t
756+#endif
757+#ifndef u_int8_t
758+#define u_int8_t UInt8
759+#endif
760+#ifndef SInt8
761+#define SInt8 int8_t
762+#endif
763+
764+/* 16 Bit */
765+#ifndef UInt16
766+#define UInt16 uint16_t
767+#endif
768+#ifndef u_int16_t
769+#define u_int16_t UInt16
770+#endif
771+#ifndef SInt16
772+#define SInt16 int16_t
773+#endif
774+
775+/* 32 Bit */
776+#ifndef UInt32
777+#define UInt32 uint32_t
778+#endif
779+#ifndef u_int32_t
780+#define u_int32_t UInt32
781+#endif
782+#ifndef SInt32
783+#define SInt32 int32_t
784+#endif
785+
786+/* 64 Bit */
787+#ifndef UInt64
788+#define UInt64 uint64_t
789+#endif
790+#ifndef u_int64_t
791+#define u_int64_t UInt64
792+#endif
793+#ifndef SInt64
794+#define SInt64 int64_t
795+#endif
796+
797+#define UniChar u_int16_t
798+#define Boolean u_int8_t
799+
800+#define UF_NODUMP 0x00000001
801+
802+/* syslimits.h */
803+#define NAME_MAX 255
804+
805+/* Byteswap stuff */
806+#define NXSwapHostLongToBig(x) cpu_to_be64(x)
807+#define NXSwapBigShortToHost(x) be16_to_cpu(x)
808+#define OSSwapBigToHostInt16(x) be16_to_cpu(x)
809+#define NXSwapBigLongToHost(x) be32_to_cpu(x)
810+#define OSSwapBigToHostInt32(x) be32_to_cpu(x)
811+#define NXSwapBigLongLongToHost(x) be64_to_cpu(x)
812+#define OSSwapBigToHostInt64(x) be64_to_cpu(x)
813+
814+#if __BYTE_ORDER == __LITTLE_ENDIAN
815+/* Big Endian Swaps */
816+#ifndef be16_to_cpu
817+#define be16_to_cpu(x) bswap_16(x)
818+#endif
819+#ifndef be32_to_cpu
820+#define be32_to_cpu(x) bswap_32(x)
821+#endif
822+#ifndef be64_to_cpu
823+#define be64_to_cpu(x) bswap_64(x)
824+#endif
825+#ifndef cpu_to_be64
826+#define cpu_to_be64(x) bswap_64(x)
827+#endif
828+#elif __BYTE_ORDER == __BIG_ENDIAN
829+/* Big endian doesn't swap */
830+#ifndef be16_to_cpu
831+#define be16_to_cpu(x) (x)
832+#endif
833+#ifndef be32_to_cpu
834+#define be32_to_cpu(x) (x)
835+#endif
836+#ifndef be64_to_cpu
837+#define be64_to_cpu(x) (x)
838+#endif
839+#ifndef cpu_to_be64
840+#define cpu_to_be64(x) (x)
841+#endif
842+#endif
843+
844+#define KAUTH_FILESEC_XATTR "com.apple.system.Security"
845+
846+#endif
847--- a/newfs_hfs.tproj/hfs_endian.c
848+++ b/newfs_hfs.tproj/hfs_endian.c
849@@ -30,7 +30,12 @@
850 #include <sys/types.h>
851 #include <sys/stat.h>
852
853+#if LINUX
854+#include "missing.h"
855+#else
856 #include <architecture/byte_order.h>
857+#endif
858+
859 #include <hfs/hfs_format.h>
860
861 #include "hfs_endian.h"
862--- a/newfs_hfs.tproj/hfs_endian.h
863+++ b/newfs_hfs.tproj/hfs_endian.h
864@@ -29,7 +29,12 @@
865 * volume format.
866 */
867 #include <hfs/hfs_format.h>
868+#if LINUX
869+#include <endian.h>
870+#include <byteswap.h>
871+#else
872 #include <architecture/byte_order.h>
873+#endif
874
875 /*********************/
876 /* BIG ENDIAN Macros */
877--- a/newfs_hfs.tproj/makehfs.c
878+++ b/newfs_hfs.tproj/makehfs.c
879@@ -31,10 +31,16 @@
880 #include <sys/param.h>
881 #include <sys/types.h>
882 #include <sys/time.h>
883+#if LINUX
884+#include <time.h>
885+#include "missing.h"
886+#endif
887 #include <sys/errno.h>
888 #include <sys/stat.h>
889 #include <sys/sysctl.h>
890+#if !LINUX
891 #include <sys/vmmeter.h>
892+#endif
893
894 #include <err.h>
895 #include <errno.h>
896@@ -47,13 +53,14 @@
897
898 #include <openssl/sha.h>
899
900+#if !LINUX
901 #include <architecture/byte_order.h>
902
903 #include <CoreFoundation/CFString.h>
904 #include <CoreFoundation/CFStringEncodingExt.h>
905
906 extern Boolean _CFStringGetFileSystemRepresentation(CFStringRef string, UInt8 *buffer, CFIndex maxBufLen);
907-
908+#endif
909
910 #include <hfs/hfs_format.h>
911 #include <hfs/hfs_mount.h>
912@@ -129,7 +136,9 @@ static UInt32 Largest __P((UInt32 a, UIn
913 static void MarkBitInAllocationBuffer __P((HFSPlusVolumeHeader *header,
914 UInt32 allocationBlock, void* sectorBuffer, UInt32 *sector));
915
916+#if !LINUX
917 static UInt32 GetDefaultEncoding();
918+#endif
919
920 static UInt32 UTCToLocal __P((UInt32 utcTime));
921
922@@ -158,11 +167,14 @@ void SETOFFSET (void *buffer, UInt16 btN
923
924 #define ROUNDUP(x, u) (((x) % (u) == 0) ? (x) : ((x)/(u) + 1) * (u))
925
926-#define ENCODING_TO_BIT(e) \
927+#if LINUX
928+#define ENCODING_TO_BIT(e) (e)
929+#else
930+#define ENCODING_TO_BIT(e)
931 ((e) < 48 ? (e) : \
932 ((e) == kCFStringEncodingMacUkrainian ? 48 : \
933 ((e) == kCFStringEncodingMacFarsi ? 49 : 0)))
934-
935+#endif
936 /*
937 * make_hfs
938 *
939@@ -528,6 +540,7 @@ InitMDB(hfsparams_t *defaults, UInt32 dr
940 * Map UTF-8 input into a Mac encoding.
941 * On conversion errors "untitled" is used as a fallback.
942 */
943+#if !LINUX
944 {
945 UniChar unibuf[kHFSMaxVolumeNameChars];
946 CFStringRef cfstr;
947@@ -553,7 +566,11 @@ InitMDB(hfsparams_t *defaults, UInt32 dr
948 bcopy(&mdbp->drVN[1], defaults->volumeName, mdbp->drVN[0]);
949 defaults->volumeName[mdbp->drVN[0]] = '\0';
950 }
951+#endif
952 /* Save the encoding hint in the Finder Info (field 4). */
953+ mdbp->drVN[0] = strlen(defaults->volumeName);
954+ bcopy(defaults->volumeName,&mdbp->drVN[1],mdbp->drVN[0]);
955+
956 mdbp->drFndrInfo[4] = SET_HFS_TEXT_ENCODING(defaults->encodingHint);
957
958 mdbp->drWrCnt = kWriteSeqNum;
959@@ -1100,9 +1117,11 @@ InitCatalogRoot_HFSPlus(const hfsparams_
960 UInt16 nodeSize;
961 SInt16 offset;
962 UInt32 unicodeBytes;
963+#if !LINUX
964 UInt8 canonicalName[256];
965 CFStringRef cfstr;
966 Boolean cfOK;
967+#endif
968 int index = 0;
969
970 nodeSize = dp->catalogNodeSize;
971@@ -1122,7 +1141,9 @@ InitCatalogRoot_HFSPlus(const hfsparams_
972 * First record is always the root directory...
973 */
974 ckp = (HFSPlusCatalogKey *)((UInt8 *)buffer + offset);
975-
976+#if LINUX
977+ ConvertUTF8toUnicode(dp->volumeName, sizeof(ckp->nodeName.unicode), ckp->nodeName.unicode, &ckp->nodeName.length);
978+#else
979 /* Use CFString functions to get a HFSPlus Canonical name */
980 cfstr = CFStringCreateWithCString(kCFAllocatorDefault, (char *)dp->volumeName, kCFStringEncodingUTF8);
981 cfOK = _CFStringGetFileSystemRepresentation(cfstr, canonicalName, sizeof(canonicalName));
982@@ -1139,6 +1160,7 @@ InitCatalogRoot_HFSPlus(const hfsparams_
983 dp->volumeName, kDefaultVolumeNameStr);
984 }
985 CFRelease(cfstr);
986+#endif
987 ckp->nodeName.length = SWAP_BE16 (ckp->nodeName.length);
988
989 unicodeBytes = sizeof(UniChar) * SWAP_BE16 (ckp->nodeName.length);
990@@ -1821,15 +1843,15 @@ WriteBuffer(const DriveInfo *driveInfo,
991 off_t sector;
992
993 if ((byteCount % driveInfo->sectorSize) != 0)
994- errx(1, "WriteBuffer: byte count %ld is not sector size multiple", byteCount);
995+ errx(1, "WriteBuffer: byte count %i is not sector size multiple", byteCount);
996
997 sector = driveInfo->sectorOffset + startingSector;
998
999 if (lseek(driveInfo->fd, sector * driveInfo->sectorSize, SEEK_SET) < 0)
1000- err(1, "seek (sector %qd)", sector);
1001+ err(1, "seek (sector %lld)", sector);
1002
1003 if (write(driveInfo->fd, buffer, byteCount) != byteCount)
1004- err(1, "write (sector %qd, %ld bytes)", sector, byteCount);
1005+ err(1, "write (sector %lld, %i bytes)", sector, byteCount);
1006 }
1007
1008
1009@@ -1913,7 +1935,7 @@ DivideAndRoundUp(UInt32 numerator, UInt3
1010 return quotient;
1011 }
1012
1013-
1014+#if !LINUX
1015 #define __kCFUserEncodingFileName ("/.CFUserTextEncoding")
1016
1017 static UInt32
1018@@ -1939,7 +1961,7 @@ GetDefaultEncoding()
1019 }
1020 return 0;
1021 }
1022-
1023+#endif
1024
1025 static int
1026 ConvertUTF8toUnicode(const UInt8* source, UInt32 bufsize, UniChar* unibuf,
1027@@ -2006,6 +2028,9 @@ ConvertUTF8toUnicode(const UInt8* source
1028 static int
1029 getencodinghint(unsigned char *name)
1030 {
1031+#if LINUX
1032+ return(0);
1033+#else
1034 int mib[3];
1035 size_t buflen = sizeof(int);
1036 struct vfsconf vfc;
1037@@ -2023,7 +2048,8 @@ getencodinghint(unsigned char *name)
1038 return (hint);
1039 error:
1040 hint = GetDefaultEncoding();
1041- return (hint);
1042+ return (0);
1043+#endif
1044 }
1045
1046
1047@@ -2034,12 +2060,14 @@ void GenerateVolumeUUID(VolumeUUID *newV
1048 unsigned char digest[20];
1049 time_t now;
1050 clock_t uptime;
1051- int mib[2];
1052- int sysdata;
1053- char sysctlstring[128];
1054 size_t datalen;
1055 double sysloadavg[3];
1056+#if !LINUX
1057+ int sysdata;
1058+ int mib[2];
1059+ char sysctlstring[128];
1060 struct vmtotal sysvmtotal;
1061+#endif
1062
1063 do {
1064 /* Initialize the SHA-1 context for processing: */
1065@@ -2052,52 +2080,58 @@ void GenerateVolumeUUID(VolumeUUID *newV
1066 SHA1_Update(&context, &uptime, sizeof(uptime));
1067
1068 /* The kernel's boot time: */
1069+#if !LINUX
1070 mib[0] = CTL_KERN;
1071 mib[1] = KERN_BOOTTIME;
1072 datalen = sizeof(sysdata);
1073 sysctl(mib, 2, &sysdata, &datalen, NULL, 0);
1074 SHA1_Update(&context, &sysdata, datalen);
1075-
1076+#endif
1077 /* The system's host id: */
1078+#if !LINUX
1079 mib[0] = CTL_KERN;
1080 mib[1] = KERN_HOSTID;
1081 datalen = sizeof(sysdata);
1082 sysctl(mib, 2, &sysdata, &datalen, NULL, 0);
1083 SHA1_Update(&context, &sysdata, datalen);
1084-
1085+#endif
1086 /* The system's host name: */
1087+#if !LINUX
1088 mib[0] = CTL_KERN;
1089 mib[1] = KERN_HOSTNAME;
1090 datalen = sizeof(sysctlstring);
1091 sysctl(mib, 2, sysctlstring, &datalen, NULL, 0);
1092 SHA1_Update(&context, sysctlstring, datalen);
1093-
1094+#endif
1095 /* The running kernel's OS release string: */
1096+#if !LINUX
1097 mib[0] = CTL_KERN;
1098 mib[1] = KERN_OSRELEASE;
1099 datalen = sizeof(sysctlstring);
1100 sysctl(mib, 2, sysctlstring, &datalen, NULL, 0);
1101 SHA1_Update(&context, sysctlstring, datalen);
1102-
1103+#endif
1104 /* The running kernel's version string: */
1105+#if !LINUX
1106 mib[0] = CTL_KERN;
1107 mib[1] = KERN_VERSION;
1108 datalen = sizeof(sysctlstring);
1109 sysctl(mib, 2, sysctlstring, &datalen, NULL, 0);
1110 SHA1_Update(&context, sysctlstring, datalen);
1111-
1112+#endif
1113 /* The system's load average: */
1114 datalen = sizeof(sysloadavg);
1115 getloadavg(sysloadavg, 3);
1116 SHA1_Update(&context, &sysloadavg, datalen);
1117
1118 /* The system's VM statistics: */
1119+#if !LINUX
1120 mib[0] = CTL_VM;
1121 mib[1] = VM_METER;
1122 datalen = sizeof(sysvmtotal);
1123 sysctl(mib, 2, &sysvmtotal, &datalen, NULL, 0);
1124 SHA1_Update(&context, &sysvmtotal, datalen);
1125-
1126+#endif
1127 /* The current GMT (26 ASCII characters): */
1128 time(&now);
1129 strncpy(randomInputBuffer, asctime(gmtime(&now)), 26); /* "Mon Mar 27 13:46:26 2000" */
1130--- a/newfs_hfs.tproj/newfs_hfs.c
1131+++ b/newfs_hfs.tproj/newfs_hfs.c
1132@@ -38,8 +38,13 @@
1133 #include <sys/mount.h>
1134 #include <sys/param.h>
1135 #include <sys/stat.h>
1136+#if LINUX
1137+#include <time.h>
1138+#endif
1139
1140+#if !LINUX
1141 #include <IOKit/storage/IOMediaBSDClient.h>
1142+#endif
1143
1144 #include <hfs/hfs_format.h>
1145 #include "newfs_hfs.h"
1146@@ -73,7 +78,9 @@ static void usage __P((void));
1147
1148 char *progname;
1149 char gVolumeName[kHFSPlusMaxFileNameChars + 1] = {kDefaultVolumeNameStr};
1150+#if !LINUX
1151 char rawdevice[MAXPATHLEN];
1152+#endif
1153 char blkdevice[MAXPATHLEN];
1154 UInt32 gBlockSize = 0;
1155 UInt32 gNextCNID = kHFSFirstUserCatalogNodeID;
1156@@ -158,8 +165,10 @@ main(argc, argv)
1157 extern int optind;
1158 int ch;
1159 int forceHFS;
1160+#if !LINUX
1161 char *cp, *special;
1162 struct statfs *mp;
1163+#endif
1164 int n;
1165
1166 if ((progname = strrchr(*argv, '/')))
1167@@ -260,16 +269,19 @@ main(argc, argv)
1168 usage();
1169 }
1170
1171- argc -= optind;
1172- argv += optind;
1173+ argc -= optind;
1174+ argv += optind;
1175
1176- if (gPartitionSize != 0) {
1177- if (argc != 0)
1178- usage();
1179- } else {
1180- if (argc != 1)
1181- usage();
1182+ if (gPartitionSize != 0) {
1183+ if (argc != 0)
1184+ usage();
1185+ } else {
1186+ if (argc != 1)
1187+ usage();
1188
1189+#if LINUX
1190+ (void) sprintf(blkdevice, "%s", argv[0]);
1191+#else
1192 special = argv[0];
1193 cp = strrchr(special, '/');
1194 if (cp != 0)
1195@@ -278,6 +290,7 @@ main(argc, argv)
1196 special++;
1197 (void) sprintf(rawdevice, "%sr%s", _PATH_DEV, special);
1198 (void) sprintf(blkdevice, "%s%s", _PATH_DEV, special);
1199+#endif
1200 }
1201
1202 if (forceHFS && gJournaled) {
1203@@ -301,6 +314,9 @@ main(argc, argv)
1204 /*
1205 * Check if target device is aready mounted
1206 */
1207+#if LINUX
1208+ // FIXME
1209+#else
1210 n = getmntinfo(&mp, MNT_NOWAIT);
1211 if (n == 0)
1212 fatal("%s: getmntinfo: %s", blkdevice, strerror(errno));
1213@@ -310,15 +326,20 @@ main(argc, argv)
1214 fatal("%s is mounted on %s", blkdevice, mp->f_mntonname);
1215 ++mp;
1216 }
1217+#endif
1218 }
1219
1220- if (hfs_newfs(rawdevice, forceHFS, true) < 0) {
1221+ if (hfs_newfs(blkdevice, forceHFS, true) < 0) {
1222+#if LINUX
1223+ err(1, NULL);
1224+#else
1225 /* On ENXIO error use the block device (to get de-blocking) */
1226 if (errno == ENXIO) {
1227 if (hfs_newfs(blkdevice, forceHFS, false) < 0)
1228 err(1, NULL);
1229 } else
1230 err(1, NULL);
1231+#endif
1232 }
1233
1234 exit(0);
1235@@ -506,7 +527,9 @@ hfs_newfs(char *device, int forceHFS, in
1236 int fso = 0;
1237 int retval = 0;
1238 hfsparams_t defaults = {0};
1239+#if !LINUX
1240 u_int64_t maxSectorsPerIO;
1241+#endif
1242
1243 if (gPartitionSize) {
1244 dip.sectorSize = kBytesPerSector;
1245@@ -526,6 +549,34 @@ hfs_newfs(char *device, int forceHFS, in
1246
1247 if (fstat( fso, &stbuf) < 0)
1248 fatal("%s: %s", device, strerror(errno));
1249+#if LINUX
1250+ dip.sectorSize = 512;
1251+ dip.sectorsPerIO = 256;
1252+
1253+# ifndef BLKGETSIZE
1254+# define BLKGETSIZE _IO(0x12,96)
1255+# endif
1256+
1257+# ifndef BLKGETSIZE64
1258+# define BLKGETSIZE64 _IOR(0x12,114,size_t)
1259+# endif
1260+
1261+ if (S_ISREG(stbuf.st_mode)) {
1262+ dip.totalSectors = stbuf.st_size / 512;
1263+ }
1264+ else if (S_ISBLK(stbuf.st_mode)) {
1265+ unsigned long size;
1266+ u_int64_t size64;
1267+ if (!ioctl(fso, BLKGETSIZE64, &size64))
1268+ dip.totalSectors = size64 / 512;
1269+ else if (!ioctl(fso, BLKGETSIZE, &size))
1270+ dip.totalSectors = size;
1271+ else
1272+ fatal("%s: %s", device, strerror(errno));
1273+ }
1274+ else
1275+ fatal("%s: is not a block device", device);
1276+#else
1277
1278 if (ioctl(fso, DKIOCGETBLOCKCOUNT, &dip.totalSectors) < 0)
1279 fatal("%s: %s", device, strerror(errno));
1280@@ -537,11 +588,14 @@ hfs_newfs(char *device, int forceHFS, in
1281 dip.sectorsPerIO = (128 * 1024) / dip.sectorSize; /* use 128K as default */
1282 else
1283 dip.sectorsPerIO = MIN(maxSectorsPerIO, (1024 * 1024) / dip.sectorSize);
1284+#endif
1285+
1286 /*
1287 * The make_hfs code currentlydoes 512 byte sized I/O.
1288 * If the sector size is bigger than 512, start over
1289 * using the block device (to get de-blocking).
1290 */
1291+#if !LINUX
1292 if (dip.sectorSize != kBytesPerSector) {
1293 if (isRaw) {
1294 close(fso);
1295@@ -556,7 +610,9 @@ hfs_newfs(char *device, int forceHFS, in
1296 dip.sectorSize = kBytesPerSector;
1297 }
1298 }
1299+#endif
1300 }
1301+
1302 dip.sectorOffset = 0;
1303 time(&createtime);
1304
1305--- a/newfs_hfs.tproj/newfs_hfs.h
1306+++ b/newfs_hfs.tproj/newfs_hfs.h
1307@@ -19,8 +19,12 @@
1308 *
1309 * @APPLE_LICENSE_HEADER_END@
1310 */
1311-
1312+
1313+#if LINUX
1314+#include "missing.h"
1315+#else
1316 #include <CoreFoundation/CFBase.h>
1317+#endif
1318
1319 /*
1320 * Mac OS Finder flags
1321@@ -122,33 +126,33 @@ enum {
1322 #define kDTDF_FileID 16
1323 #define kDTDF_Name "Desktop DF"
1324 #define kDTDF_Chars 10
1325-#define kDTDF_Type 'DTFL'
1326-#define kDTDF_Creator 'DMGR'
1327+#define kDTDF_Type 0x4454464C /* 'DTFL' */
1328+#define kDTDF_Creator 0x444D4752 /* 'DMGR' */
1329
1330 #define kDTDB_FileID 17
1331 #define kDTDB_Name "Desktop DB"
1332 #define kDTDB_Chars 10
1333-#define kDTDB_Type 'BTFL'
1334-#define kDTDB_Creator 'DMGR'
1335+#define kDTDB_Type 0x4254464C /* 'BTFL' */
1336+#define kDTDB_Creator 0x444D4752 /* 'DMGR' */
1337 #define kDTDB_Size 1024
1338
1339 #define kReadMe_FileID 18
1340 #define kReadMe_Name "ReadMe"
1341 #define kReadMe_Chars 6
1342-#define kReadMe_Type 'ttro'
1343-#define kReadMe_Creator 'ttxt'
1344+#define kReadMe_Type 0x7474726F /* 'ttro' */
1345+#define kReadMe_Creator 0x74747974 /* 'ttxt' */
1346
1347 #define kFinder_FileID 19
1348 #define kFinder_Name "Finder"
1349 #define kFinder_Chars 6
1350-#define kFinder_Type 'FNDR'
1351-#define kFinder_Creator 'MACS'
1352+#define kFinder_Type 0x464E4452 /* 'FNDR' */
1353+#define kFinder_Creator 0x4D414353 /* 'MACS' */
1354
1355 #define kSystem_FileID 20
1356 #define kSystem_Name "System"
1357 #define kSystem_Chars 6
1358-#define kSystem_Type 'zsys'
1359-#define kSystem_Creator 'MACS'
1360+#define kSystem_Type 0x7A737973 /* 'zsys' */
1361+#define kSystem_Creator 0x4D414353 /* 'MACS' */
1362
1363
1364