init: remove the existing early_mount code
keeps parts of the code that are still needed for the fs_mgr
+ dt based implementation
b/27805372
Test: boot angler, sailfish without regressions
Change-Id: I1b08f8b7b4f2e67118d328443a5011c0f5ead919
Signed-off-by: Sandeep Patil <sspatil@google.com>
diff --git a/init/devices.cpp b/init/devices.cpp
index c7f3efa..2224c13 100644
--- a/init/devices.cpp
+++ b/init/devices.cpp
@@ -874,8 +874,8 @@
#define UEVENT_MSG_LEN 2048
-template<typename T>
-static inline coldboot_action_t handle_device_fd_with(const T& handle_uevent)
+static inline coldboot_action_t handle_device_fd_with(
+ std::function<coldboot_action_t(uevent* uevent)> handle_uevent)
{
char msg[UEVENT_MSG_LEN+2];
int n;
@@ -985,67 +985,6 @@
return COLDBOOT_CONTINUE;
}
-static coldboot_action_t early_uevent_handler(struct uevent *uevent, const char *base, bool is_block)
-{
- const char *name;
- char devpath[DEVPATH_LEN];
-
- if (is_block && strncmp(uevent->subsystem, "block", 5))
- return COLDBOOT_STOP;
-
- name = parse_device_name(uevent, MAX_DEV_NAME);
- if (!name) {
- LOG(ERROR) << "Failed to parse dev name from uevent: " << uevent->action
- << " " << uevent->partition_name << " " << uevent->partition_num
- << " " << uevent->major << ":" << uevent->minor;
- return COLDBOOT_STOP;
- }
-
- snprintf(devpath, sizeof(devpath), "%s%s", base, name);
- make_dir(base, 0755);
-
- dev_t dev = makedev(uevent->major, uevent->minor);
- mode_t mode = 0600 | (is_block ? S_IFBLK : S_IFCHR);
- mknod(devpath, mode, dev);
-
- return COLDBOOT_STOP;
-}
-
-void early_create_dev(const std::string& syspath, early_device_type dev_type)
-{
- android::base::unique_fd dfd(open(syspath.c_str(), O_RDONLY));
- if (dfd < 0) {
- LOG(ERROR) << "Failed to open " << syspath;
- return;
- }
-
- android::base::unique_fd fd(openat(dfd, "uevent", O_WRONLY));
- if (fd < 0) {
- LOG(ERROR) << "Failed to open " << syspath << "/uevent";
- return;
- }
-
- fcntl(device_fd, F_SETFL, O_NONBLOCK);
-
- write(fd, "add\n", 4);
- handle_device_fd_with(dev_type == EARLY_BLOCK_DEV ?
- [](uevent* uevent) -> coldboot_action_t {
- return early_uevent_handler(uevent, "/dev/block/", true);
- } :
- [](uevent* uevent) -> coldboot_action_t {
- return early_uevent_handler(uevent, "/dev/", false);
- });
-}
-
-int early_device_socket_open() {
- device_fd = uevent_open_socket(256*1024, true);
- return device_fd < 0;
-}
-
-void early_device_socket_close() {
- close(device_fd);
-}
-
void device_init(const char* path, coldboot_callback fn) {
sehandle = selinux_android_file_context_handle();
selinux_status_open(true);