From 979be15e98d2eb0c9a3b0ccf24e52ae7c71a55ac Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 25 Feb 2018 14:25:11 +0100
Subject: Ugly hacks to get things building on Haiku.


diff --git a/configure.ac b/configure.ac
index 5e837c9..0d49ae5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -101,7 +101,8 @@ AC_MSG_ERROR([--with-ldopts no longer supported; use LDFLAGS= instead]))
 dnl
 AC_PROG_CC
 if test "$GCC" = yes; then
-   RDYNAMIC="-rdynamic"
+   #RDYNAMIC="-rdynamic"
+   RDYNAMIC=""
    AC_SUBST(RDYNAMIC)
 fi
 AC_PROG_CPP
@@ -1175,7 +1176,7 @@ dnl Check to see if -lsocket is required (solaris) to make something
 dnl that uses socket() to compile; this is needed for the UUID library
 dnl
 SOCKET_LIB=''
-AC_CHECK_LIB(socket, socket, [SOCKET_LIB=-lsocket])
+AC_SEARCH_LIBS(socket, socket network, SOCKET_LIB=-lnetwork)
 AC_SUBST(SOCKET_LIB)
 dnl
 dnl See if libmagic exists
diff --git a/e2fsck/Makefile.in b/e2fsck/Makefile.in
index 8fe05e0..14d6196 100644
--- a/e2fsck/Makefile.in
+++ b/e2fsck/Makefile.in
@@ -16,7 +16,7 @@ MANPAGES=	e2fsck.8
 FMANPAGES=	e2fsck.conf.5
 
 LIBS= $(LIBSUPPORT) $(LIBEXT2FS) $(LIBCOM_ERR) $(LIBBLKID) $(LIBUUID) \
-	$(LIBINTL) $(LIBE2P) $(LIBMAGIC) $(SYSLIBS)
+	$(LIBINTL) $(LIBE2P) $(LIBMAGIC) $(SYSLIBS) -lbsd
 DEPLIBS= $(DEPLIBSUPPORT) $(LIBEXT2FS) $(DEPLIBCOM_ERR) $(DEPLIBBLKID) \
 	 $(DEPLIBUUID) $(DEPLIBE2P)
 
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index cd5cba2..6e1a7b9 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -19,9 +19,7 @@
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
-#ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
-#endif
 #ifdef HAVE_SETJMP_H
 #include <setjmp.h>
 #endif
diff --git a/misc/create_inode.c b/misc/create_inode.c
index 05aa636..0d0d27c 100644
--- a/misc/create_inode.c
+++ b/misc/create_inode.c
@@ -38,6 +38,11 @@
 #include "create_inode.h"
 #include "support/nls-enable.h"
 
+#ifdef __HAIKU__
+#define major(x) 0
+#define minor(x) (x)
+#endif
+
 /* 64KiB is the minimum blksize to best minimize system call overhead. */
 #define COPY_FILE_BUFLEN	65536
 
-- 
2.16.1


From a3dc9722a2ebbd0320e266c8de4d4b0a8404ab19 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 25 Feb 2018 15:38:54 +0100
Subject: Extra patches.


diff --git a/lib/blkid/devname.c b/lib/blkid/devname.c
index e2b8051..46c9225 100644
--- a/lib/blkid/devname.c
+++ b/lib/blkid/devname.c
@@ -43,6 +43,8 @@
 
 #include "blkidP.h"
 
+#define makedev(maj,min) (min)
+
 /*
  * Find a dev struct in the cache by device name, if available.
  *
diff --git a/lib/blkid/devno.c b/lib/blkid/devno.c
index 34ceb3c..4c9f34a 100644
--- a/lib/blkid/devno.c
+++ b/lib/blkid/devno.c
@@ -37,6 +37,8 @@
 
 #include "blkidP.h"
 
+#define makedev(maj,min) (min)
+
 char *blkid_strndup(const char *s, int length)
 {
 	char *ret;
diff --git a/lib/ext2fs/bmap64.h b/lib/ext2fs/bmap64.h
index d8c7a3c..8ab1174 100644
--- a/lib/ext2fs/bmap64.h
+++ b/lib/ext2fs/bmap64.h
@@ -9,6 +9,8 @@
  * %End-Header%
  */
 
+#include <sys/time.h>
+
 struct ext2_bmap_statistics {
 	int		type;
 	struct timeval	created;
diff --git a/configure.ac b/configure.ac
index ca24553..8bd3a14 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1321,8 +1321,8 @@ esac
 dnl
 dnl Check the available mount options
 dnl
-AX_CHECK_MOUNT_OPT(nosuid)
-AX_CHECK_MOUNT_OPT(nodev)
+dnl AX_CHECK_MOUNT_OPT(nosuid)
+dnl AX_CHECK_MOUNT_OPT(nodev)
 dnl Enable LTO for all packages
 dnl
 AC_ARG_ENABLE([lto],
-- 
2.16.1


From 56244924d08f0fa53f15e606231159a0d287222b Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Thu, 7 Jan 2021 20:23:58 +0100
Subject: [PATCH] Haiku: type loff_t

---
 lib/ext2fs/imager.c | 3 +++
 misc/e2fuzz.c       | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/lib/ext2fs/imager.c b/lib/ext2fs/imager.c
index b3ede9a..a1addee 100644
--- a/lib/ext2fs/imager.c
+++ b/lib/ext2fs/imager.c
@@ -37,6 +37,9 @@
 #ifndef HAVE_TYPE_SSIZE_T
 typedef int ssize_t;
 #endif
+#ifdef __HAIKU__
+typedef off_t loff_t;
+#endif
 
 /*
  * This function returns 1 if the specified block is all zeros
diff --git a/misc/e2fuzz.c b/misc/e2fuzz.c
index 7c0f776..97ffc4a 100644
--- a/misc/e2fuzz.c
+++ b/misc/e2fuzz.c
@@ -42,6 +42,10 @@ static ssize_t my_pwrite(int fd, const void *buf, size_t count, off_t offset)
 }
 #endif /* !defined HAVE_PWRITE64 && !defined HAVE_PWRITE */
 
+#ifdef __HAIKU__
+typedef off_t loff_t;
+#endif
+
 static int getseed(void)
 {
 	int r;
-- 
2.30.0

