From 9416f4f9d6542b616640c0fbb53899bbfc1859a2 Mon Sep 17 00:00:00 2001 From: xiaolu Date: Thu, 4 Jun 2015 08:22:23 +0800 Subject: partition: recreate tw_internal_path(/data/media/0), after wipe media from data or format /data. Change-Id: I3671d7a5759260a4e74952168483a6816eb28f5d --- partition.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'partition.cpp') diff --git a/partition.cpp b/partition.cpp index 9c5462d3e..e154564be 100644 --- a/partition.cpp +++ b/partition.cpp @@ -1051,7 +1051,7 @@ bool TWPartition::Mount(bool Display_Error) { if (Removable) Update_Size(Display_Error); - if (!Symlink_Mount_Point.empty()) { + if (!Symlink_Mount_Point.empty() && TWFunc::Path_Exists(Symlink_Path)) { string Command = "mount -o bind '" + Symlink_Path + "' '" + Symlink_Mount_Point + "'"; TWFunc::Exec_Cmd(Command); } @@ -2116,15 +2116,22 @@ void TWPartition::Recreate_Media_Folder(void) { } else if (!TWFunc::Path_Exists("/data/media")) { PartitionManager.Mount_By_Path(Symlink_Mount_Point, true); LOGINFO("Recreating /data/media folder.\n"); - mkdir("/data/media", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); + mkdir("/data/media", 0770); + string Internal_path = DataManager::GetStrValue("tw_internal_path"); + if (!Internal_path.empty()) { + LOGINFO("Recreating %s folder.\n", Internal_path.c_str()); + mkdir(Internal_path.c_str(), 0770); + } +#ifdef TW_INTERNAL_STORAGE_PATH + mkdir(EXPAND(TW_INTERNAL_STORAGE_PATH), 0770); +#endif #ifdef HAVE_SELINUX - // Attempt to set the correct SELinux contexts on the folder - fixPermissions perms; - perms.fixDataInternalContexts(); // Afterwards, we will try to set the // default metadata that we were hopefully able to get during // early boot. tw_set_default_metadata("/data/media"); + if (!Internal_path.empty()) + tw_set_default_metadata(Internal_path.c_str()); #endif // Toggle mount to ensure that "internal sdcard" gets mounted PartitionManager.UnMount_By_Path(Symlink_Mount_Point, true); -- cgit v1.2.3