From 3182ea132e917b197149fee74a7eeba5b6b5125d Mon Sep 17 00:00:00 2001 From: Bowgo Tsai Date: Fri, 17 May 2019 15:40:18 +0800 Subject: [PATCH] Moving /odm/build.prop to /odm/etc/buid.prop In device root directory, we have the following symlinks: - /odm/app -> /vendor/odm/app - /odm/bin -> /vendor/odm/bin - /odm/etc -> /vendor/odm/etc ... This allows the Generic System Image (GSI) to be used on both devices: 1) Has a physical odm partition, where those symlink will be hidden when /odm is used as the mount point 2) Has no physical odm partition and fallback to /vendor/odm/. We can't just have the symlink /odm -> /vendor/odm, because the former devices won't have /vendor/odm directory, which leads to mount failure when the mount point /odm is resolved to /vendor/odm. The existing /vendor/odm/build.prop won't be loaded in the latter devices, because there is no symlink - /odm/build.prop -> /vendor/odm/build.prop. Note that init blocks reading through direct symlinks (O_NOFOLLOW) so the above symlink won't work either. This CL moves the odm build.prop to /odm/etc/build.prop for init to load it (symlinks in earlier components of the path will still be followed by O_NOFOLLOW). Bug: 132128501 Test: boot a device and checks /odm/etc/build.prop is loaded Change-Id: I0733c277baa67c549bb45599abb70aba13fbdbcf Merged-In: I0733c277baa67c549bb45599abb70aba13fbdbcf (cherry picked from commit c49655b2a48eca2ab751b853a9a4692f322cafa2) --- init/property_service.cpp | 8 ++++++-- libcutils/fs_config.cpp | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index bca73c950..fce8d578f 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -883,8 +883,12 @@ void property_load_boot_defaults(bool load_debug_prop) { load_properties_from_file("/system/build.prop", nullptr, &properties); load_properties_from_file("/vendor/default.prop", nullptr, &properties); load_properties_from_file("/vendor/build.prop", nullptr, &properties); - load_properties_from_file("/odm/default.prop", nullptr, &properties); - load_properties_from_file("/odm/build.prop", nullptr, &properties); + if (SelinuxGetVendorAndroidVersion() >= __ANDROID_API_Q__) { + load_properties_from_file("/odm/etc/build.prop", nullptr, &properties); + } else { + load_properties_from_file("/odm/default.prop", nullptr, &properties); + load_properties_from_file("/odm/build.prop", nullptr, &properties); + } load_properties_from_file("/product/build.prop", nullptr, &properties); load_properties_from_file("/product_services/build.prop", nullptr, &properties); load_properties_from_file("/factory/factory.prop", "ro.*", &properties); diff --git a/libcutils/fs_config.cpp b/libcutils/fs_config.cpp index 6217bc802..a5f4f0e55 100644 --- a/libcutils/fs_config.cpp +++ b/libcutils/fs_config.cpp @@ -159,8 +159,9 @@ static const struct fs_path_config android_files[] = { { 00750, AID_ROOT, AID_SHELL, 0, "data/nativetest64/*" }, { 00600, AID_ROOT, AID_ROOT, 0, "default.prop" }, // legacy { 00600, AID_ROOT, AID_ROOT, 0, "system/etc/prop.default" }, - { 00600, AID_ROOT, AID_ROOT, 0, "odm/build.prop" }, - { 00600, AID_ROOT, AID_ROOT, 0, "odm/default.prop" }, + { 00600, AID_ROOT, AID_ROOT, 0, "odm/build.prop" }, // legacy; only for P release + { 00600, AID_ROOT, AID_ROOT, 0, "odm/default.prop" }, // legacy; only for P release + { 00600, AID_ROOT, AID_ROOT, 0, "odm/etc/build.prop" }, { 00444, AID_ROOT, AID_ROOT, 0, odm_conf_dir + 1 }, { 00444, AID_ROOT, AID_ROOT, 0, odm_conf_file + 1 }, { 00444, AID_ROOT, AID_ROOT, 0, oem_conf_dir + 1 },