Переглянути джерело

hfsprogs: initial import

Adds supports for hfsprogs, allowing the creation and verification of
HFS/HFS+ filesystems.

This creates two selectable packages:
- hfsfsck
- mkhfs

A filesystem checking script is included with hfsfsck to allow OpenWrt
to check/repair filesystem errors.

Using Ubuntu's 332.25 sources plus their patches from debian/patches/.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
Florian Fainelli 10 роки тому
джерело
коміт
197e6a5a1c

+ 81
- 0
utils/hfsprogs/Makefile Переглянути файл

@@ -0,0 +1,81 @@
1
+#
2
+# Copyright (C) 2015 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=hfsprogs
11
+PKG_VERSION:=332.25
12
+PKG_RELEASE:=1
13
+
14
+PKG_LICENSE:=GPL-3.0+
15
+PKG_LICENSE_FILES:=COPYING
16
+
17
+PKG_MAINTAINER:=Florian Fainelli <florian@openwrt.org>
18
+
19
+PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).orig.tar.gz
20
+PKG_SOURCE_URL:=http://archive.ubuntu.com/ubuntu/pool/universe/h/$(PKG_NAME)
21
+PKG_BUILD_DIR:=$(BUILD_DIR)/diskdev_cmds-$(PKG_VERSION)
22
+PKG_MD5SUM:=261c3de5ec0dcf5244e3f60d79c1d6f1
23
+PKG_LICENSE:=APSL 2.0
24
+
25
+include $(INCLUDE_DIR)/package.mk
26
+include $(INCLUDE_DIR)/nls.mk
27
+
28
+define Package/hfsprogs/Default
29
+  SECTION:=utils
30
+  CATEGORY:=Utilities
31
+  SUBMENU:=Filesystem
32
+  DEPENDS:=+libopenssl
33
+endef
34
+
35
+define Package/hfsfsck
36
+  $(call Package/hfsprogs/Default)
37
+  TITLE:=fsck (fsck.hfs) utility from hfsprogs
38
+endef
39
+
40
+define Package/mkhfs
41
+  $(call Package/hfsprogs/Default)
42
+  TITLE:=mkfs (mkfs.hfs) utility from hfsprogs
43
+endef
44
+
45
+define Package/hfsfsck/description
46
+	Utilities to create and check HFS/HFS+ filesystems.
47
+	(fsck.hfs and fsck.hfsplus for checking integrity of HFS/HFS+ volumes)
48
+endef
49
+
50
+define Package/mkhfs/description
51
+	Utilities to create and check HFS/HFS+ filesystems.
52
+	(mkfs.hfs and mkfs.hfsplus for creating HFS/HFS+ volumes)
53
+endef
54
+
55
+define Build/Configure
56
+endef
57
+
58
+define Build/Compile
59
+	$(MAKE) -C $(PKG_BUILD_DIR) \
60
+		-f Makefile.lnx \
61
+		$(TARGET_CONFIGURE_OPTS) \
62
+		CFLAGS+="$(TARGET_CFLAGS) -I$(PKG_BUILD_DIR)/include -DDEBUG_BUILD=0 -D_FILE_OFFSET_BITS=64 -D LINUX=1 -D BSD=1" \
63
+		all
64
+endef
65
+
66
+define Package/hfsfsck/install
67
+	$(INSTALL_DIR) $(1)/lib/functions/fsck
68
+	$(INSTALL_DATA) ./files/hfsfsck.sh $(1)/lib/functions/fsck/
69
+	$(INSTALL_DIR) $(1)/usr/sbin
70
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/fsck_hfs.tproj/fsck_hfs	$(1)/usr/sbin/fsck.hfsplus
71
+	(cd $(1)/usr/sbin; ln -sf fsck.hfsplus fsck.hfs;)
72
+endef
73
+
74
+define Package/mkhfs/install
75
+	$(INSTALL_DIR) $(1)/usr/sbin
76
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/newfs_hfs.tproj/newfs_hfs $(1)/usr/sbin/mkfs.hfsplus
77
+	(cd $(1)/usr/sbin; ln -sf mkfs.hfsplus mkfs.hfs;)
78
+endef
79
+
80
+$(eval $(call BuildPackage,hfsfsck))
81
+$(eval $(call BuildPackage,mkhfs))

+ 30
- 0
utils/hfsprogs/files/hfsfsck.sh Переглянути файл

@@ -0,0 +1,30 @@
1
+#!/bin/sh
2
+# Copyright 2015 OpenWrt.org
3
+# This is free software, licensed under the GNU General Public License v2.
4
+# See /LICENSE for more information.
5
+#
6
+
7
+fsck_hfsfsck() {
8
+	hfsfsck "$device" 2>&1 | logger -t "fstab: hfsfsck ($device)"
9
+	local status="$?"
10
+	case "$status" in
11
+		0) ;; #success
12
+		4) reboot;;
13
+		8) echo "hfsfsck ($device): Warning! Uncorrected errors."| logger -t fstab
14
+			return 1
15
+			;;
16
+		*) echo "hfsfsck ($device): Error $status. Check not complete."| logger -t fstab;;
17
+	esac
18
+	return 0
19
+}
20
+
21
+fsck_hfs() {
22
+	fsck_hfsfsck "$@"
23
+}
24
+
25
+fsck_hfsplus() {
26
+	fsck_hfsfsck "$@"
27
+}
28
+
29
+append libmount_known_fsck "hfs"
30
+append libmount_known_fsck "hfsplus"

+ 93
- 0
utils/hfsprogs/patches/0001-Create-short-Makefiles-for-Debian.patch Переглянути файл

@@ -0,0 +1,93 @@
1
+From: =?UTF-8?q?Rog=C3=A9rio=20Brito?= <rbrito@ime.usp.br>
2
+Date: Thu, 24 Oct 2013 01:11:21 -0200
3
+Subject: Create short Makefiles for Debian
4
+
5
+Create short Makefiles for compiling just the necessary parts for a
6
+Debian-based (and possibly other distributions) HFS+ filesystem
7
+utilities.
8
+---
9
+ Makefile.lnx                       |  8 ++++++++
10
+ fsck_hfs.tproj/Makefile.lnx        | 16 ++++++++++++++++
11
+ fsck_hfs.tproj/dfalib/Makefile.lnx | 15 +++++++++++++++
12
+ newfs_hfs.tproj/Makefile.lnx       | 12 ++++++++++++
13
+ 4 files changed, 51 insertions(+)
14
+ create mode 100644 Makefile.lnx
15
+ create mode 100644 fsck_hfs.tproj/Makefile.lnx
16
+ create mode 100644 fsck_hfs.tproj/dfalib/Makefile.lnx
17
+ create mode 100644 newfs_hfs.tproj/Makefile.lnx
18
+
19
+diff --git a/Makefile.lnx b/Makefile.lnx
20
+new file mode 100644
21
+index 0000000..687d1e7
22
+--- /dev/null
23
++++ b/Makefile.lnx
24
+@@ -0,0 +1,8 @@
25
++CC := gcc
26
++CFLAGS += -I$(PWD)/include -DDEBUG_BUILD=0 -D_FILE_OFFSET_BITS=64 -D LINUX=1 -D BSD=1
27
++SUBDIRS := newfs_hfs.tproj fsck_hfs.tproj
28
++
29
++all clean:
30
++	for d in $(SUBDIRS); do $(MAKE) -C $$d -f Makefile.lnx $@; done
31
++
32
++export CC CFLAGS
33
+diff --git a/fsck_hfs.tproj/Makefile.lnx b/fsck_hfs.tproj/Makefile.lnx
34
+new file mode 100644
35
+index 0000000..977d7e8
36
+--- /dev/null
37
++++ b/fsck_hfs.tproj/Makefile.lnx
38
+@@ -0,0 +1,16 @@
39
++CFILES = fsck_hfs.c strings.c utilities.c cache.c fsck_debug.c
40
++OFILES = $(CFILES:.c=.o)
41
++
42
++all: fsck_hfs
43
++
44
++fsck_hfs: $(OFILES) dfalib/libdfa.a
45
++	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OFILES) dfalib/libdfa.a
46
++
47
++dfalib/libdfa.a: FORCE
48
++	$(MAKE) -C dfalib -f Makefile.lnx CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" libdfa.a
49
++
50
++clean:
51
++	$(RM) fsck_hfs $(OFILES)
52
++	$(MAKE) -C dfalib -f Makefile.lnx clean
53
++
54
++.PHONY : FORCE clean
55
+diff --git a/fsck_hfs.tproj/dfalib/Makefile.lnx b/fsck_hfs.tproj/dfalib/Makefile.lnx
56
+new file mode 100644
57
+index 0000000..8c07196
58
+--- /dev/null
59
++++ b/fsck_hfs.tproj/dfalib/Makefile.lnx
60
+@@ -0,0 +1,15 @@
61
++CFILES = hfs_endian.c BlockCache.c\
62
++         BTree.c BTreeAllocate.c BTreeMiscOps.c \
63
++         BTreeNodeOps.c BTreeScanner.c BTreeTreeOps.c\
64
++         CatalogCheck.c HardLinkCheck.c\
65
++         SBTree.c SControl.c SVerify1.c SVerify2.c\
66
++         SRepair.c SRebuildCatalogBTree.c\
67
++         SUtils.c SKeyCompare.c SDevice.c SExtents.c SAllocate.c\
68
++         SCatalog.c SStubs.c VolumeBitmapCheck.c
69
++OFILES = $(CFILES:.c=.o)
70
++
71
++libdfa.a: $(OFILES)
72
++	ar rc $@ $?
73
++
74
++clean:
75
++	$(RM) $(OFILES) libdfa.a
76
+diff --git a/newfs_hfs.tproj/Makefile.lnx b/newfs_hfs.tproj/Makefile.lnx
77
+new file mode 100644
78
+index 0000000..58e6700
79
+--- /dev/null
80
++++ b/newfs_hfs.tproj/Makefile.lnx
81
+@@ -0,0 +1,12 @@
82
++CFILES = hfs_endian.c makehfs.c newfs_hfs.c
83
++OFILES = $(CFILES:.c=.o)
84
++
85
++all: newfs_hfs
86
++
87
++newfs_hfs: $(OFILES)
88
++	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OFILES) -lcrypto
89
++
90
++clean:
91
++	$(RM) newfs_hfs $(OFILES)
92
++
93
++.PHONY : FORCE clean

+ 1407
- 0
utils/hfsprogs/patches/0002-Add-exclude-Darwin-specific-code.patch
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 1024
- 0
utils/hfsprogs/patches/0003-Add-helper-include-files-absent-from-the-upstream-pa.patch
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 131
- 0
utils/hfsprogs/patches/0004-Fix-compilation-on-64-bit-arches.patch Переглянути файл

@@ -0,0 +1,131 @@
1
+From: =?UTF-8?q?Rog=C3=A9rio=20Brito?= <rbrito@ime.usp.br>
2
+Date: Thu, 24 Oct 2013 01:11:21 -0200
3
+Subject: Fix compilation on 64-bit arches
4
+
5
+---
6
+ fsck_hfs.tproj/dfalib/BTreePrivate.h |  5 ++++-
7
+ fsck_hfs.tproj/dfalib/SControl.c     |  8 ++++----
8
+ fsck_hfs.tproj/dfalib/SVerify1.c     | 14 +++++++-------
9
+ fsck_hfs.tproj/dfalib/hfs_endian.c   |  2 +-
10
+ 4 files changed, 16 insertions(+), 13 deletions(-)
11
+
12
+diff --git a/fsck_hfs.tproj/dfalib/BTreePrivate.h b/fsck_hfs.tproj/dfalib/BTreePrivate.h
13
+index 058c75b..2fc2f28 100644
14
+--- a/fsck_hfs.tproj/dfalib/BTreePrivate.h
15
++++ b/fsck_hfs.tproj/dfalib/BTreePrivate.h
16
+@@ -104,6 +104,9 @@ typedef enum {
17
+ 
18
+ ///////////////////////////////////// Types /////////////////////////////////////
19
+ 
20
++// Forward declaration from Scavenger.h
21
++struct BTreeExtensionsRec;
22
++
23
+ typedef struct BTreeControlBlock {					// fields specific to BTree CBs
24
+ 
25
+ 	UInt8		keyCompareType;   /* Key string Comparison Type */
26
+@@ -144,7 +147,7 @@ typedef struct BTreeControlBlock {					// fields specific to BTree CBs
27
+ 	UInt32						 numPossibleHints;	// Looks like a formated hint
28
+ 	UInt32						 numValidHints;		// Hint used to find correct record.
29
+ 	
30
+-	UInt32						 refCon;			//	Used by DFA to point to private data.
31
++	struct BTreeExtensionsRec			*refCon;			//	Used by DFA to point to private data.
32
+ 	SFCB						*fcbPtr;		// fcb of btree file
33
+ 	
34
+ } BTreeControlBlock, *BTreeControlBlockPtr;
35
+diff --git a/fsck_hfs.tproj/dfalib/SControl.c b/fsck_hfs.tproj/dfalib/SControl.c
36
+index 37eb242..4ce9e16 100644
37
+--- a/fsck_hfs.tproj/dfalib/SControl.c
38
++++ b/fsck_hfs.tproj/dfalib/SControl.c
39
+@@ -1034,7 +1034,7 @@ static int ScavTerm( SGlobPtr GPtr )
40
+ 		btcbP = (BTreeControlBlock*)fcbP->fcbBtree;
41
+ 		if ( btcbP != nil)
42
+ 		{
43
+-			if( btcbP->refCon != (UInt32)nil )
44
++			if( btcbP->refCon != nil )
45
+ 			{
46
+ 				if(((BTreeExtensionsRec*)btcbP->refCon)->BTCBMPtr != nil)
47
+ 				{
48
+@@ -1043,13 +1043,13 @@ static int ScavTerm( SGlobPtr GPtr )
49
+ 				}
50
+ 				DisposeMemory( (Ptr)btcbP->refCon );
51
+ 				err = MemError();
52
+-				btcbP->refCon = (UInt32)nil;
53
++				btcbP->refCon = nil;
54
+ 			}
55
+ 				
56
+ 			fcbP = GPtr->calculatedCatalogFCB;	//	release catalog BTree bit map
57
+ 			btcbP = (BTreeControlBlock*)fcbP->fcbBtree;
58
+ 				
59
+-			if( btcbP->refCon != (UInt32)nil )
60
++			if( btcbP->refCon != nil )
61
+ 			{
62
+ 				if(((BTreeExtensionsRec*)btcbP->refCon)->BTCBMPtr != nil)
63
+ 				{
64
+@@ -1058,7 +1058,7 @@ static int ScavTerm( SGlobPtr GPtr )
65
+ 				}
66
+ 				DisposeMemory( (Ptr)btcbP->refCon );
67
+ 				err = MemError();
68
+-				btcbP->refCon = (UInt32)nil;
69
++				btcbP->refCon = nil;
70
+ 			}
71
+ 		}
72
+ 	}
73
+diff --git a/fsck_hfs.tproj/dfalib/SVerify1.c b/fsck_hfs.tproj/dfalib/SVerify1.c
74
+index c272d4d..a273bf3 100644
75
+--- a/fsck_hfs.tproj/dfalib/SVerify1.c
76
++++ b/fsck_hfs.tproj/dfalib/SVerify1.c
77
+@@ -789,8 +789,8 @@ OSErr	CreateExtentsBTreeControlBlock( SGlobPtr GPtr )
78
+ 	//
79
+ 	//	set up our DFA extended BTCB area.  Will we have enough memory on all HFS+ volumes.
80
+ 	//
81
+-	btcb->refCon = (UInt32) AllocateClearMemory( sizeof(BTreeExtensionsRec) );			// allocate space for our BTCB extensions
82
+-	if ( btcb->refCon == (UInt32) nil ) {
83
++	btcb->refCon = AllocateClearMemory( sizeof(BTreeExtensionsRec) );			// allocate space for our BTCB extensions
84
++	if ( btcb->refCon == nil ) {
85
+ 		err = R_NoMem;
86
+ 		goto exit;
87
+ 	}
88
+@@ -1144,8 +1144,8 @@ OSErr	CreateCatalogBTreeControlBlock( SGlobPtr GPtr )
89
+ 	//	set up our DFA extended BTCB area.  Will we have enough memory on all HFS+ volumes.
90
+ 	//
91
+ 
92
+-	btcb->refCon = (UInt32) AllocateClearMemory( sizeof(BTreeExtensionsRec) );			// allocate space for our BTCB extensions
93
+-	if ( btcb->refCon == (UInt32)nil ) {
94
++	btcb->refCon = AllocateClearMemory( sizeof(BTreeExtensionsRec) );			// allocate space for our BTCB extensions
95
++	if ( btcb->refCon == nil ) {
96
+ 		err = R_NoMem;
97
+ 		goto exit;
98
+ 	}
99
+@@ -1779,8 +1779,8 @@ OSErr	CreateAttributesBTreeControlBlock( SGlobPtr GPtr )
100
+ 	//
101
+ 	//	set up our DFA extended BTCB area.  Will we have enough memory on all HFS+ volumes.
102
+ 	//
103
+-	btcb->refCon = (UInt32) AllocateClearMemory( sizeof(BTreeExtensionsRec) );			// allocate space for our BTCB extensions
104
+-	if ( btcb->refCon == (UInt32)nil ) {
105
++	btcb->refCon = AllocateClearMemory( sizeof(BTreeExtensionsRec) );			// allocate space for our BTCB extensions
106
++	if ( btcb->refCon == nil ) {
107
+ 		err = R_NoMem;
108
+ 		goto exit;
109
+ 	}
110
+@@ -1793,7 +1793,7 @@ OSErr	CreateAttributesBTreeControlBlock( SGlobPtr GPtr )
111
+ 	}
112
+ 	else
113
+ 	{
114
+-		if ( btcb->refCon == (UInt32)nil ) {
115
++		if ( btcb->refCon == nil ) {
116
+ 			err = R_NoMem;
117
+ 			goto exit;
118
+ 		}
119
+diff --git a/fsck_hfs.tproj/dfalib/hfs_endian.c b/fsck_hfs.tproj/dfalib/hfs_endian.c
120
+index 69500c1..3cc9eb4 100755
121
+--- a/fsck_hfs.tproj/dfalib/hfs_endian.c
122
++++ b/fsck_hfs.tproj/dfalib/hfs_endian.c
123
+@@ -437,7 +437,7 @@ hfs_swap_HFSPlusBTInternalNode (
124
+     BTNodeDescriptor *srcDesc = src->buffer;
125
+     UInt16 *srcOffs = (UInt16 *)((char *)src->buffer + (src->blockSize - (srcDesc->numRecords * sizeof (UInt16))));
126
+ 	char *nextRecord;	/*  Points to start of record following current one */
127
+-    UInt32 i;
128
++    int i;
129
+     UInt32 j;
130
+ 
131
+     if (fileID == kHFSExtentsFileID) {

+ 291
- 0
utils/hfsprogs/patches/0005-Remove-Apple-specific-p-from-strings.patch Переглянути файл

@@ -0,0 +1,291 @@
1
+From: =?UTF-8?q?Rog=C3=A9rio=20Brito?= <rbrito@ime.usp.br>
2
+Date: Thu, 24 Oct 2013 01:11:21 -0200
3
+Subject: Remove (Apple-specific?) \p from strings
4
+
5
+Modify the way that debug messages are sent to the user, by eliminating one
6
+character of them.
7
+---
8
+ fsck_hfs.tproj/dfalib/BTreeTreeOps.c | 48 ++++++++++++++++++------------------
9
+ fsck_hfs.tproj/dfalib/SBTree.c       | 14 +++++------
10
+ 2 files changed, 31 insertions(+), 31 deletions(-)
11
+
12
+diff --git a/fsck_hfs.tproj/dfalib/BTreeTreeOps.c b/fsck_hfs.tproj/dfalib/BTreeTreeOps.c
13
+index b812b14..37fb170 100644
14
+--- a/fsck_hfs.tproj/dfalib/BTreeTreeOps.c
15
++++ b/fsck_hfs.tproj/dfalib/BTreeTreeOps.c
16
+@@ -223,7 +223,7 @@ OSStatus	SearchTree	(BTreeControlBlockPtr	 btreePtr,
17
+         //
18
+         if (curNodeNum == 0)
19
+         {
20
+-//          Panic("\pSearchTree: curNodeNum is zero!");
21
++            Panic("SearchTree: curNodeNum is zero!");
22
+             err = fsBTInvalidNodeErr;
23
+             goto ErrorExit;
24
+         }
25
+@@ -433,7 +433,7 @@ OSStatus	InsertLevel (BTreeControlBlockPtr		 btreePtr,
26
+ 		M_ExitOnError (err);
27
+ 		
28
+ 		if ( DEBUG_BUILD && updateParent && newRoot )
29
+-			DebugStr("\p InsertLevel: New root from primary key, update from secondary key...");
30
++			DebugStr("InsertLevel: New root from primary key, update from secondary key...");
31
+ 	}
32
+ 
33
+ 	//////////////////////// Update Parent(s) ///////////////////////////////
34
+@@ -448,7 +448,7 @@ OSStatus	InsertLevel (BTreeControlBlockPtr		 btreePtr,
35
+ 		
36
+ 		secondaryKey = nil;
37
+ 		
38
+-		PanicIf ( (level == btreePtr->treeDepth), "\p InsertLevel: unfinished insert!?");
39
++		PanicIf ( (level == btreePtr->treeDepth), "InsertLevel: unfinished insert!?");
40
+ 
41
+ 		++level;
42
+ 
43
+@@ -456,7 +456,7 @@ OSStatus	InsertLevel (BTreeControlBlockPtr		 btreePtr,
44
+ 		index = treePathTable [level].index;
45
+ 		parentNodeNum = treePathTable [level].node;
46
+ 
47
+-		PanicIf ( parentNodeNum == 0, "\p InsertLevel: parent node is zero!?");
48
++		PanicIf ( parentNodeNum == 0, "InsertLevel: parent node is zero!?");
49
+ 
50
+ 		err = GetNode (btreePtr, parentNodeNum, &parentNode);	// released as target node in next level up
51
+ 		M_ExitOnError (err);
52
+@@ -470,7 +470,7 @@ OSStatus	InsertLevel (BTreeControlBlockPtr		 btreePtr,
53
+ 		{
54
+ 			//¥¥Êdebug: check if ptr == targetNodeNum
55
+ 			GetRecordByIndex (btreePtr, parentNode.buffer, index, &keyPtr, &recPtr, &recSize);
56
+-			PanicIf( (*(UInt32 *) recPtr) != targetNodeNum, "\p InsertLevel: parent ptr doesn't match target node!");
57
++			PanicIf( (*(UInt32 *) recPtr) != targetNodeNum, "InsertLevel: parent ptr doesn't match target node!");
58
+ 			
59
+ 			// need to delete and re-insert this parent key/ptr
60
+ 			// we delete it here and it gets re-inserted in the
61
+@@ -532,7 +532,7 @@ ErrorExit:
62
+ 	(void) ReleaseNode (btreePtr, targetNode);
63
+ 	(void) ReleaseNode (btreePtr, &siblingNode);
64
+ 
65
+-	Panic ("\p InsertLevel: an error occured!");
66
++	Panic ("InsertLevel: an error occured!");
67
+ 
68
+ 	return	err;
69
+ 
70
+@@ -566,7 +566,7 @@ static OSErr	InsertNode	(BTreeControlBlockPtr	 btreePtr,
71
+ 
72
+ 	*rootSplit = false;
73
+ 	
74
+-	PanicIf ( targetNode->buffer == siblingNode->buffer, "\p InsertNode: targetNode == siblingNode, huh?");
75
++	PanicIf ( targetNode->buffer == siblingNode->buffer, "InsertNode: targetNode == siblingNode, huh?");
76
+ 	
77
+ 	leftNodeNum = ((NodeDescPtr) targetNode->buffer)->bLink;
78
+ 	rightNodeNum = ((NodeDescPtr) targetNode->buffer)->fLink;
79
+@@ -606,7 +606,7 @@ static OSErr	InsertNode	(BTreeControlBlockPtr	 btreePtr,
80
+ 	
81
+ 	if ( leftNodeNum > 0 )
82
+ 	{
83
+-		PanicIf ( siblingNode->buffer != nil, "\p InsertNode: siblingNode already aquired!");
84
++		PanicIf ( siblingNode->buffer != nil, "InsertNode: siblingNode already aquired!");
85
+ 
86
+ 		if ( siblingNode->buffer == nil )
87
+ 		{
88
+@@ -614,7 +614,7 @@ static OSErr	InsertNode	(BTreeControlBlockPtr	 btreePtr,
89
+ 			M_ExitOnError (err);
90
+ 		}
91
+ 
92
+-		PanicIf ( ((NodeDescPtr) siblingNode->buffer)->fLink != nodeNum, "\p InsertNode, RotateLeft: invalid sibling link!" );
93
++		PanicIf ( ((NodeDescPtr) siblingNode->buffer)->fLink != nodeNum, "InsertNode, RotateLeft: invalid sibling link!" );
94
+ 
95
+ 		if ( !key->skipRotate )		// are rotates allowed?
96
+ 		{
97
+@@ -703,7 +703,7 @@ OSStatus	DeleteTree			(BTreeControlBlockPtr		 btreePtr,
98
+ 
99
+ 	targetNodeNum = treePathTable[level].node;
100
+ 	targetNodePtr = targetNode->buffer;
101
+-	PanicIf (targetNodePtr == nil, "\pDeleteTree: targetNode has nil buffer!");
102
++	PanicIf (targetNodePtr == nil, "DeleteTree: targetNode has nil buffer!");
103
+ 
104
+ 	DeleteRecord (btreePtr, targetNodePtr, index);
105
+ 		
106
+@@ -797,7 +797,7 @@ OSStatus	DeleteTree			(BTreeControlBlockPtr		 btreePtr,
107
+ 			 
108
+ 			//¥¥Êdebug: check if ptr == targetNodeNum
109
+ 			GetRecordByIndex (btreePtr, parentNode.buffer, index, &keyPtr, &recPtr, &recSize);
110
+-			PanicIf( (*(UInt32 *) recPtr) != targetNodeNum, "\p DeleteTree: parent ptr doesn't match targetNodeNum!!");
111
++			PanicIf( (*(UInt32 *) recPtr) != targetNodeNum, " DeleteTree: parent ptr doesn't match targetNodeNum!!");
112
+ 			
113
+ 			// need to delete and re-insert this parent key/ptr
114
+ 			DeleteRecord (btreePtr, parentNode.buffer, index);
115
+@@ -1018,7 +1018,7 @@ static OSStatus	RotateLeft		(BTreeControlBlockPtr		 btreePtr,
116
+ 										keyPtr, keyLength, recPtr, recSize);
117
+ 			if ( !didItFit )
118
+ 			{
119
+-				Panic ("\pRotateLeft: InsertKeyRecord (left) returned false!");
120
++				Panic ("RotateLeft: InsertKeyRecord (left) returned false!");
121
+ 				err = fsBTBadRotateErr;
122
+ 				goto ErrorExit;
123
+ 			}
124
+@@ -1031,7 +1031,7 @@ static OSStatus	RotateLeft		(BTreeControlBlockPtr		 btreePtr,
125
+ 			didItFit = RotateRecordLeft (btreePtr, leftNode, rightNode);
126
+ 			if ( !didItFit )
127
+ 			{
128
+-				Panic ("\pRotateLeft: RotateRecordLeft returned false!");
129
++				Panic ("RotateLeft: RotateRecordLeft returned false!");
130
+ 				err = fsBTBadRotateErr;
131
+ 				goto ErrorExit;
132
+ 			}
133
+@@ -1048,7 +1048,7 @@ static OSStatus	RotateLeft		(BTreeControlBlockPtr		 btreePtr,
134
+ 									keyPtr, keyLength, recPtr, recSize);
135
+ 		if ( !didItFit )
136
+ 		{
137
+-			Panic ("\pRotateLeft: InsertKeyRecord (right) returned false!");
138
++			Panic ("RotateLeft: InsertKeyRecord (right) returned false!");
139
+ 			err = fsBTBadRotateErr;
140
+ 			goto ErrorExit;
141
+ 		}
142
+@@ -1117,7 +1117,7 @@ static OSStatus	SplitLeft		(BTreeControlBlockPtr		 btreePtr,
143
+ 	right = rightNode->buffer;
144
+ 	left  = leftNode->buffer;
145
+ 	
146
+-	PanicIf ( right->bLink != 0 && left == 0, "\p SplitLeft: left sibling missing!?" );
147
++	PanicIf ( right->bLink != 0 && left == 0, " SplitLeft: left sibling missing!?" );
148
+ 	
149
+ 	//¥¥ type should be kLeafNode or kIndexNode
150
+ 	
151
+@@ -1240,8 +1240,8 @@ static OSStatus	AddNewRootNode	(BTreeControlBlockPtr	 btreePtr,
152
+ 	Boolean				didItFit;
153
+ 	UInt16				keyLength;	
154
+ 	
155
+-	PanicIf (leftNode == nil, "\pAddNewRootNode: leftNode == nil");
156
+-	PanicIf (rightNode == nil, "\pAddNewRootNode: rightNode == nil");
157
++	PanicIf (leftNode == nil, "AddNewRootNode: leftNode == nil");
158
++	PanicIf (rightNode == nil, "AddNewRootNode: rightNode == nil");
159
+ 	
160
+ 	
161
+ 	/////////////////////// Initialize New Root Node ////////////////////////////
162
+@@ -1264,7 +1264,7 @@ static OSStatus	AddNewRootNode	(BTreeControlBlockPtr	 btreePtr,
163
+ 	didItFit = InsertKeyRecord ( btreePtr, rootNode.buffer, 0, keyPtr, keyLength,
164
+ 								 (UInt8 *) &rightNode->bLink, 4 );
165
+ 
166
+-	PanicIf ( !didItFit, "\pAddNewRootNode:InsertKeyRecord failed for left index record");
167
++	PanicIf ( !didItFit, "AddNewRootNode:InsertKeyRecord failed for left index record");
168
+ 
169
+ 
170
+ 	//////////////////// Insert Right Node Index Record /////////////////////////
171
+@@ -1275,7 +1275,7 @@ static OSStatus	AddNewRootNode	(BTreeControlBlockPtr	 btreePtr,
172
+ 	didItFit = InsertKeyRecord ( btreePtr, rootNode.buffer, 1, keyPtr, keyLength,
173
+ 								 (UInt8 *) &leftNode->fLink, 4 );
174
+ 
175
+-	PanicIf ( !didItFit, "\pAddNewRootNode:InsertKeyRecord failed for right index record");
176
++	PanicIf ( !didItFit, "AddNewRootNode:InsertKeyRecord failed for right index record");
177
+ 
178
+ 
179
+ #if DEBUG_TREEOPS
180
+@@ -1355,7 +1355,7 @@ static OSStatus	SplitRight		(BTreeControlBlockPtr		 btreePtr,
181
+ 	}
182
+ 	rightPtr = rightNodePtr->buffer;
183
+ 	
184
+-	PanicIf ( leftPtr->fLink != 0 && rightPtr == 0, "\p SplitRight: right sibling missing!?" );
185
++	PanicIf ( leftPtr->fLink != 0 && rightPtr == 0, "SplitRight: right sibling missing!?" );
186
+ 	
187
+ 	//¥¥ type should be kLeafNode or kIndexNode
188
+ 	
189
+@@ -1557,7 +1557,7 @@ static OSStatus	RotateRight		(BTreeControlBlockPtr		 btreePtr,
190
+ 									keyPtr, keyLength, recPtr, recSize);
191
+ 		if ( !didItFit )
192
+ 		{
193
+-			Panic ("\pRotateRight: InsertKeyRecord (left) returned false!");
194
++			Panic ("RotateRight: InsertKeyRecord (left) returned false!");
195
+ 			err = fsBTBadRotateErr;
196
+ 			goto ErrorExit;
197
+ 		}
198
+@@ -1572,7 +1572,7 @@ static OSStatus	RotateRight		(BTreeControlBlockPtr		 btreePtr,
199
+ 		didItFit = RotateRecordRight( btreePtr, leftNodePtr, rightNodePtr );
200
+ 		if ( !didItFit )
201
+ 		{
202
+-			Panic ("\pRotateRight: RotateRecordRight returned false!");
203
++			Panic ("RotateRight: RotateRecordRight returned false!");
204
+ 			err = fsBTBadRotateErr;
205
+ 			goto ErrorExit;
206
+ 		}
207
+@@ -1583,7 +1583,7 @@ static OSStatus	RotateRight		(BTreeControlBlockPtr		 btreePtr,
208
+ 										keyPtr, keyLength, recPtr, recSize);
209
+ 			if ( !didItFit )
210
+ 			{
211
+-				Panic ("\pRotateRight: InsertKeyRecord (left) returned false!");
212
++				Panic ("RotateRight: InsertKeyRecord (left) returned false!");
213
+ 				err = fsBTBadRotateErr;
214
+ 				goto ErrorExit;
215
+ 			}
216
+@@ -1607,7 +1607,7 @@ static OSStatus	RotateRight		(BTreeControlBlockPtr		 btreePtr,
217
+ 									keyPtr, keyLength, recPtr, recSize);
218
+ 		if ( !didItFit )
219
+ 		{
220
+-			Panic ("\pRotateRight: InsertKeyRecord (right) returned false!");
221
++			Panic ("RotateRight: InsertKeyRecord (right) returned false!");
222
+ 			err = fsBTBadRotateErr;
223
+ 			goto ErrorExit;
224
+ 		}
225
+diff --git a/fsck_hfs.tproj/dfalib/SBTree.c b/fsck_hfs.tproj/dfalib/SBTree.c
226
+index cd81b13..eeb4e8c 100644
227
+--- a/fsck_hfs.tproj/dfalib/SBTree.c
228
++++ b/fsck_hfs.tproj/dfalib/SBTree.c
229
+@@ -103,7 +103,7 @@ OSErr SearchBTreeRecord(SFCB *fcb, const void* key, UInt32 hint, void* foundKey,
230
+ 			CopyMemory(&resultIterator->key, foundKey, CalcKeySize(btcb, &resultIterator->key));	//¥¥ warning, this could overflow user's buffer!!!
231
+ 
232
+ 		if ( DEBUG_BUILD && !ValidHFSRecord(data, btcb, *dataSize) )
233
+-			DebugStr("\pSearchBTreeRecord: bad record?");
234
++			DebugStr("SearchBTreeRecord: bad record?");
235
+ 	}
236
+ 
237
+ ErrorExit:
238
+@@ -211,7 +211,7 @@ OSErr GetBTreeRecord(SFCB *fcb, SInt16 selectionIndex, void* key, void* data, UI
239
+ 		CopyMemory(&iterator->key, key, CalcKeySize(btcb, &iterator->key));	//¥¥ warning, this could overflow user's buffer!!!
240
+ 		
241
+ 		if ( DEBUG_BUILD && !ValidHFSRecord(data, btcb, *dataSize) )
242
+-			DebugStr("\pGetBTreeRecord: bad record?");
243
++			DebugStr("GetBTreeRecord: bad record?");
244
+ 
245
+ 	}
246
+ 	
247
+@@ -243,7 +243,7 @@ OSErr InsertBTreeRecord(SFCB *fcb, const void* key, const void* data, UInt16 dat
248
+ 	CopyMemory(key, &iterator.key, CalcKeySize(btcb, (BTreeKey *) key));	//¥¥ should we range check against maxkeylen?
249
+ 
250
+ 	if ( DEBUG_BUILD && !ValidHFSRecord(data, btcb, dataSize) )
251
+-		DebugStr("\pInsertBTreeRecord: bad record?");
252
++		DebugStr("InsertBTreeRecord: bad record?");
253
+ 
254
+ 	result = BTInsertRecord( fcb, &iterator, &btRecord, dataSize );
255
+ 
256
+@@ -305,7 +305,7 @@ OSErr ReplaceBTreeRecord(SFCB *fcb, const void* key, UInt32 hint, void *newData,
257
+ 	CopyMemory(key, &iterator.key, CalcKeySize(btcb, (BTreeKey *) key));		//¥¥ should we range check against maxkeylen?
258
+ 
259
+ 	if ( DEBUG_BUILD && !ValidHFSRecord(newData, btcb, dataSize) )
260
+-		DebugStr("\pReplaceBTreeRecord: bad record?");
261
++		DebugStr("ReplaceBTreeRecord: bad record?");
262
+ 
263
+ 	result = BTReplaceRecord( fcb, &iterator, &btRecord, dataSize );
264
+ 
265
+@@ -344,7 +344,7 @@ SetEndOfForkProc ( SFCB *filePtr, FSSize minEOF, FSSize maxEOF )
266
+ 	else
267
+ 	{
268
+ 		if ( DEBUG_BUILD )
269
+-			DebugStr("\pSetEndOfForkProc: minEOF is smaller than current size!");
270
++			DebugStr("SetEndOfForkProc: minEOF is smaller than current size!");
271
+ 		return -1;
272
+ 	}
273
+ 
274
+@@ -370,7 +370,7 @@ SetEndOfForkProc ( SFCB *filePtr, FSSize minEOF, FSSize maxEOF )
275
+ 	//	Make sure we got at least as much space as we needed
276
+ 	//
277
+ 	if (filePtr->fcbLogicalSize < minEOF) {
278
+-		Panic("\pSetEndOfForkProc: disk too full to extend B-tree file");
279
++		Panic("SetEndOfForkProc: disk too full to extend B-tree file");
280
+ 		return dskFulErr;
281
+ 	}
282
+ 	
283
+@@ -442,7 +442,7 @@ static OSErr CheckBTreeKey(const BTreeKey *key, const BTreeControlBlock *btcb)
284
+ 	if ( (keyLen < 6) || (keyLen > btcb->maxKeyLength) )
285
+ 	{
286
+ 		if ( DEBUG_BUILD )
287
+-			DebugStr("\pCheckBTreeKey: bad key length!");
288
++			DebugStr("CheckBTreeKey: bad key length!");
289
+ 		return fsBTInvalidKeyLengthErr;
290
+ 	}
291
+ 	

+ 37
- 0
utils/hfsprogs/patches/0006-Adjust-types-for-printing.patch Переглянути файл

@@ -0,0 +1,37 @@
1
+From: =?UTF-8?q?Rog=C3=A9rio=20Brito?= <rbrito@ime.usp.br>
2
+Date: Thu, 24 Oct 2013 01:11:21 -0200
3
+Subject: Adjust types for printing
4
+
5
+Try to address the issues of a given integral type having different sizes
6
+in 32 and 64-bit architectures.
7
+---
8
+ fsck_hfs.tproj/dfalib/SControl.c   | 2 +-
9
+ fsck_hfs.tproj/dfalib/hfs_endian.c | 2 +-
10
+ 2 files changed, 2 insertions(+), 2 deletions(-)
11
+
12
+diff --git a/fsck_hfs.tproj/dfalib/SControl.c b/fsck_hfs.tproj/dfalib/SControl.c
13
+index 4ce9e16..8b03ece 100644
14
+--- a/fsck_hfs.tproj/dfalib/SControl.c
15
++++ b/fsck_hfs.tproj/dfalib/SControl.c
16
+@@ -776,7 +776,7 @@ static int ScavSetUp( SGlob *GPtr)
17
+ 		pointer = (ScavStaticStructures *) AllocateClearMemory( sizeof(ScavStaticStructures) );
18
+ 		if ( pointer == nil ) {
19
+ 			if ( GPtr->logLevel >= kDebugLog ) {
20
+-				printf( "\t error %d - could not allocate %ld bytes of memory \n",
21
++				printf( "\t error %d - could not allocate %i bytes of memory \n",
22
+ 					R_NoMem, sizeof(ScavStaticStructures) );
23
+ 			}
24
+ 			return( R_NoMem );
25
+diff --git a/fsck_hfs.tproj/dfalib/hfs_endian.c b/fsck_hfs.tproj/dfalib/hfs_endian.c
26
+index 3cc9eb4..6ca2ac1 100755
27
+--- a/fsck_hfs.tproj/dfalib/hfs_endian.c
28
++++ b/fsck_hfs.tproj/dfalib/hfs_endian.c
29
+@@ -563,7 +563,7 @@ hfs_swap_HFSPlusBTInternalNode (
30
+             /* Make sure name length is consistent with key length */
31
+             if (keyLength < sizeof(srcKey->parentID) + sizeof(srcKey->nodeName.length) +
32
+                 srcKey->nodeName.length*sizeof(srcKey->nodeName.unicode[0])) {
33
+-				if (debug) printf("hfs_swap_HFSPlusBTInternalNode: catalog record #%d keyLength=%d expected=%lu\n",
34
++				if (debug) printf("hfs_swap_HFSPlusBTInternalNode: catalog record #%d keyLength=%d expected=%i\n",
35
+ 					srcDesc->numRecords-i, keyLength, sizeof(srcKey->parentID) + sizeof(srcKey->nodeName.length) +
36
+                     srcKey->nodeName.length*sizeof(srcKey->nodeName.unicode[0]));
37
+ 				WriteError(fcb->fcbVolume->vcbGPtr, E_KeyLen, fcb->fcbFileID, src->blockNum);

+ 23
- 0
utils/hfsprogs/patches/0007-Fix-path-for-HFS-wrapper-block.patch Переглянути файл

@@ -0,0 +1,23 @@
1
+From: =?UTF-8?q?Rog=C3=A9rio=20Brito?= <rbrito@ime.usp.br>
2
+Date: Thu, 24 Oct 2013 01:11:21 -0200
3
+Subject: Fix path for HFS wrapper block
4
+
5
+Fix the installation of the HFS wrapper block to be compliant in Linux
6
+systems (since it is arch independent).
7
+---
8
+ newfs_hfs.tproj/makehfs.c | 2 +-
9
+ 1 file changed, 1 insertion(+), 1 deletion(-)
10
+
11
+diff --git a/newfs_hfs.tproj/makehfs.c b/newfs_hfs.tproj/makehfs.c
12
+index 7609779..2233ef7 100644
13
+--- a/newfs_hfs.tproj/makehfs.c
14
++++ b/newfs_hfs.tproj/makehfs.c
15
+@@ -70,7 +70,7 @@ extern Boolean _CFStringGetFileSystemRepresentation(CFStringRef string, UInt8 *b
16
+ #include "readme.h"
17
+ 
18
+ 
19
+-#define HFS_BOOT_DATA	"/usr/share/misc/hfsbootdata"
20
++#define HFS_BOOT_DATA	"/usr/share/hfsprogs/hfsbootdata"
21
+ 
22
+ #define HFS_JOURNAL_FILE	".journal"
23
+ #define HFS_JOURNAL_INFO	".journal_info_block"

+ 40
- 0
utils/hfsprogs/patches/0008-Provide-command-line-option-a.patch Переглянути файл

@@ -0,0 +1,40 @@
1
+From: =?UTF-8?q?Rog=C3=A9rio=20Brito?= <rbrito@ime.usp.br>
2
+Date: Thu, 24 Oct 2013 01:11:21 -0200
3
+Subject: Provide command line option -a
4
+
5
+Create a new command line option (-a) for the fsck.hfsplus that has the same
6
+behavior that the -p option has, for greater compatibility with other tools.
7
+---
8
+ fsck_hfs.tproj/fsck_hfs.c | 5 +++--
9
+ 1 file changed, 3 insertions(+), 2 deletions(-)
10
+
11
+diff --git a/fsck_hfs.tproj/fsck_hfs.c b/fsck_hfs.tproj/fsck_hfs.c
12
+index f1a18bd..6117698 100644
13
+--- a/fsck_hfs.tproj/fsck_hfs.c
14
++++ b/fsck_hfs.tproj/fsck_hfs.c
15
+@@ -104,7 +104,7 @@ main(argc, argv)
16
+ 	else
17
+ 		progname = *argv;
18
+ 
19
+-	while ((ch = getopt(argc, argv, "c:D:dfglm:npqruy")) != EOF) {
20
++	while ((ch = getopt(argc, argv, "c:D:dfglm:napqruy")) != EOF) {
21
+ 		switch (ch) {
22
+ 		case 'c':
23
+ 			/* Cache size to use in fsck_hfs */
24
+@@ -169,6 +169,7 @@ main(argc, argv)
25
+ 			yflag = 0;
26
+ 			break;
27
+ 
28
++		case 'a':
29
+ 		case 'p':
30
+ 			preen++;
31
+ 			break;
32
+@@ -572,7 +573,7 @@ usage()
33
+ 	(void) fprintf(stderr, "  l = live fsck (lock down and test-only)\n");
34
+ 	(void) fprintf(stderr, "  m arg = octal mode used when creating lost+found directory \n");
35
+ 	(void) fprintf(stderr, "  n = assume a no response \n");
36
+-	(void) fprintf(stderr, "  p = just fix normal inconsistencies \n");
37
++	(void) fprintf(stderr, "  p, a = just fix normal inconsistencies \n");
38
+ 	(void) fprintf(stderr, "  q = quick check returns clean, dirty, or failure \n");
39
+ 	(void) fprintf(stderr, "  r = rebuild catalog btree \n");
40
+ 	(void) fprintf(stderr, "  u = usage \n");

+ 187
- 0
utils/hfsprogs/patches/0009-Rename-dprintf-to-dbg_printf.patch Переглянути файл

@@ -0,0 +1,187 @@
1
+From: =?UTF-8?q?Rog=C3=A9rio=20Brito?= <rbrito@ime.usp.br>
2
+Date: Thu, 24 Oct 2013 01:11:21 -0200
3
+Subject: Rename dprintf to dbg_printf
4
+
5
+---
6
+ fsck_hfs.tproj/dfalib/SRepair.c  | 18 +++++++++---------
7
+ fsck_hfs.tproj/dfalib/SVerify1.c |  6 +++---
8
+ fsck_hfs.tproj/fsck_debug.c      | 10 +++++-----
9
+ fsck_hfs.tproj/fsck_debug.h      | 10 +++++-----
10
+ 4 files changed, 22 insertions(+), 22 deletions(-)
11
+
12
+diff --git a/fsck_hfs.tproj/dfalib/SRepair.c b/fsck_hfs.tproj/dfalib/SRepair.c
13
+index 8eb759c..89c12d6 100644
14
+--- a/fsck_hfs.tproj/dfalib/SRepair.c
15
++++ b/fsck_hfs.tproj/dfalib/SRepair.c
16
+@@ -1825,13 +1825,13 @@ static OSErr FixAttrSize(SGlobPtr GPtr, RepairOrderPtr p)
17
+ 	result = BTSearchRecord(GPtr->calculatedAttributesFCB, &iterator, 
18
+ 				kInvalidMRUCacheKey, &btRecord, &recSize, &iterator);
19
+ 	if (result) {
20
+-		dprintf (d_error|d_xattr, "%s: Cannot find attribute record (err = %d)\n", __FUNCTION__, result);
21
++		dbg_printf (d_error|d_xattr, "%s: Cannot find attribute record (err = %d)\n", __FUNCTION__, result);
22
+ 		goto out;
23
+ 	}
24
+ 
25
+ 	/* We should only get record of type kHFSPlusAttrForkData */
26
+ 	if (record.recordType != kHFSPlusAttrForkData) {
27
+-		dprintf (d_error|d_xattr, "%s: Record found is not attribute fork data\n", __FUNCTION__);
28
++		dbg_printf (d_error|d_xattr, "%s: Record found is not attribute fork data\n", __FUNCTION__);
29
+ 		result = btNotFound;
30
+ 		goto out;
31
+ 	}
32
+@@ -1862,7 +1862,7 @@ static OSErr FixAttrSize(SGlobPtr GPtr, RepairOrderPtr p)
33
+ 		result = BTReplaceRecord(GPtr->calculatedAttributesFCB, &iterator,
34
+ 					&btRecord, recSize);
35
+ 		if (result) {
36
+-			dprintf (d_error|d_xattr, "%s: Cannot replace attribute record (err=%d)\n", __FUNCTION__, result);
37
++			dbg_printf (d_error|d_xattr, "%s: Cannot replace attribute record (err=%d)\n", __FUNCTION__, result);
38
+ 			goto out;
39
+ 		}
40
+ 	}
41
+@@ -2058,7 +2058,7 @@ del_overflow_extents:
42
+ 
43
+ 		/* Delete the extent record */ 
44
+ 		err = DeleteBTreeRecord(GPtr->calculatedExtentsFCB, &extentKey);
45
+-		dprintf (d_info, "%s: Deleting extent overflow for fileID=%u, forkType=%u, startBlock=%u\n", __FUNCTION__, fileID, forkType, foundStartBlock);
46
++		dbg_printf (d_info, "%s: Deleting extent overflow for fileID=%u, forkType=%u, startBlock=%u\n", __FUNCTION__, fileID, forkType, foundStartBlock);
47
+ 		if (err) {
48
+ 			goto create_symlink;
49
+ 		}
50
+@@ -3227,12 +3227,12 @@ static OSErr MoveExtent(SGlobPtr GPtr, ExtentInfo *extentInfo)
51
+ 											  &extentData, &recordSize, &foundExtentIndex);
52
+ 				foundLocation = extentsBTree;
53
+ 				if (err != noErr) {
54
+-					dprintf (d_error|d_overlap, "%s: No matching extent record found in extents btree for fileID = %d (err=%d)\n", __FUNCTION__, extentInfo->fileID, err);
55
++					dbg_printf (d_error|d_overlap, "%s: No matching extent record found in extents btree for fileID = %d (err=%d)\n", __FUNCTION__, extentInfo->fileID, err);
56
+ 					goto out;
57
+ 				}
58
+ 			} else {
59
+ 				/* No more extents exist for this file */
60
+-				dprintf (d_error|d_overlap, "%s: No matching extent record found for fileID = %d\n", __FUNCTION__, extentInfo->fileID);
61
++				dbg_printf (d_error|d_overlap, "%s: No matching extent record found for fileID = %d\n", __FUNCTION__, extentInfo->fileID);
62
+ 				goto out;
63
+ 			}
64
+ 		}
65
+@@ -3241,7 +3241,7 @@ static OSErr MoveExtent(SGlobPtr GPtr, ExtentInfo *extentInfo)
66
+ 	err = CopyDiskBlocks(GPtr, extentInfo->startBlock, extentInfo->blockCount, 
67
+ 						 extentInfo->newStartBlock);
68
+ 	if (err != noErr) {
69
+-		dprintf (d_error|d_overlap, "%s: Error in copying disk blocks for fileID = %d (err=%d)\n", __FUNCTION__, extentInfo->fileID, err);
70
++		dbg_printf (d_error|d_overlap, "%s: Error in copying disk blocks for fileID = %d (err=%d)\n", __FUNCTION__, extentInfo->fileID, err);
71
+ 		goto out;
72
+ 	}
73
+ 	
74
+@@ -3260,7 +3260,7 @@ static OSErr MoveExtent(SGlobPtr GPtr, ExtentInfo *extentInfo)
75
+ 
76
+ 	}
77
+ 	if (err != noErr) {
78
+-		dprintf (d_error|d_overlap, "%s: Error in updating extent record for fileID = %d (err=%d)\n", __FUNCTION__, extentInfo->fileID, err);
79
++		dbg_printf (d_error|d_overlap, "%s: Error in updating extent record for fileID = %d (err=%d)\n", __FUNCTION__, extentInfo->fileID, err);
80
+ 		goto out;
81
+ 	}
82
+ 
83
+@@ -3491,7 +3491,7 @@ static OSErr SearchExtentInAttributeBT(SGlobPtr GPtr, ExtentInfo *extentInfo,
84
+ 	result = BTSearchRecord(GPtr->calculatedAttributesFCB, &iterator, 
85
+ 				kInvalidMRUCacheKey, &btRecord, recordSize, &iterator);
86
+ 	if (result) {
87
+-		dprintf (d_error|d_overlap, "%s: Error finding attribute record (err=%d) for fileID = %d, attrname = %d\n", __FUNCTION__, result, extentInfo->fileID, extentInfo->attrname);
88
++		dbg_printf (d_error|d_overlap, "%s: Error finding attribute record (err=%d) for fileID = %d, attrname = %d\n", __FUNCTION__, result, extentInfo->fileID, extentInfo->attrname);
89
+ 		goto out;	
90
+ 	}
91
+ 	
92
+diff --git a/fsck_hfs.tproj/dfalib/SVerify1.c b/fsck_hfs.tproj/dfalib/SVerify1.c
93
+index a273bf3..39bda5c 100644
94
+--- a/fsck_hfs.tproj/dfalib/SVerify1.c
95
++++ b/fsck_hfs.tproj/dfalib/SVerify1.c
96
+@@ -2157,9 +2157,9 @@ CheckAttributeRecord(SGlobPtr GPtr, const HFSPlusAttrKey *key, const HFSPlusAttr
97
+ 	
98
+ 	if (doDelete == true) {
99
+ 		result = DeleteBTreeRecord(GPtr->calculatedAttributesFCB, key);
100
+-		dprintf (d_info|d_xattr, "%s: Deleting attribute %s for fileID %d, type = %d\n", __FUNCTION__, attrname, key->fileID, rec->recordType);
101
++		dbg_printf (d_info|d_xattr, "%s: Deleting attribute %s for fileID %d, type = %d\n", __FUNCTION__, attrname, key->fileID, rec->recordType);
102
+ 		if (result) {
103
+-			dprintf (d_error|d_xattr, "%s: Error in deleting record for %s for fileID %d, type = %d\n", __FUNCTION__, attrname, key->fileID, rec->recordType);
104
++			dbg_printf (d_error|d_xattr, "%s: Error in deleting record for %s for fileID %d, type = %d\n", __FUNCTION__, attrname, key->fileID, rec->recordType);
105
+ 		}
106
+ 		
107
+ 		/* Set flags to mark header and map dirty */
108
+@@ -3034,7 +3034,7 @@ OSErr	CheckFileExtents( SGlobPtr GPtr, UInt32 fileNumber, UInt8 forkType,
109
+ 		//	checkout the extent record first
110
+ 		err = ChkExtRec( GPtr, extents, &lastExtentIndex );
111
+ 		if (err != noErr) {
112
+-			dprintf (d_info, "%s: Bad extent for fileID %u in extent %u for startblock %u\n", __FUNCTION__, fileNumber, lastExtentIndex, blockCount);
113
++			dbg_printf (d_info, "%s: Bad extent for fileID %u in extent %u for startblock %u\n", __FUNCTION__, fileNumber, lastExtentIndex, blockCount);
114
+ 
115
+ 			/* Stop verification if bad extent is found for system file or EA */
116
+ 			if ((fileNumber < kHFSFirstUserCatalogNodeID) ||
117
+diff --git a/fsck_hfs.tproj/fsck_debug.c b/fsck_hfs.tproj/fsck_debug.c
118
+index 1be3fc5..77e8e51 100644
119
+--- a/fsck_hfs.tproj/fsck_debug.c
120
++++ b/fsck_hfs.tproj/fsck_debug.c
121
+@@ -25,18 +25,18 @@
122
+ #include <stdio.h>
123
+ #include <stdarg.h>
124
+ 
125
+-/* Current debug level of fsck_hfs for printing messages via dprintf */
126
++/* Current debug level of fsck_hfs for printing messages via dbg_printf */
127
+ unsigned long cur_debug_level;
128
+ 
129
+-/* Function: dprintf
130
++/* Function: dbg_printf
131
+  *
132
+  * Description: Debug function similar to printf except the first parameter
133
+- * which indicates the type of message to be printed by dprintf. Based on 
134
++ * which indicates the type of message to be printed by dbg_printf. Based on
135
+  * current debug level and the type of message, the function decides 
136
+  * whether to print the message or not.
137
+  *
138
+  * Each unique message type has a bit assigned to it.  The message type 
139
+- * passed to dprintf can be one or combination (OR-ed value) of pre-defined 
140
++ * passed to dbg_printf can be one or combination (OR-ed value) of pre-defined
141
+  * debug message types.  Only the messages whose type have one or more similar
142
+  * bits set in comparison with current global debug level are printed. 
143
+  *
144
+@@ -56,7 +56,7 @@ unsigned long cur_debug_level;
145
+  * Output:
146
+  *	Nothing
147
+  */
148
+-void dprintf (unsigned long type, char *fmt, ...) 
149
++void dbg_printf (unsigned long type, char *fmt, ...)
150
+ {
151
+ 	if (cur_debug_level & type) {
152
+ 		va_list ap;
153
+diff --git a/fsck_hfs.tproj/fsck_debug.h b/fsck_hfs.tproj/fsck_debug.h
154
+index 81e3932..cb1b9be 100644
155
+--- a/fsck_hfs.tproj/fsck_debug.h
156
++++ b/fsck_hfs.tproj/fsck_debug.h
157
+@@ -36,18 +36,18 @@ enum debug_message_type {
158
+ 	d_overlap	=	0x0020 	/* Overlap extents related messages */
159
+ };
160
+ 
161
+-/* Current debug level of fsck_hfs for printing messages via dprintf */
162
++/* Current debug level of fsck_hfs for printing messages via dbg_printf */
163
+ extern unsigned long cur_debug_level;
164
+ 
165
+-/* Function: dprintf
166
++/* Function: dbg_printf
167
+  *
168
+  * Description: Debug function similar to printf except the first parameter
169
+- * which indicates the type of message to be printed by dprintf. Based on 
170
++ * which indicates the type of message to be printed by dbg_printf. Based on
171
+  * current debug level and the type of message, the function decides 
172
+  * whether to print the message or not.
173
+  *
174
+  * Each unique message type has a bit assigned to it.  The message type 
175
+- * passed to dprintf can be one or combination (OR-ed value) of pre-defined 
176
++ * passed to dbg_printf can be one or combination (OR-ed value) of pre-defined
177
+  * debug message types.  Only the messages whose type have one or more similar
178
+  * bits set in comparison with current global debug level are printed. 
179
+  *
180
+@@ -67,6 +67,6 @@ extern unsigned long cur_debug_level;
181
+  * Output:
182
+  *	Nothing
183
+  */
184
+-extern void dprintf (unsigned long message_type, char *format, ...);
185
++extern void dbg_printf (unsigned long message_type, char *format, ...);
186
+ 
187
+ #endif /* __FSCK_DEBUG__ */

+ 1319
- 0
utils/hfsprogs/patches/0010-Rename-custom-macro-nil-with-NULL.patch
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 71
- 0
utils/hfsprogs/patches/0011-Fix-types.patch Переглянути файл

@@ -0,0 +1,71 @@
1
+From: =?UTF-8?q?Rog=C3=A9rio=20Brito?= <rbrito@ime.usp.br>
2
+Date: Thu, 24 Oct 2013 01:11:22 -0200
3
+Subject: Fix types
4
+
5
+---
6
+ fsck_hfs.tproj/cache.c | 30 ++++++++++++++++--------------
7
+ 1 file changed, 16 insertions(+), 14 deletions(-)
8
+
9
+diff --git a/fsck_hfs.tproj/cache.c b/fsck_hfs.tproj/cache.c
10
+index 527088a..540fa0b 100644
11
+--- a/fsck_hfs.tproj/cache.c
12
++++ b/fsck_hfs.tproj/cache.c
13
+@@ -961,20 +961,21 @@ int CacheLookup (Cache_t *cache, uint64_t off, Tag_t **tag)
14
+  */
15
+ int CacheRawRead (Cache_t *cache, uint64_t off, uint32_t len, void *buf)
16
+ {
17
+-	uint64_t	result;
18
++	off_t	result1;
19
++	ssize_t result2;
20
+ 		
21
+ 	/* Both offset and length must be multiples of the device block size */
22
+ 	if (off % cache->DevBlockSize) return (EINVAL);
23
+ 	if (len % cache->DevBlockSize) return (EINVAL);
24
+ 	
25
+ 	/* Seek to the position */
26
+-	result = lseek (cache->FD_R, off, SEEK_SET);
27
+-	if (result < 0) return (errno);
28
+-	if (result != off) return (ENXIO);
29
++	result1 = lseek(cache->FD_R, off, SEEK_SET);
30
++	if (result1 < 0) return (errno);
31
++	if (result1 != off) return (ENXIO);
32
+ 	/* Read into the buffer */
33
+-	result = read (cache->FD_R, buf, len);
34
+-	if (result < 0) return (errno);
35
+-	if (result == 0) return (ENXIO);
36
++	result2 = read(cache->FD_R, buf, len);
37
++	if (result2 < 0) return (errno);
38
++	if (result2 == 0) return (ENXIO);
39
+ 
40
+ 	/* Update counters */
41
+ 	cache->DiskRead++;
42
+@@ -989,21 +990,22 @@ int CacheRawRead (Cache_t *cache, uint64_t off, uint32_t len, void *buf)
43
+  */
44
+ int CacheRawWrite (Cache_t *cache, uint64_t off, uint32_t len, void *buf)
45
+ {
46
+-	uint64_t	result;
47
++	off_t	result1;
48
++	ssize_t result2;
49
+ 	
50
+ 	/* Both offset and length must be multiples of the device block size */
51
+ 	if (off % cache->DevBlockSize) return (EINVAL);
52
+ 	if (len % cache->DevBlockSize) return (EINVAL);
53
+ 	
54
+ 	/* Seek to the position */
55
+-	result = lseek (cache->FD_W, off, SEEK_SET);
56
+-	if (result < 0) return (errno);
57
+-	if (result != off) return (ENXIO);
58
++	result1 = lseek (cache->FD_W, off, SEEK_SET);
59
++	if (result1 < 0) return (errno);
60
++	if (result1 != off) return (ENXIO);
61
+ 	
62
+ 	/* Write into the buffer */
63
+-	result = write (cache->FD_W, buf, len);
64
+-	if (result < 0) return (errno);
65
+-	if (result == 0) return (ENXIO);
66
++	result2 = write (cache->FD_W, buf, len);
67
++	if (result2 < 0) return (errno);
68
++	if (result2 == 0) return (ENXIO);
69
+ 	
70
+ 	/* Update counters */
71
+ 	cache->DiskWrite++;

+ 50
- 0
utils/hfsprogs/patches/0012-Fix-mkfs-not-creating-UUIDs-for-new-filesystems.patch Переглянути файл

@@ -0,0 +1,50 @@
1
+From: Matthew Garrett <mjg59@codon.org.uk>
2
+Date: Thu, 24 Oct 2013 01:11:22 -0200
3
+Subject: Fix mkfs not creating UUIDs for new filesystems.
4
+MIME-Version: 1.0
5
+Content-Type: text/plain; charset=UTF-8
6
+Content-Transfer-Encoding: 8bit
7
+
8
+Fix mkfs not creating UUIDs for new filesystems.
9
+
10
+Thanks to Lars Noodén for reporting the bug at
11
+ <https://bugs.launchpad.net/bugs/737002>.
12
+
13
+This closes LP: #737002.
14
+---
15
+ include/missing.h | 8 +++++++-
16
+ 1 file changed, 7 insertions(+), 1 deletion(-)
17
+
18
+diff --git a/include/missing.h b/include/missing.h
19
+index 0a859c4..f50e8fb 100644
20
+--- a/include/missing.h
21
++++ b/include/missing.h
22
+@@ -72,7 +72,7 @@
23
+ #define NAME_MAX	255
24
+ 
25
+ /* Byteswap stuff */
26
+-#define NXSwapHostLongToBig(x)		cpu_to_be64(x)
27
++#define NXSwapHostLongToBig(x)		cpu_to_be32(x)
28
+ #define NXSwapBigShortToHost(x) 	be16_to_cpu(x)
29
+ #define OSSwapBigToHostInt16(x)		be16_to_cpu(x)
30
+ #define NXSwapBigLongToHost(x)		be32_to_cpu(x)
31
+@@ -88,6 +88,9 @@
32
+ #ifndef be32_to_cpu
33
+ #define be32_to_cpu(x) bswap_32(x)
34
+ #endif
35
++#ifndef cpu_to_be32
36
++#define cpu_to_be32(x) bswap_32(x)
37
++#endif
38
+ #ifndef be64_to_cpu
39
+ #define be64_to_cpu(x) bswap_64(x)
40
+ #endif
41
+@@ -102,6 +105,9 @@
42
+ #ifndef be32_to_cpu
43
+ #define be32_to_cpu(x)	(x)
44
+ #endif
45
++#ifndef cpu_to_be32
46
++#define cpu_to_be32(x)	(x)
47
++#endif
48
+ #ifndef be64_to_cpu
49
+ #define be64_to_cpu(x)	(x)
50
+ #endif

+ 157
- 0
utils/hfsprogs/patches/0013-Fix-manpages.patch Переглянути файл

@@ -0,0 +1,157 @@
1
+From: =?UTF-8?q?Rog=C3=A9rio=20Theodoro=20de=20Brito?= <rbrito@ime.usp.br>
2
+Date: Thu, 25 Nov 2010 00:00:00 -0200
3
+Subject: Fix manpages
4
+MIME-Version: 1.0
5
+Content-Type: text/plain; charset=UTF-8
6
+Content-Transfer-Encoding: 8bit
7
+
8
+Remove typos, references in the "See also" sections of the manpages to
9
+commands that are not available in Debian systems (and, quite probably,
10
+other systems too) and non-Linux specific comments.
11
+
12
+Authored also by Christoph Hellwig <hch@lst.de> and  "A. Costa" <agcosta@gis.net>
13
+
14
+Bug-Debian: http://bugs.debian.org/598714
15
+Bug-Debian: http://bugs.debian.org/575201
16
+Forwarded: no
17
+Reviewed-by: Rogério Theodoro de Brito <rbrito@ime.usp.br>
18
+---
19
+ fsck_hfs.tproj/fsck_hfs.8   | 18 +++++++-----------
20
+ newfs_hfs.tproj/newfs_hfs.8 | 23 ++++++++---------------
21
+ 2 files changed, 15 insertions(+), 26 deletions(-)
22
+
23
+diff --git a/fsck_hfs.tproj/fsck_hfs.8 b/fsck_hfs.tproj/fsck_hfs.8
24
+index aec9949..0bc804d 100644
25
+--- a/fsck_hfs.tproj/fsck_hfs.8
26
++++ b/fsck_hfs.tproj/fsck_hfs.8
27
+@@ -19,18 +19,18 @@
28
+ .Dt FSCK_HFS 8
29
+ .Os "Mac OS X"
30
+ .Sh NAME
31
+-.Nm fsck_hfs
32
++.Nm fsck.hfs
33
+ .Nd HFS file system consistency check
34
+ .Sh SYNOPSIS
35
+-.Nm fsck_hfs
36
++.Nm fsck.hfs
37
+ .Fl q
38
+ .Op Fl df
39
+ .Ar special ...
40
+-.Nm fsck_hfs
41
++.Nm fsck.hfs
42
+ .Fl p
43
+ .Op Fl df
44
+ .Ar special ...
45
+-.Nm fsck_hfs
46
++.Nm fsck.hfs
47
+ .Op Fl n | y | r
48
+ .Op Fl dfgl
49
+ .Op Fl m Ar mode
50
+@@ -52,9 +52,7 @@ The second form of
51
+ preens the specified file systems.
52
+ It is normally started by
53
+ .Xr fsck 8
54
+-run from
55
+-.Pa /etc/rc.boot
56
+-during automatic reboot, when a HFS file system is detected.
57
++during systen boot, when a HFS file system is detected.
58
+ When preening file systems,
59
+ .Nm
60
+ will fix common inconsistencies for file systems that were not
61
+@@ -105,9 +103,9 @@ to check and repair journaled HFS+ file systems.
62
+ .It Fl g
63
+ Causes
64
+ .Nm
65
+-to generate it's output strings in GUI format.
66
++to generate its output strings in GUI format.
67
+ This option is used when another application with a graphical user interface
68
+-(like Mac OS X Disk Utility) is envoking the
69
++(like Mac OS X Disk Utility) is invoking the
70
+ .Nm
71
+ tool.
72
+ .It Fl l
73
+@@ -144,8 +142,6 @@ specified file system for a new catalog file and if there is no damage
74
+ to the leaf nodes in the existing catalog file.
75
+ .El
76
+ .Pp
77
+-Because of inconsistencies between the block device and the buffer cache,
78
+-the raw device should always be used.
79
+ .Sh SEE ALSO
80
+ .Xr fsck 8
81
+ .Sh BUGS
82
+diff --git a/newfs_hfs.tproj/newfs_hfs.8 b/newfs_hfs.tproj/newfs_hfs.8
83
+index d002cc9..fe91962 100644
84
+--- a/newfs_hfs.tproj/newfs_hfs.8
85
++++ b/newfs_hfs.tproj/newfs_hfs.8
86
+@@ -19,10 +19,10 @@
87
+ .Dt NEWFS_HFS 8
88
+ .Os "Mac OS X"
89
+ .Sh NAME
90
+-.Nm newfs_hfs
91
++.Nm mkfs.hfs
92
+ .Nd construct a new HFS Plus file system
93
+ .Sh SYNOPSIS
94
+-.Nm newfs_hfs
95
++.Nm mkfs.hfs
96
+ .Op Fl N Ar [partition-size]
97
+ .Op Fl U Ar uid
98
+ .Op Fl G Ar gid
99
+@@ -37,19 +37,13 @@
100
+ .Op Fl v Ar volume-name
101
+ .Ar special
102
+ .Sh DESCRIPTION
103
+-.Nm Newfs_hfs
104
++.Nm mkfs.hfs
105
+ builds an HFS Plus file system on the specified special device.
106
+-Before running 
107
+-.Nm newfs_hfs
108
+-the disk should be partitioned using the
109
+-.Em Disk Utility
110
+-application or
111
+-.Xr pdisk 8 .
112
+ .Pp
113
+ The file system default parameters are calculated based on
114
+ the size of the disk partition. Typically the defaults are
115
+ reasonable, however
116
+-.Nm newfs_hfs
117
++.Nm mkfs.hfs
118
+ has several options to allow the defaults to be selectively overridden.
119
+ The options are as follows:
120
+ .Bl -tag -width Fl
121
+@@ -66,7 +60,7 @@ Set the group of the file system's root directory to
122
+ Specify the access permissions mask for the file system's root directory.
123
+ .It Fl h
124
+ Creates a legacy HFS format filesystem. This option
125
+-is not recomended for file systems that will be
126
++is not recommended for file systems that will be
127
+ primarily used with Mac OS X or Darwin.
128
+ .It Fl s
129
+ Creates a case-sensitive HFS Plus filesystem. By
130
+@@ -93,7 +87,7 @@ sizes are specified with the
131
+ option followed by a comma
132
+ separated list of the form arg=blocks.
133
+ .Pp
134
+-Example:  -c c=5000,e=500
135
++Example:  \-c c=5000,e=500
136
+ .Bl -tag -width Fl
137
+ .It Em a=blocks
138
+ Set the attribute file clump size.
139
+@@ -126,7 +120,7 @@ the form arg=bytes. The
140
+ size must be a power of two and no larger than
141
+ 32768 bytes.
142
+ .Pp
143
+-Example:  -n c=8192,e=4096
144
++Example:  \-n c=8192,e=4096
145
+ .Bl -tag -width Fl
146
+ .It Em a=bytes
147
+ Set the attribute b-tree node size.
148
+@@ -139,8 +133,7 @@ Set the extent overflow b-tree node size.
149
+ Volume name (file system name) in ascii or UTF-8 format.
150
+ .El
151
+ .Sh SEE ALSO
152
+-.Xr mount 8 ,
153
+-.Xr pdisk 8
154
++.Xr mount 8
155
+ .Sh HISTORY
156
+ The
157
+ .Nm

+ 15
- 0
utils/hfsprogs/patches/0014-uClibc_no_loadavg.patch Переглянути файл

@@ -0,0 +1,15 @@
1
+--- diskdev_cmds-332.25/newfs_hfs.tproj/makehfs.c	2015-03-27 21:58:04.163171675 -0700
2
++++ hfsprogs-332.25/newfs_hfs.tproj/makehfs.c	2015-03-27 21:56:03.687175020 -0700
3
+@@ -2119,10 +2119,12 @@
4
+ 		sysctl(mib, 2, sysctlstring, &datalen, NULL, 0);
5
+ 		SHA1_Update(&context, sysctlstring, datalen);
6
+ #endif
7
++#ifndef __UCLIBC__
8
+ 		/* The system's load average: */
9
+ 		datalen = sizeof(sysloadavg);
10
+ 		getloadavg(sysloadavg, 3);
11
+ 		SHA1_Update(&context, &sysloadavg, datalen);
12
++#endif
13
+ 
14
+ 		/* The system's VM statistics: */
15
+ #if !LINUX