summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmds-receive.c2
-rw-r--r--cmds-scrub.c2
-rw-r--r--cmds-send.c2
-rw-r--r--convert.c5
-rw-r--r--kerncompat.h12
-rw-r--r--mkfs.c3
-rw-r--r--restore.c5
7 files changed, 28 insertions, 3 deletions
diff --git a/cmds-receive.c b/cmds-receive.c
index a8be6fa4..a21c0376 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -21,6 +21,8 @@
#define _XOPEN_SOURCE 700
#define _BSD_SOURCE
+#include "kerncompat.h"
+
#include <unistd.h>
#include <stdint.h>
#include <dirent.h>
diff --git a/cmds-scrub.c b/cmds-scrub.c
index 24be20ff..e29db27d 100644
--- a/cmds-scrub.c
+++ b/cmds-scrub.c
@@ -16,6 +16,8 @@
* Boston, MA 021110-1307, USA.
*/
+#include "kerncompat.h"
+
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <sys/stat.h>
diff --git a/cmds-send.c b/cmds-send.c
index 9b47e706..59522c35 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -18,6 +18,8 @@
#define _GNU_SOURCE
+#include "kerncompat.h"
+
#include <unistd.h>
#include <stdint.h>
#include <dirent.h>
diff --git a/convert.c b/convert.c
index fa7bf8c5..1de2a441 100644
--- a/convert.c
+++ b/convert.c
@@ -18,6 +18,9 @@
#define _XOPEN_SOURCE 600
#define _GNU_SOURCE 1
+
+#include "kerncompat.h"
+
#ifndef __CHECKER__
#include <sys/ioctl.h>
#include <sys/mount.h>
@@ -31,7 +34,7 @@
#include <unistd.h>
#include <uuid/uuid.h>
#include <linux/fs.h>
-#include "kerncompat.h"
+
#include "ctree.h"
#include "disk-io.h"
#include "volumes.h"
diff --git a/kerncompat.h b/kerncompat.h
index 46236cd5..d60f7222 100644
--- a/kerncompat.h
+++ b/kerncompat.h
@@ -18,6 +18,7 @@
#ifndef __KERNCOMPAT
#define __KERNCOMPAT
+
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
@@ -57,11 +58,22 @@
#endif
#ifndef __CHECKER__
+/*
+ * Since we're using primitive definitions from kernel-space, we need to
+ * define __KERNEL__ so that system header files know which definitions
+ * to use.
+ */
+#define __KERNEL__
#include <asm/types.h>
typedef __u32 u32;
typedef __u64 u64;
typedef __u16 u16;
typedef __u8 u8;
+/*
+ * Continuing to define __KERNEL__ breaks others parts of the code, so
+ * we can just undefine it now that we have the correct headers...
+ */
+#undef __KERNEL__
#else
typedef unsigned int u32;
typedef unsigned int __u32;
diff --git a/mkfs.c b/mkfs.c
index 47f0c9ca..8fda48a8 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -19,6 +19,8 @@
#define _XOPEN_SOURCE 500
#define _GNU_SOURCE
+#include "kerncompat.h"
+
#ifndef __CHECKER__
#include <sys/ioctl.h>
#include <sys/mount.h>
@@ -37,7 +39,6 @@
#include <linux/fs.h>
#include <ctype.h>
#include <attr/xattr.h>
-#include "kerncompat.h"
#include "ctree.h"
#include "disk-io.h"
#include "volumes.h"
diff --git a/restore.c b/restore.c
index b9e5381f..c447416a 100644
--- a/restore.c
+++ b/restore.c
@@ -18,6 +18,9 @@
#define _XOPEN_SOURCE 500
#define _GNU_SOURCE 1
+
+#include "kerncompat.h"
+
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
@@ -25,7 +28,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <zlib.h>
-#include "kerncompat.h"
+
#include "ctree.h"
#include "disk-io.h"
#include "print-tree.h"