Use umount2 for UnMount function
This allows specifying additional umount flags when using UnMount-based functions
Change-Id: Idb89ec59315bc11bbbe262a23b4a779e03a3f2d5
diff --git a/partition.cpp b/partition.cpp
index cd46420..3f27d12 100755
--- a/partition.cpp
+++ b/partition.cpp
@@ -1716,7 +1716,7 @@
return true;
}
-bool TWPartition::UnMount(bool Display_Error) {
+bool TWPartition::UnMount(bool Display_Error, int flags) {
if (Is_Mounted()) {
int never_unmount_system;
@@ -1728,9 +1728,9 @@
PartitionManager.Remove_MTP_Storage(MTP_Storage_ID);
if (!Symlink_Mount_Point.empty())
- umount(Symlink_Mount_Point.c_str());
+ umount2(Symlink_Mount_Point.c_str(), flags);
- umount(Mount_Point.c_str());
+ umount2(Mount_Point.c_str(), flags);
if (Is_Mounted()) {
if (Display_Error)
gui_msg(Msg(msg::kError, "fail_unmount=Failed to unmount '{1}' ({2})")(Mount_Point)(strerror(errno)));
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index c878e1b..1c3c31b 100755
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -808,7 +808,7 @@
return false;
}
-int TWPartitionManager::UnMount_By_Path(string Path, bool Display_Error) {
+int TWPartitionManager::UnMount_By_Path(string Path, bool Display_Error, int flags) {
std::vector<TWPartition*>::iterator iter;
int ret = false;
bool found = false;
@@ -817,10 +817,10 @@
// Iterate through all partitions
for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
if ((*iter)->Mount_Point == Local_Path || (!(*iter)->Symlink_Mount_Point.empty() && (*iter)->Symlink_Mount_Point == Local_Path)) {
- ret = (*iter)->UnMount(Display_Error);
+ ret = (*iter)->UnMount(Display_Error, flags);
found = true;
} else if ((*iter)->Is_SubPartition && (*iter)->SubPartition_Of == Local_Path) {
- (*iter)->UnMount(Display_Error);
+ (*iter)->UnMount(Display_Error, flags);
}
}
if (found) {
diff --git a/partitions.hpp b/partitions.hpp
index bdcea55..b0242ad 100755
--- a/partitions.hpp
+++ b/partitions.hpp
@@ -125,7 +125,7 @@
bool Is_Mounted(); // Checks mount to see if the partition is currently mounted
bool Is_File_System_Writable(); // Checks if the root directory of the file system can be written to
bool Mount(bool Display_Error); // Mounts the partition if it is not mounted
- bool UnMount(bool Display_Error); // Unmounts the partition if it is mounted
+ bool UnMount(bool Display_Error, int flags = 0); // Unmounts the partition if it is mounted
bool ReMount(bool Display_Error); // Remounts the partition
bool ReMount_RW(bool Display_Error); // Remounts the partition with read/write access
bool Bind_Mount(bool Display_Error); // Bind mount partition if symlink mountpoint is populated
@@ -327,7 +327,7 @@
void Output_Partition_Logging(); // Outputs partition information to the log
void Output_Partition(TWPartition* Part); // Outputs partition details to the log
int Mount_By_Path(string Path, bool Display_Error); // Mounts partition based on path (e.g. /system)
- int UnMount_By_Path(string Path, bool Display_Error); // Unmounts partition based on path
+ int UnMount_By_Path(string Path, bool Display_Error, int flags = 0); // Unmounts partition based on path
int Is_Mounted_By_Path(string Path); // Checks if partition is mounted based on path
int Mount_Current_Storage(bool Display_Error); // Mounts the current storage location
int Mount_Settings_Storage(bool Display_Error); // Mounts the settings file storage location (usually internal)