Merge changes from topic 'ext4_utils_header'

* changes:
  libfec: Update the header path for ext4_utils.
  ext4_utils: Export headers for libext4_utils* libs.
diff --git a/ext4_utils/Android.mk b/ext4_utils/Android.mk
index a8362b2..16b73c4 100644
--- a/ext4_utils/Android.mk
+++ b/ext4_utils/Android.mk
@@ -24,6 +24,10 @@
 LOCAL_MODULE := libext4_utils_host
 # Various instances of dereferencing a type-punned pointer in extent.c
 LOCAL_CFLAGS += -fno-strict-aliasing
+LOCAL_C_INCLUDES := \
+    $(LOCAL_PATH)/include
+LOCAL_EXPORT_C_INCLUDE_DIRS := \
+    $(LOCAL_PATH)/include
 LOCAL_STATIC_LIBRARIES := \
     libsparse_host \
     libz
@@ -36,6 +40,8 @@
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES := make_ext4fs_main.c
 LOCAL_MODULE := make_ext4fs
+LOCAL_C_INCLUDES := \
+    $(LOCAL_PATH)/include
 LOCAL_SHARED_LIBRARIES += libcutils
 LOCAL_STATIC_LIBRARIES += \
     libext4_utils_host \
@@ -48,10 +54,11 @@
 LOCAL_CFLAGS_linux := -DHOST
 include $(BUILD_HOST_EXECUTABLE)
 
+
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES := blk_alloc_to_base_fs.c
 LOCAL_MODULE := blk_alloc_to_base_fs
-LOCAL_SHARED_LIBRARIES += libcutils
+LOCAL_SHARED_LIBRARIES := libcutils
 LOCAL_CFLAGS_darwin := -DHOST
 LOCAL_CFLAGS_linux := -DHOST
 include $(BUILD_HOST_EXECUTABLE)
@@ -69,9 +76,14 @@
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES := $(libext4_utils_src_files)
 LOCAL_MODULE := libext4_utils
-LOCAL_C_INCLUDES += system/core/logwrapper/include
+LOCAL_C_INCLUDES := \
+    $(LOCAL_PATH)/include \
+    system/core/logwrapper/include
 # Various instances of dereferencing a type-punned pointer in extent.c
 LOCAL_CFLAGS += -fno-strict-aliasing
+LOCAL_CFLAGS += -DREAL_UUID
+LOCAL_EXPORT_C_INCLUDE_DIRS := \
+    $(LOCAL_PATH)/include
 LOCAL_SHARED_LIBRARIES := \
     libbase \
     libcutils \
@@ -79,18 +91,21 @@
     libselinux \
     libsparse \
     libz
-LOCAL_CFLAGS := -DREAL_UUID
 include $(BUILD_SHARED_LIBRARY)
 
 
 include $(CLEAR_VARS)
-LOCAL_SRC_FILES := $(libext4_utils_src_files) \
+LOCAL_SRC_FILES := \
+    $(libext4_utils_src_files) \
     ext4_crypt_init_extensions.cpp
 LOCAL_MODULE := libext4_utils_static
+LOCAL_C_INCLUDES := \
+    $(LOCAL_PATH)/include
 # Various instances of dereferencing a type-punned pointer in extent.c
 LOCAL_CFLAGS += -fno-strict-aliasing
+LOCAL_EXPORT_C_INCLUDE_DIRS := \
+    $(LOCAL_PATH)/include
 LOCAL_STATIC_LIBRARIES := \
-    libbase \
     liblogwrap \
     libsparse_static \
     libselinux \
@@ -101,6 +116,8 @@
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES := make_ext4fs_main.c
 LOCAL_MODULE := make_ext4fs
+LOCAL_C_INCLUDES := \
+    $(LOCAL_PATH)/include
 LOCAL_SHARED_LIBRARIES := \
     libcutils \
     libext2_uuid \
@@ -114,6 +131,8 @@
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES := ext2simg.c
 LOCAL_MODULE := ext2simg
+LOCAL_C_INCLUDES := \
+    $(LOCAL_PATH)/include
 LOCAL_SHARED_LIBRARIES += \
     libext4_utils \
     libselinux \
@@ -125,6 +144,8 @@
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES := ext2simg.c
 LOCAL_MODULE := ext2simg
+LOCAL_C_INCLUDES := \
+    $(LOCAL_PATH)/include
 LOCAL_SHARED_LIBRARIES += \
     libselinux
 LOCAL_STATIC_LIBRARIES += \
diff --git a/ext4_utils/allocate.c b/ext4_utils/allocate.c
index 497f580..6f5e4d3 100644
--- a/ext4_utils/allocate.c
+++ b/ext4_utils/allocate.c
@@ -14,14 +14,15 @@
  * limitations under the License.
  */
 
-#include "ext4_utils.h"
 #include "allocate.h"
 
-#include <sparse/sparse.h>
-
 #include <stdio.h>
 #include <stdlib.h>
 
+#include <sparse/sparse.h>
+
+#include "ext4_utils/ext4_utils.h"
+
 struct xattr_list_element {
 	struct ext4_inode *inode;
 	struct ext4_xattr_header *header;
diff --git a/ext4_utils/allocate.h b/ext4_utils/allocate.h
index 4a733d0..67af7c1 100644
--- a/ext4_utils/allocate.h
+++ b/ext4_utils/allocate.h
@@ -19,7 +19,7 @@
 
 #define EXT4_ALLOCATE_FAILED (u32)(~0)
 
-#include "ext4_utils.h"
+#include "ext4_utils/ext4_utils.h"
 
 struct region {
 	u32 block;
diff --git a/ext4_utils/contents.c b/ext4_utils/contents.c
index e66573e..a2cd3b8 100644
--- a/ext4_utils/contents.c
+++ b/ext4_utils/contents.c
@@ -14,10 +14,18 @@
  * limitations under the License.
  */
 
+#include "contents.h"
+
 #include <sys/stat.h>
 #include <string.h>
 #include <stdio.h>
 
+#include "allocate.h"
+#include "ext4_utils/ext4_utils.h"
+#include "ext4_utils/make_ext4fs.h"
+#include "extent.h"
+#include "indirect.h"
+
 #ifdef __ANDROID__
 #include <linux/capability.h>
 #else
@@ -27,13 +35,6 @@
 #define XATTR_SELINUX_SUFFIX "selinux"
 #define XATTR_CAPS_SUFFIX "capability"
 
-#include "ext4_utils.h"
-#include "make_ext4fs.h"
-#include "allocate.h"
-#include "contents.h"
-#include "extent.h"
-#include "indirect.h"
-
 #ifdef _WIN32
 #define S_IFLNK 0  /* used by make_link, not needed under mingw */
 #endif
diff --git a/ext4_utils/contents.h b/ext4_utils/contents.h
index e57687e..d4c87d8 100644
--- a/ext4_utils/contents.h
+++ b/ext4_utils/contents.h
@@ -17,6 +17,8 @@
 #ifndef _DIRECTORY_H_
 #define _DIRECTORY_H_
 
+#include "ext4_utils/ext4_utils.h"
+
 struct dentry {
 	char *path;
 	char *full_path;
diff --git a/ext4_utils/crc16.c b/ext4_utils/crc16.c
index 2575812..d86dcb8 100644
--- a/ext4_utils/crc16.c
+++ b/ext4_utils/crc16.c
@@ -9,7 +9,7 @@
 
 /* Converted to crc16 */
 
-#include "ext4_utils.h"
+#include "ext4_utils/ext4_utils.h"
 
 static u16 crc16_tab[] = {
 		0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
diff --git a/ext4_utils/ext2simg.c b/ext4_utils/ext2simg.c
index f467266..b1d0611 100644
--- a/ext4_utils/ext2simg.c
+++ b/ext4_utils/ext2simg.c
@@ -14,22 +14,26 @@
  * limitations under the License.
  */
 
+#ifndef _FILE_OFFSET_BITS
 #define _FILE_OFFSET_BITS 64
-#define _LARGEFILE64_SOURCE 1
+#endif
 
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/mman.h>
+#ifndef _LARGEFILE64_SOURCE
+#define _LARGEFILE64_SOURCE 1
+#endif
+
 #include <fcntl.h>
 #include <libgen.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 #include <unistd.h>
 
 #include <sparse/sparse.h>
 
-#include "ext4_utils.h"
-#include "make_ext4fs.h"
 #include "allocate.h"
+#include "ext4_utils/ext4_utils.h"
+#include "ext4_utils/make_ext4fs.h"
 
 #if defined(__APPLE__) && defined(__MACH__)
 #define off64_t off_t
diff --git a/ext4_utils/ext4_crypt.cpp b/ext4_utils/ext4_crypt.cpp
index be77b79..4478904 100644
--- a/ext4_utils/ext4_crypt.cpp
+++ b/ext4_utils/ext4_crypt.cpp
@@ -14,18 +14,17 @@
  * limitations under the License.
  */
 
-#include "ext4_crypt.h"
+#include "ext4_utils/ext4_crypt.h"
 
+#include <asm/ioctl.h>
 #include <dirent.h>
 #include <errno.h>
-#include <string.h>
-#include <unistd.h>
-
 #include <fcntl.h>
-#include <asm/ioctl.h>
+#include <string.h>
 #include <sys/syscall.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <unistd.h>
 
 #include <android-base/logging.h>
 #include <cutils/properties.h>
diff --git a/ext4_utils/ext4_crypt_init_extensions.cpp b/ext4_utils/ext4_crypt_init_extensions.cpp
index 14e3d44..3c2bc8e 100644
--- a/ext4_utils/ext4_crypt_init_extensions.cpp
+++ b/ext4_utils/ext4_crypt_init_extensions.cpp
@@ -14,15 +14,7 @@
  * limitations under the License.
  */
 
-#define TAG "ext4_utils"
-
-#include "ext4_crypt_init_extensions.h"
-#include "ext4_crypt.h"
-
-#include <android-base/logging.h>
-
-#include <string>
-#include <vector>
+#include "ext4_utils/ext4_crypt_init_extensions.h"
 
 #include <dirent.h>
 #include <errno.h>
@@ -30,15 +22,21 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
-#include <android-base/file.h>
-#include <android-base/stringprintf.h>
+#include <string>
+#include <vector>
 
+#include <android-base/file.h>
+#include <android-base/logging.h>
+#include <android-base/stringprintf.h>
 #include <cutils/klog.h>
 #include <cutils/properties.h>
 #include <cutils/sockets.h>
 #include <logwrap/logwrap.h>
 
-#include "key_control.h"
+#include "ext4_utils/ext4_crypt.h"
+#include "ext4_utils/key_control.h"
+
+#define TAG "ext4_utils"
 
 static const std::string arbitrary_sequence_number = "42";
 static const int vold_command_timeout_ms = 60 * 1000;
diff --git a/ext4_utils/ext4_sb.c b/ext4_utils/ext4_sb.c
index 7bbbcfe..5c3e4f3 100644
--- a/ext4_utils/ext4_sb.c
+++ b/ext4_utils/ext4_sb.c
@@ -16,7 +16,7 @@
 
 #include <errno.h>
 
-#include "ext4_sb.h"
+#include "ext4_utils/ext4_sb.h"
 
 int ext4_parse_sb(struct ext4_super_block *sb, struct fs_info *info)
 {
diff --git a/ext4_utils/ext4_utils.c b/ext4_utils/ext4_utils.c
index f358960..bfa57bc 100644
--- a/ext4_utils/ext4_utils.c
+++ b/ext4_utils/ext4_utils.c
@@ -14,23 +14,25 @@
  * limitations under the License.
  */
 
-#include "ext4_utils.h"
-#include "allocate.h"
-#include "indirect.h"
-#include "extent.h"
-#include "sha1.h"
-
-#include <sparse/sparse.h>
-#ifdef REAL_UUID
-#include <uuid.h>
-#endif
+#include "ext4_utils/ext4_utils.h"
 
 #include <fcntl.h>
 #include <inttypes.h>
-#include <sys/stat.h>
-#include <sys/types.h>
 #include <stddef.h>
 #include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <sparse/sparse.h>
+
+#include "allocate.h"
+#include "extent.h"
+#include "indirect.h"
+#include "sha1.h"
+
+#ifdef REAL_UUID
+#include <uuid.h>
+#endif
 
 #ifdef _WIN32
 #include <winsock2.h>
diff --git a/ext4_utils/ext4fixup.c b/ext4_utils/ext4fixup.c
index 09602b6..f9285d0 100644
--- a/ext4_utils/ext4fixup.c
+++ b/ext4_utils/ext4fixup.c
@@ -13,19 +13,22 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include "ext4_utils.h"
-#include "make_ext4fs.h"
-#include "ext4_extents.h"
-#include "allocate.h"
+
 #include "ext4fixup.h"
 
+#define _LARGEFILE64_SOURCE
+
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
 #include <sparse/sparse.h>
 
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
+#include "allocate.h"
+#include "ext4_utils/ext4_extents.h"
+#include "ext4_utils/ext4_utils.h"
+#include "ext4_utils/make_ext4fs.h"
 
 #ifndef _WIN32
 #include <sys/mman.h>
diff --git a/ext4_utils/ext4fixup_main.c b/ext4_utils/ext4fixup_main.c
index 47c7e65..f4428cb 100644
--- a/ext4_utils/ext4fixup_main.c
+++ b/ext4_utils/ext4fixup_main.c
@@ -14,10 +14,11 @@
  * limitations under the License.
  */
 
-#include <unistd.h>
 #include <libgen.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
+
 #include "ext4fixup.h"
 
 static void usage(char *me)
diff --git a/ext4_utils/extent.c b/ext4_utils/extent.c
index 7887488..ff56a14 100644
--- a/ext4_utils/extent.c
+++ b/ext4_utils/extent.c
@@ -14,15 +14,16 @@
  * limitations under the License.
  */
 
-#include "ext4_utils.h"
 #include "extent.h"
 
-#include <sparse/sparse.h>
-
 #include <inttypes.h>
 #include <stdlib.h>
 #include <stdio.h>
 
+#include <sparse/sparse.h>
+
+#include "allocate.h"
+#include "ext4_utils/ext4_utils.h"
 
 /* Creates data buffers for the first backing_len bytes of a block allocation
    and queues them to be written */
diff --git a/ext4_utils/extent.h b/ext4_utils/extent.h
index a78a7b0..44cee10 100644
--- a/ext4_utils/extent.h
+++ b/ext4_utils/extent.h
@@ -17,8 +17,10 @@
 #ifndef _EXTENT_H_
 #define _EXTENT_H_
 
-#include "allocate.h"
-#include "ext4_utils.h"
+#include "ext4_utils/ext4_utils.h"
+
+struct ext4_inode;
+struct block_allocation;
 
 void inode_allocate_extents(struct ext4_inode *inode, u64 len);
 struct block_allocation* inode_allocate_file_extents(
diff --git a/ext4_utils/ext4.h b/ext4_utils/include/ext4_utils/ext4.h
similarity index 100%
rename from ext4_utils/ext4.h
rename to ext4_utils/include/ext4_utils/ext4.h
diff --git a/ext4_utils/ext4_crypt.h b/ext4_utils/include/ext4_utils/ext4_crypt.h
similarity index 92%
rename from ext4_utils/ext4_crypt.h
rename to ext4_utils/include/ext4_utils/ext4_crypt.h
index ddc09a7..d02ff81 100644
--- a/ext4_utils/ext4_crypt.h
+++ b/ext4_utils/include/ext4_utils/ext4_crypt.h
@@ -14,6 +14,9 @@
  * limitations under the License.
  */
 
+#ifndef _EXT4_CRYPT_H_
+#define _EXT4_CRYPT_H_
+
 #include <sys/cdefs.h>
 #include <stdbool.h>
 #include <cutils/multiuser.h>
@@ -28,3 +31,5 @@
 static const char* e4crypt_key_ref = "/unencrypted/ref";
 
 __END_DECLS
+
+#endif // _EXT4_CRYPT_H_
diff --git a/ext4_utils/ext4_crypt_init_extensions.h b/ext4_utils/include/ext4_utils/ext4_crypt_init_extensions.h
similarity index 89%
rename from ext4_utils/ext4_crypt_init_extensions.h
rename to ext4_utils/include/ext4_utils/ext4_crypt_init_extensions.h
index 63f6d88..2cf98de 100644
--- a/ext4_utils/ext4_crypt_init_extensions.h
+++ b/ext4_utils/include/ext4_utils/ext4_crypt_init_extensions.h
@@ -14,6 +14,9 @@
  * limitations under the License.
  */
 
+#ifndef _EXT4_CRYPT_INIT_EXTENSIONS_H_
+#define _EXT4_CRYPT_INIT_EXTENSIONS_H_
+
 #include <sys/cdefs.h>
 #include <stdbool.h>
 #include <cutils/multiuser.h>
@@ -29,3 +32,5 @@
 int e4crypt_do_init_user0();
 
 __END_DECLS
+
+#endif // _EXT4_CRYPT_INIT_EXTENSIONS_H_
diff --git a/ext4_utils/ext4_extents.h b/ext4_utils/include/ext4_utils/ext4_extents.h
similarity index 98%
rename from ext4_utils/ext4_extents.h
rename to ext4_utils/include/ext4_utils/ext4_extents.h
index b1290f4..68fc4a4 100644
--- a/ext4_utils/ext4_extents.h
+++ b/ext4_utils/include/ext4_utils/ext4_extents.h
@@ -12,7 +12,7 @@
 #ifndef _EXT4_EXTENTS
 #define _EXT4_EXTENTS
 
-#include "ext4.h"
+#include "ext4_utils/ext4.h"
 
 #define AGGRESSIVE_TEST_
 
diff --git a/ext4_utils/ext4_kernel_headers.h b/ext4_utils/include/ext4_utils/ext4_kernel_headers.h
similarity index 90%
rename from ext4_utils/ext4_kernel_headers.h
rename to ext4_utils/include/ext4_utils/ext4_kernel_headers.h
index 4b24dce..ebdf202 100644
--- a/ext4_utils/ext4_kernel_headers.h
+++ b/ext4_utils/include/ext4_utils/ext4_kernel_headers.h
@@ -36,10 +36,10 @@
 #define __u8 uint8_t
 #endif
 
-#include "ext4.h"
-#include "xattr.h"
-#include "ext4_extents.h"
-#include "jbd2.h"
+#include "ext4_utils/ext4.h"
+#include "ext4_utils/ext4_extents.h"
+#include "ext4_utils/jbd2.h"
+#include "ext4_utils/xattr.h"
 
 #ifndef __BIONIC__
 #undef __le64
diff --git a/ext4_utils/ext4_sb.h b/ext4_utils/include/ext4_utils/ext4_sb.h
similarity index 96%
rename from ext4_utils/ext4_sb.h
rename to ext4_utils/include/ext4_utils/ext4_sb.h
index 159580d..11b8971 100644
--- a/ext4_utils/ext4_sb.h
+++ b/ext4_utils/include/ext4_utils/ext4_sb.h
@@ -17,7 +17,7 @@
 #ifndef _EXT4_UTILS_EXT4_SB_H_
 #define _EXT4_UTILS_EXT4_SB_H_
 
-#include "ext4_kernel_headers.h"
+#include "ext4_utils/ext4_kernel_headers.h"
 
 #define EXT4_SUPER_MAGIC 0xEF53
 
diff --git a/ext4_utils/ext4_utils.h b/ext4_utils/include/ext4_utils/ext4_utils.h
similarity index 100%
rename from ext4_utils/ext4_utils.h
rename to ext4_utils/include/ext4_utils/ext4_utils.h
diff --git a/ext4_utils/jbd2.h b/ext4_utils/include/ext4_utils/jbd2.h
similarity index 100%
rename from ext4_utils/jbd2.h
rename to ext4_utils/include/ext4_utils/jbd2.h
diff --git a/ext4_utils/key_control.h b/ext4_utils/include/ext4_utils/key_control.h
similarity index 93%
rename from ext4_utils/key_control.h
rename to ext4_utils/include/ext4_utils/key_control.h
index 748c32d..fe6a6b5 100644
--- a/ext4_utils/key_control.h
+++ b/ext4_utils/include/ext4_utils/key_control.h
@@ -1,3 +1,6 @@
+#ifndef _KEY_CONTROL_H_
+#define _KEY_CONTROL_H_
+
 #include <sys/cdefs.h>
 #include <sys/types.h>
 
@@ -29,3 +32,5 @@
                    const char *description, key_serial_t destringid);
 
 __END_DECLS
+
+#endif // _KEY_CONTROL_H_
diff --git a/ext4_utils/make_ext4fs.h b/ext4_utils/include/ext4_utils/make_ext4fs.h
similarity index 100%
rename from ext4_utils/make_ext4fs.h
rename to ext4_utils/include/ext4_utils/make_ext4fs.h
diff --git a/ext4_utils/wipe.h b/ext4_utils/include/ext4_utils/wipe.h
similarity index 96%
rename from ext4_utils/wipe.h
rename to ext4_utils/include/ext4_utils/wipe.h
index c7a86fa..d7d089e 100644
--- a/ext4_utils/wipe.h
+++ b/ext4_utils/include/ext4_utils/wipe.h
@@ -21,7 +21,7 @@
 extern "C" {
 #endif
 
-#include "ext4_utils.h"
+#include "ext4_utils/ext4_utils.h"
 
 /* Set WIPE_IS_SUPPORTED to 1 if the current platform supports
  * wiping of block devices. 0 otherwise. For now, only Linux does.
diff --git a/ext4_utils/xattr.h b/ext4_utils/include/ext4_utils/xattr.h
similarity index 100%
rename from ext4_utils/xattr.h
rename to ext4_utils/include/ext4_utils/xattr.h
diff --git a/ext4_utils/indirect.c b/ext4_utils/indirect.c
index cd85a43..992cc32 100644
--- a/ext4_utils/indirect.c
+++ b/ext4_utils/indirect.c
@@ -14,14 +14,16 @@
  * limitations under the License.
  */
 
-#include "ext4_utils.h"
 #include "indirect.h"
-#include "allocate.h"
+
+#include <stdio.h>
+#include <stdlib.h>
 
 #include <sparse/sparse.h>
 
-#include <stdlib.h>
-#include <stdio.h>
+#include "allocate.h"
+#include "ext4_utils/ext4_utils.h"
+
 
 /* Creates data buffers for the first backing_len bytes of a block allocation
    and queues them to be written */
diff --git a/ext4_utils/indirect.h b/ext4_utils/indirect.h
index cee8979..93741c0 100644
--- a/ext4_utils/indirect.h
+++ b/ext4_utils/indirect.h
@@ -17,7 +17,10 @@
 #ifndef _INDIRECT_H_
 #define _INDIRECT_H_
 
-#include "allocate.h"
+#include "ext4_utils/ext4_utils.h"
+
+struct ext4_inode;
+struct block_allocation;
 
 void inode_allocate_indirect(struct ext4_inode *inode, unsigned long len);
 u8 *inode_allocate_data_indirect(struct ext4_inode *inode, unsigned long len,
diff --git a/ext4_utils/key_control.cpp b/ext4_utils/key_control.cpp
index 64f230a..de6bde2 100644
--- a/ext4_utils/key_control.cpp
+++ b/ext4_utils/key_control.cpp
@@ -1,4 +1,4 @@
-#include "key_control.h"
+#include "ext4_utils/key_control.h"
 
 #include <stdarg.h>
 #include <unistd.h>
diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c
index 744cf0a..a1cfe06 100644
--- a/ext4_utils/make_ext4fs.c
+++ b/ext4_utils/make_ext4fs.c
@@ -14,13 +14,11 @@
  * limitations under the License.
  */
 
-#include "make_ext4fs.h"
-#include "ext4_utils.h"
-#include "allocate.h"
-#include "contents.h"
-#include "wipe.h"
+#include "ext4_utils/make_ext4fs.h"
 
-#include <sparse/sparse.h>
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
 
 #include <assert.h>
 #include <dirent.h>
@@ -30,9 +28,16 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <unistd.h>
+
+#include <sparse/sparse.h>
+
+#include "allocate.h"
+#include "contents.h"
+#include "ext4_utils/ext4_utils.h"
+#include "ext4_utils/wipe.h"
 
 #ifdef _WIN32
 
diff --git a/ext4_utils/make_ext4fs_main.c b/ext4_utils/make_ext4fs_main.c
index 1343cc6..87cb53e 100644
--- a/ext4_utils/make_ext4fs_main.c
+++ b/ext4_utils/make_ext4fs_main.c
@@ -40,8 +40,8 @@
 struct selabel_handle;
 #endif
 
-#include "make_ext4fs.h"
-#include "ext4_utils.h"
+#include "ext4_utils/ext4_utils.h"
+#include "ext4_utils/make_ext4fs.h"
 
 #ifndef _WIN32 /* O_BINARY is windows-specific flag */
 #define O_BINARY 0
diff --git a/ext4_utils/setup_fs.c b/ext4_utils/setup_fs.c
index 56c563f..802412d 100644
--- a/ext4_utils/setup_fs.c
+++ b/ext4_utils/setup_fs.c
@@ -1,9 +1,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <sys/reboot.h>
 #include <sys/wait.h>
+#include <unistd.h>
+
 #include <cutils/android_reboot.h>
 #include <cutils/partition_utils.h>
 
diff --git a/ext4_utils/wipe.c b/ext4_utils/wipe.c
index 5766632..a519d74 100644
--- a/ext4_utils/wipe.c
+++ b/ext4_utils/wipe.c
@@ -14,8 +14,9 @@
  * limitations under the License.
  */
 
-#include "ext4_utils.h"
-#include "wipe.h"
+#include "ext4_utils/wipe.h"
+
+#include "ext4_utils/ext4_utils.h"
 
 #if WIPE_IS_SUPPORTED
 
diff --git a/libfec/Android.mk b/libfec/Android.mk
index b92dd4e..283019c 100644
--- a/libfec/Android.mk
+++ b/libfec/Android.mk
@@ -7,7 +7,6 @@
 common_c_includes := \
     $(LOCAL_PATH)/include \
     external/fec \
-    system/extras/ext4_utils \
     system/extras/squashfs_utils
 
 common_src_files := \
diff --git a/libfec/fec_open.cpp b/libfec/fec_open.cpp
index caec370..45e0c26 100644
--- a/libfec/fec_open.cpp
+++ b/libfec/fec_open.cpp
@@ -18,9 +18,10 @@
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 
+#include <ext4_utils/ext4_sb.h>
+
 extern "C" {
     #include <squashfs_utils.h>
-    #include <ext4_sb.h>
 }
 
 #if defined(__linux__)
diff --git a/tests/fstest/Android.mk b/tests/fstest/Android.mk
index 9be7ae4..7b769b0 100644
--- a/tests/fstest/Android.mk
+++ b/tests/fstest/Android.mk
@@ -18,9 +18,8 @@
 LOCAL_MODULE_TAGS := tests
 LOCAL_MODULE := recovery_test
 LOCAL_SRC_FILES := recovery_test.cpp
-LOCAL_SHARED_LIBRARIES += libcutils libutils liblog liblogwrap
+LOCAL_SHARED_LIBRARIES += libcutils libutils liblog liblogwrap libext4_utils
 LOCAL_STATIC_LIBRARIES += libtestUtil libfs_mgr
 LOCAL_C_INCLUDES += system/extras/tests/include \
-                    system/extras/ext4_utils \
                     system/core/logwrapper/include
 include $(BUILD_NATIVE_TEST)
diff --git a/tests/fstest/recovery_test.cpp b/tests/fstest/recovery_test.cpp
index 02c7e8f..fab9a0f 100644
--- a/tests/fstest/recovery_test.cpp
+++ b/tests/fstest/recovery_test.cpp
@@ -29,8 +29,8 @@
 #include <unistd.h>
 
 #include "cutils/properties.h"
-#include "ext4.h"
-#include "ext4_utils.h"
+#include <ext4_utils/ext4.h>
+#include <ext4_utils/ext4_utils.h>
 
 #define LOG_TAG "fsRecoveryTest"
 #include <utils/Log.h>
diff --git a/verity/Android.mk b/verity/Android.mk
index 1a7351f..ef5f08e 100644
--- a/verity/Android.mk
+++ b/verity/Android.mk
@@ -8,7 +8,7 @@
 LOCAL_MODULE_CLASS := EXECUTABLES
 LOCAL_MODULE_TAGS := optional
 LOCAL_SHARED_LIBRARIES := libcrypto
-LOCAL_C_INCLUDES += external/openssl/include system/extras/ext4_utils system/core/mkbootimg
+LOCAL_C_INCLUDES += external/openssl/include system/core/mkbootimg
 include $(BUILD_HOST_EXECUTABLE)
 
 endif # HOST_OS == linux