external: fsck_msdos: fix pointer truncation issue of 64bit

fix the pointer truncation issue of 64bit when porting from 32bit
which cause segment fault.

Change-Id: I2bc1fdbc4308de60d4e80ec65bf1b603198ae87f
diff --git a/dir.c b/dir.c
index 681859b..c9fa9c4 100644
--- a/dir.c
+++ b/dir.c
@@ -384,7 +384,7 @@
 removede(int f, struct bootblock *boot,struct cluster_chain_descriptor *fat, u_char *start,
     u_char *end, cl_t startcl, cl_t endcl, cl_t curcl, char *path, int type)
 {
-	fsck_debug("removede : %u:%u --->> %u:%u \n",startcl,start,endcl,end);
+	fsck_debug("removede : %u:%p --->> %u:%p \n",startcl,start,endcl,end);
 	switch (type) {
 	case 0:
 		pwarn("Invalid long filename entry for %s\n", path);
@@ -425,8 +425,8 @@
 	/*
 	 * Check size on ordinary files
 	 */
-	struct cluster_chain_descriptor *fat,tofind;
-	struct fatcache *cache;
+	struct cluster_chain_descriptor *fat = NULL,tofind;
+	struct fatcache *cache = NULL;
 	u_int64_t physicalSize;
 	const u_int64_t max_physical_size = 0x100000000;
 
@@ -461,7 +461,7 @@
 	}
 
 	if (physicalSize < (u_int64_t)dir->size) {
-		pwarn("size of %s is %u, should at most be %u\n",
+		pwarn("size of %s is %u, should at most be %llu\n",
 		      fullpath(dir), dir->size, physicalSize);
 		fsck_debug("physicalSize:%llu ,dir->size = %d ,dir->head:0x%x\n",physicalSize,dir->size,dir->head);
 		if (ask(1, "Truncate")) {
diff --git a/fatcache.h b/fatcache.h
index db08af0..6db35a6 100644
--- a/fatcache.h
+++ b/fatcache.h
@@ -52,15 +52,20 @@
 #define	fsck_warn		FSCK_SLOGW
 #define	fsck_err		FSCK_SLOGE
 #define	fsck_debug		FSCK_SLOGD
+
+#ifndef offsetof
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
+
 #define container_of(ptr, type, member) \
 	((type *)((unsigned long)(ptr) - offsetof(type, member)))
 int fsck_msdos_cache_compare(struct cluster_chain_descriptor *fat1,struct cluster_chain_descriptor *fat2);
 RB_HEAD(FSCK_MSDOS_CACHE,cluster_chain_descriptor);
-extern RB_FIND(name, x, y);
-extern RB_REMOVE(name, x, y);
-extern RB_NEXT(name, x, y);
-extern RB_INSERT(name, x, y);
+struct cluster_chain_descriptor* FSCK_MSDOS_CACHE_RB_FIND(struct FSCK_MSDOS_CACHE* x, struct cluster_chain_descriptor *y);
+struct cluster_chain_descriptor* FSCK_MSDOS_CACHE_RB_REMOVE(struct FSCK_MSDOS_CACHE* x, struct cluster_chain_descriptor *y);
+struct cluster_chain_descriptor* FSCK_MSDOS_CACHE_RB_NEXT(struct cluster_chain_descriptor *y);
+struct cluster_chain_descriptor* FSCK_MSDOS_CACHE_RB_INSERT(struct FSCK_MSDOS_CACHE* x, struct cluster_chain_descriptor *y);
+struct cluster_chain_descriptor* FSCK_MSDOS_CACHE_RB_MINMAX(struct FSCK_MSDOS_CACHE* x, int val);
 extern struct FSCK_MSDOS_CACHE rb_root;
 extern unsigned int * fat_bitmap;
 typedef unsigned char u_char;
diff --git a/fragment.h b/fragment.h
index b98f1e0..8d86202 100644
--- a/fragment.h
+++ b/fragment.h
@@ -42,8 +42,9 @@
 extern struct FSCK_MSDOS_FRAGMENT rb_free_root,rb_bad_root;
 void free_fragment_tree(struct FSCK_MSDOS_FRAGMENT* head);
 struct fragment* New_fragment(void);
-extern RB_FIND(name, x, y);
-extern RB_REMOVE(name, x, y);
-extern RB_NEXT(name, x, y);
-extern RB_INSERT(name, x, y);
+struct fragment* FSCK_MSDOS_FRAGMENT_RB_FIND(struct FSCK_MSDOS_FRAGMENT* x, struct fragment* y);
+struct fragment* FSCK_MSDOS_FRAGMENT_RB_REMOVE(struct FSCK_MSDOS_FRAGMENT* x, struct fragment* y);
+struct fragment* FSCK_MSDOS_FRAGMENT_RB_NEXT(struct fragment* y);
+struct fragment* FSCK_MSDOS_FRAGMENT_RB_INSERT(struct FSCK_MSDOS_FRAGMENT* x, struct fragment* y);
+struct fragment* FSCK_MSDOS_FRAGMENT_RB_MINMAX(struct FSCK_MSDOS_FRAGMENT* x, int val);
 #endif