Blob Blame History Raw
diff --git a/lib/sg_pt_linux.c b/lib/sg_pt_linux.c
index 76773fa..914570b 100644
--- a/lib/sg_pt_linux.c
+++ b/lib/sg_pt_linux.c
@@ -18,8 +18,11 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
-#include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/sysmacros.h>      /* to define 'major' */
+#ifndef major
+#include <sys/types.h>
+#endif
 
 
 #ifdef HAVE_CONFIG_H
diff --git a/src/sg_dd.c b/src/sg_dd.c
index 97a6f77..7bb5eed 100644
--- a/src/sg_dd.c
+++ b/src/sg_dd.c
@@ -44,13 +44,15 @@
 #define __STDC_FORMAT_MACROS 1
 #include <inttypes.h>
 #include <sys/ioctl.h>
-#include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/sysmacros.h>
 #include <sys/time.h>
 #include <sys/file.h>
-#include <linux/major.h>
+#include <sys/sysmacros.h>
+#ifndef major
+#include <sys/types.h>
+#endif
 #include <linux/fs.h>   /* <sys/mount.h> */
+#include <linux/major.h>
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/src/sg_map26.c b/src/sg_map26.c
index 7739592..8e583d2 100644
--- a/src/sg_map26.c
+++ b/src/sg_map26.c
@@ -33,8 +33,11 @@
 #include <dirent.h>
 #include <libgen.h>
 #include <sys/ioctl.h>
-#include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/sysmacros.h>      /* new location for major + minor */
+#ifndef major
+#include <sys/types.h>
+#endif
 #include <linux/major.h>
 
 #ifdef HAVE_CONFIG_H
diff --git a/src/sg_read.c b/src/sg_read.c
index 2cf8212..1eb0411 100644
--- a/src/sg_read.c
+++ b/src/sg_read.c
@@ -36,9 +36,11 @@
 #define __STDC_FORMAT_MACROS 1
 #include <inttypes.h>
 #include <sys/ioctl.h>
-#include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/sysmacros.h>
+#ifndef major
+#include <sys/types.h>
+#endif
 #include <sys/mman.h>
 #include <sys/time.h>
 #include <linux/major.h>
diff --git a/src/sg_xcopy.c b/src/sg_xcopy.c
index 11206ac..49b4341 100644
--- a/src/sg_xcopy.c
+++ b/src/sg_xcopy.c
@@ -47,11 +47,13 @@
 #define __STDC_FORMAT_MACROS 1
 #include <inttypes.h>
 #include <sys/ioctl.h>
-#include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/sysmacros.h>
 #include <sys/time.h>
 #include <sys/file.h>
+#include <sys/sysmacros.h>
+#ifndef major
+#include <sys/types.h>
+#endif
 #include <linux/major.h>
 #include <linux/fs.h>   /* <sys/mount.h> */
 
diff --git a/src/sgm_dd.c b/src/sgm_dd.c
index 4e40acc..edf4861 100644
--- a/src/sgm_dd.c
+++ b/src/sgm_dd.c
@@ -48,11 +48,13 @@
 #define __STDC_FORMAT_MACROS 1
 #include <inttypes.h>
 #include <sys/ioctl.h>
-#include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/sysmacros.h>
-#include <sys/mman.h>
 #include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/sysmacros.h>
+#ifndef major
+#include <sys/types.h>
+#endif
 #include <linux/major.h>
 #include <linux/fs.h>   /* <sys/mount.h> */
 
diff --git a/src/sgp_dd.c b/src/sgp_dd.c
index 1ebecca..be9547b 100644
--- a/src/sgp_dd.c
+++ b/src/sgp_dd.c
@@ -43,9 +43,11 @@
 #define __STDC_FORMAT_MACROS 1
 #include <inttypes.h>
 #include <sys/ioctl.h>
-#include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/sysmacros.h>
+#ifndef major
+#include <sys/types.h>
+#endif
 #include <sys/time.h>
 #include <linux/major.h>
 #include <linux/fs.h>   /* <sys/mount.h> */