am d66b3e88: Merge "Modiy mkyaffsimage for SELinux."
* commit 'd66b3e8898579431a5eb66e4470989e534ef3e73':
Modiy mkyaffsimage for SELinux.
diff --git a/yaffs2/utils/mkyaffs2image.c b/yaffs2/utils/mkyaffs2image.c
index 2b152e6..f4e5745 100644
--- a/yaffs2/utils/mkyaffs2image.c
+++ b/yaffs2/utils/mkyaffs2image.c
@@ -382,12 +382,26 @@
mntpoint, suffix);
exit(1);
}
- if (selabel_lookup(sehnd, &secontext,
- dest_name,
- stats.st_mode) < 0) {
- perror("selabel_lookup");
- exit(1);
+
+ char *sepath = NULL;
+ if (dest_name[0] == '/')
+ sepath = strdup(dest_name);
+ else if (asprintf(&sepath, "/%s", dest_name) < 0)
+ sepath = NULL;
+
+ if (!sepath) {
+ perror("malloc");
+ exit(1);
}
+
+ if (selabel_lookup(sehnd, &secontext,
+ sepath,
+ stats.st_mode) < 0) {
+ perror("selabel_lookup");
+ free(sepath);
+ exit(1);
+ }
+ free(sepath);
}
#endif
@@ -636,10 +650,25 @@
//printf("Processing directory %s into image file %s\n",dir,image);
#ifdef HAVE_SELINUX
if (sehnd) {
- if (selabel_lookup(sehnd, &secontext, mntpoint, stats.st_mode) < 0) {
- perror("selabel_lookup");
- exit(1);
- }
+
+ char *sepath = NULL;
+ if (mntpoint[0] == '/')
+ sepath = strdup(mntpoint);
+ else if (asprintf(&sepath, "/%s", mntpoint) < 0)
+ sepath = NULL;
+
+ if (!sepath) {
+ perror("malloc");
+ exit(1);
+ }
+
+ if (selabel_lookup(sehnd, &secontext, sepath, stats.st_mode) < 0) {
+ perror("selabel_lookup");
+ free(sepath);
+ exit(1);
+ }
+
+ free(sepath);
}
#endif