1 diff --git a/extras/ext4_utils/make_ext4fs.c b/extras/ext4_utils/make_ext4fs.c
2 index b2d1426..94e92d6 100644
3 --- a/extras/ext4_utils/make_ext4fs.c
4 +++ b/extras/ext4_utils/make_ext4fs.c
10 #include <selinux/selinux.h>
11 #include <selinux/label.h>
12 #include <selinux/android.h>
17 @@ -178,6 +180,7 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
18 error("can't set android permissions - built without android support");
24 if (selabel_lookup(sehnd, &dentries[i].secon, dentries[i].path, stat.st_mode) < 0) {
25 @@ -188,6 +191,7 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
26 printf("Labeling %s as %s\n", dentries[i].path, dentries[i].secon);
31 if (S_ISREG(stat.st_mode)) {
32 dentries[i].file_type = EXT4_FT_REG_FILE;
33 @@ -229,10 +233,12 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
34 dentries[0].file_type = EXT4_FT_DIR;
39 if (selabel_lookup(sehnd, &dentries[0].secon, dentries[0].path, dentries[0].mode) < 0)
40 error("cannot lookup security context for %s", dentries[0].path);
46 @@ -270,9 +276,11 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
49 error("failed to set permissions on %s\n", dentries[i].path);
51 ret = inode_set_selinux(entry_inode, dentries[i].secon);
53 error("failed to set SELinux context on %s\n", dentries[i].path);
56 free(dentries[i].path);
57 free(dentries[i].full_path);
58 @@ -562,6 +570,7 @@ int make_ext4fs_internal(int fd, const char *_directory,
59 root_mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
60 inode_set_permissions(root_inode_num, root_mode, 0, 0, 0);
65 char *secontext = NULL;
66 @@ -578,6 +587,7 @@ int make_ext4fs_internal(int fd, const char *_directory,
74 diff --git a/extras/ext4_utils/make_ext4fs_main.c b/extras/ext4_utils/make_ext4fs_main.c
75 index b6c740d..ce31764 100644
76 --- a/extras/ext4_utils/make_ext4fs_main.c
77 +++ b/extras/ext4_utils/make_ext4fs_main.c
79 #include <private/android_filesystem_config.h>
84 #include <selinux/selinux.h>
85 #include <selinux/label.h>
88 struct selabel_handle;
92 #include "make_ext4fs.h"
93 #include "ext4_utils.h"
94 @@ -72,9 +74,11 @@ int main(int argc, char **argv)
97 struct selabel_handle *sehnd = NULL;
100 struct selinux_opt seopts[] = { { SELABEL_OPT_PATH, "" } };
104 while ((opt = getopt(argc, argv, "l:j:b:g:i:I:L:a:S:fwzJsctv")) != -1) {
106 @@ -131,6 +135,7 @@ int main(int argc, char **argv)
107 fprintf(stderr, "Warning: -t (initialize inode tables) is deprecated\n");
112 seopts[0].value = optarg;
113 sehnd = selabel_open(SELABEL_CTX_FILE, seopts, 1);
114 @@ -139,6 +144,7 @@ int main(int argc, char **argv)
122 @@ -149,6 +155,7 @@ int main(int argc, char **argv)
128 // Use only if -S option not requested
129 if (!sehnd && mountpoint) {
130 @@ -160,6 +167,7 @@ int main(int argc, char **argv)
136 if (wipe && sparse) {
137 fprintf(stderr, "Cannot specifiy both wipe and sparse\n");