summaryrefslogtreecommitdiffstats
path: root/partition.cpp
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2014-02-09 18:48:33 +0100
committerEthan Yonker <dees_troy@teamw.in>2014-02-09 18:48:33 +0100
commitf27497f0cc8fa4bcec43e61c67ba45487f588cfc (patch)
tree8fe254bd956d3aa1b8e1188f5308010a4e94c57a /partition.cpp
parentUpdate SuperSU (diff)
downloadandroid_bootable_recovery-f27497f0cc8fa4bcec43e61c67ba45487f588cfc.tar
android_bootable_recovery-f27497f0cc8fa4bcec43e61c67ba45487f588cfc.tar.gz
android_bootable_recovery-f27497f0cc8fa4bcec43e61c67ba45487f588cfc.tar.bz2
android_bootable_recovery-f27497f0cc8fa4bcec43e61c67ba45487f588cfc.tar.lz
android_bootable_recovery-f27497f0cc8fa4bcec43e61c67ba45487f588cfc.tar.xz
android_bootable_recovery-f27497f0cc8fa4bcec43e61c67ba45487f588cfc.tar.zst
android_bootable_recovery-f27497f0cc8fa4bcec43e61c67ba45487f588cfc.zip
Diffstat (limited to 'partition.cpp')
-rw-r--r--partition.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/partition.cpp b/partition.cpp
index 3f19b7d61..b597695e2 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -53,6 +53,7 @@ extern "C" {
}
#ifdef HAVE_SELINUX
#include "selinux/selinux.h"
+#include <selinux/label.h>
#endif
using namespace std;
@@ -1344,17 +1345,25 @@ bool TWPartition::Wipe_EXT4() {
return false;
#if defined(HAVE_SELINUX) && defined(USE_EXT4)
+ int ret;
+ char *secontext = NULL;
+
gui_print("Formatting %s using make_ext4fs function.\n", Display_Name.c_str());
- if (make_ext4fs(Actual_Block_Device.c_str(), Length, Mount_Point.c_str(), selinux_handle) != 0) {
+
+ if (selabel_lookup(selinux_handle, &secontext, Mount_Point.c_str(), S_IFDIR) < 0) {
+ LOGINFO("Cannot lookup security context for '%s'\n", Mount_Point.c_str());
+ ret = make_ext4fs(Actual_Block_Device.c_str(), Length, Mount_Point.c_str(), NULL);
+ } else {
+ ret = make_ext4fs(Actual_Block_Device.c_str(), Length, Mount_Point.c_str(), selinux_handle);
+ }
+ if (ret != 0) {
LOGERR("Unable to wipe '%s' using function call.\n", Mount_Point.c_str());
return false;
} else {
- #ifdef HAVE_SELINUX
string sedir = Mount_Point + "/lost+found";
PartitionManager.Mount_By_Path(sedir.c_str(), true);
rmdir(sedir.c_str());
mkdir(sedir.c_str(), S_IRWXU | S_IRWXG | S_IWGRP | S_IXGRP);
- #endif
return true;
}
#else