init: add back TARGET_INIT_VENDOR_LIB for vendor_load_properties

squashed:

init: add libinit hook for devices to create device links

let devices react to device uevents e.g. for creating
links in /dev/block/by-name/ when there is no partition name
available like on raspi with MBR boot device

Change-Id: If657c2608dc5f5363fed4a987f496cd09b56816f
diff --git a/init/Android.bp b/init/Android.bp
index 57e5a68..3a8b004 100644
--- a/init/Android.bp
+++ b/init/Android.bp
@@ -218,6 +218,7 @@
     defaults: [
         "init_defaults",
         "selinux_policy_version",
+        "vendor_init_defaults",
     ],
     srcs: init_common_sources + init_device_sources,
     export_include_dirs: ["."],
@@ -252,6 +253,14 @@
 }
 
 cc_library_static {
+    name: "vendor_init",
+    recovery_available: true,
+    srcs: [
+        "vendor_init.cpp",
+    ],
+}
+
+cc_library_static {
     name: "libinit",
     defaults: ["libinit_defaults"],
 }
@@ -277,7 +286,10 @@
     name: "init_second_stage_defaults",
     recovery_available: true,
     stem: "init",
-    defaults: ["init_defaults"],
+    defaults: [
+        "init_defaults",
+        "vendor_init_defaults",
+    ],
     srcs: ["main.cpp"],
     symlinks: ["ueventd"],
 }
diff --git a/init/devices.cpp b/init/devices.cpp
index 5560c20..b202eea 100644
--- a/init/devices.cpp
+++ b/init/devices.cpp
@@ -42,6 +42,10 @@
 #include "selabel.h"
 #include "util.h"
 
+#ifdef TARGET_CREATE_DEVICE_SYMLINKS
+#include "vendor_init.h"
+#endif
+
 using namespace std::chrono_literals;
 
 using android::base::Basename;
@@ -438,6 +442,10 @@
         links.emplace_back("/dev/sys/block/by-name/zoned_device");
     }
 
+#ifdef TARGET_CREATE_DEVICE_SYMLINKS
+    vendor_create_device_symlinks(uevent.partition_num, uevent.device_name, links);
+#endif
+
     auto last_slash = uevent.path.rfind('/');
     links.emplace_back(link_path + "/" + uevent.path.substr(last_slash + 1));
 
diff --git a/init/property_service.cpp b/init/property_service.cpp
index 0d6eb15..64f2949 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -77,6 +77,7 @@
 #include "subcontext.h"
 #include "system/core/init/property_service.pb.h"
 #include "util.h"
+#include "vendor_init.h"
 
 static constexpr char APPCOMPAT_OVERRIDE_PROP_FOLDERNAME[] =
         "/dev/__properties__/appcompat_override";
@@ -1458,6 +1459,10 @@
             }
             InitPropertySet("ro.persistent_properties.ready", "true");
             persistent_properties_loaded = true;
+
+            /* vendor-specific properties
+            */
+            vendor_load_properties();
             break;
         }
         default:
diff --git a/init/vendor_init.cpp b/init/vendor_init.cpp
new file mode 100644
index 0000000..051debf
--- /dev/null
+++ b/init/vendor_init.cpp
@@ -0,0 +1,48 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "vendor_init.h"
+
+namespace android {
+namespace init {
+
+/* init vendor override stubs */
+
+__attribute__ ((weak))
+void vendor_load_properties()
+{
+}
+
+#ifdef TARGET_CREATE_DEVICE_SYMLINKS
+__attribute__ ((weak))
+void vendor_create_device_symlinks(int, std::string, std::vector<std::string>&)
+{
+}
+#endif
+
+}
+}
\ No newline at end of file
diff --git a/init/vendor_init.h b/init/vendor_init.h
new file mode 100644
index 0000000..0bae2db
--- /dev/null
+++ b/init/vendor_init.h
@@ -0,0 +1,44 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __INIT_VENDOR__H__
+#define __INIT_VENDOR__H__
+
+#include <string>
+
+namespace android {
+namespace init {
+
+extern void vendor_load_properties(void);
+
+#ifdef TARGET_CREATE_DEVICE_SYMLINKS
+extern void vendor_create_device_symlinks(int partNum, std::string partName, std::vector<std::string>& links);
+#endif
+
+}
+}
+#endif /* __INIT_VENDOR__H__ */