From 808344f4eda06095d77ceca02315efc593c51f5f Mon Sep 17 00:00:00 2001 From: me-cafebabe Date: Thu, 28 Jul 2022 04:07:04 +0800 Subject: [PATCH] partitionmanager: Only create logical partition symlink when it doesn't exist Legacy devices might have symlinks to real partitions in this folder. Change-Id: I4d3360ff1022eabbd4f6ae7688d8bb7306ae9777 (cherry picked from commit 928234b2b704555073ab03eb6a051fa9c9fd2a86) --- partitionmanager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/partitionmanager.cpp b/partitionmanager.cpp index eb7b6043..743e9285 100755 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -3418,8 +3418,10 @@ bool TWPartitionManager::Prepare_Super_Volume(TWPartition* twrpPart) { twrpPart->Update_Size(true); twrpPart->Set_Can_Be_Backed_Up(false); twrpPart->Set_Can_Be_Wiped(false); - LOGINFO("Symlinking %s => /dev/block/bootdevice/by-name/%s \n", fstabEntry.blk_device.c_str(), bare_partition_name.c_str()); - symlink(fstabEntry.blk_device.c_str(), ("/dev/block/bootdevice/by-name/" + bare_partition_name).c_str()); + if (access(("/dev/block/bootdevice/by-name/" + bare_partition_name).c_str(), F_OK) == -1) { + LOGINFO("Symlinking %s => /dev/block/bootdevice/by-name/%s \n", fstabEntry.blk_device.c_str(), bare_partition_name.c_str()); + symlink(fstabEntry.blk_device.c_str(), ("/dev/block/bootdevice/by-name/" + bare_partition_name).c_str()); + } return true; }