Removing block device by-num symlinks

The uevent.partition_num easily collides between partitions, for
example:

  Both /dev/block/sda3 and /dev/block/sdd3 will generate the same symlink:
    /dev/block/platform/soc/1da4000.ufshc/by-num/p3

This change remove those by-num symlinks as there seems no effective
user of it.

Bug: 78613232
Test: m init_tests && \
      adb push $OUT/data/nativetest64/init_tests/init_tests /data/. && \
      adb shell /data/init_tests

Change-Id: I8dfa8dc1a2f9fc9296aa30f33e905bf158b501de
Merged-In: I8dfa8dc1a2f9fc9296aa30f33e905bf158b501de
(cherry picked from commit 95591bd00e)
This commit is contained in:
Bowgo Tsai 2018-05-17 16:19:52 +08:00
parent 7905b1e162
commit ff17cc31e5
3 changed files with 0 additions and 7 deletions

View File

@ -331,10 +331,6 @@ std::vector<std::string> DeviceHandler::GetBlockDeviceSymlinks(const Uevent& uev
links.emplace_back(link_path + "/by-name/" + partition_name_sanitized);
}
if (uevent.partition_num >= 0) {
links.emplace_back(link_path + "/by-num/p" + std::to_string(uevent.partition_num));
}
auto last_slash = uevent.path.rfind('/');
links.emplace_back(link_path + "/" + uevent.path.substr(last_slash + 1));

View File

@ -84,7 +84,6 @@ TEST(device_handler, get_block_device_symlinks_success_platform_with_partition)
};
std::vector<std::string> expected_result{
"/dev/block/platform/soc.0/f9824900.sdhci/by-name/modem",
"/dev/block/platform/soc.0/f9824900.sdhci/by-num/p1",
"/dev/block/platform/soc.0/f9824900.sdhci/mmcblk0p1",
};
@ -100,7 +99,6 @@ TEST(device_handler, get_block_device_symlinks_success_platform_with_partition_o
.partition_num = 1,
};
std::vector<std::string> expected_result{
"/dev/block/platform/soc.0/f9824900.sdhci/by-num/p1",
"/dev/block/platform/soc.0/f9824900.sdhci/mmcblk0p1",
};

View File

@ -413,7 +413,6 @@ ListenerAction FirstStageMountVBootV2::UeventCallback(const Uevent& uevent) {
// the content of uevent. by-name symlink will be at [0] if uevent->partition_name
// is not empty. e.g.,
// - /dev/block/platform/soc.0/f9824900.sdhci/by-name/modem
// - /dev/block/platform/soc.0/f9824900.sdhci/by-num/p1
// - /dev/block/platform/soc.0/f9824900.sdhci/mmcblk0p1
std::vector<std::string> links = device_handler_.GetBlockDeviceSymlinks(uevent);
if (!links.empty()) {