am af41b37f: am 7176b213: Merge "Add automatic file_contexts handle to make_ext4fs."
* commit 'af41b37f0088417f98261c24647f195ecd4999fc':
Add automatic file_contexts handle to make_ext4fs.
diff --git a/ext4_utils/Android.mk b/ext4_utils/Android.mk
index f9b571e..1fef735 100644
--- a/ext4_utils/Android.mk
+++ b/ext4_utils/Android.mk
@@ -41,6 +41,7 @@
LOCAL_LDLIBS += -lws2_32
else
LOCAL_STATIC_LIBRARIES += libselinux
+ LOCAL_CFLAGS := -DHOST
endif
include $(BUILD_HOST_EXECUTABLE)
diff --git a/ext4_utils/make_ext4fs.h b/ext4_utils/make_ext4fs.h
index 577157a..e80e636 100644
--- a/ext4_utils/make_ext4fs.h
+++ b/ext4_utils/make_ext4fs.h
@@ -27,6 +27,7 @@
#ifndef USE_MINGW
#include <selinux/selinux.h>
#include <selinux/label.h>
+#include <selinux/android.h>
#else
struct selabel_handle;
#endif
diff --git a/ext4_utils/make_ext4fs_main.c b/ext4_utils/make_ext4fs_main.c
index c54618d..000b857 100644
--- a/ext4_utils/make_ext4fs_main.c
+++ b/ext4_utils/make_ext4fs_main.c
@@ -136,6 +136,18 @@
}
}
+#if !defined(HOST)
+ // Use only if -S option not requested
+ if (!sehnd && mountpoint[0] != '\0') {
+ sehnd = selinux_android_file_context_handle();
+
+ if (!sehnd) {
+ perror(optarg);
+ exit(EXIT_FAILURE);
+ }
+ }
+#endif
+
if (wipe && sparse) {
fprintf(stderr, "Cannot specifiy both wipe and sparse\n");
usage(argv[0]);