diff options
author | David Ng <dave@codeaurora.org> | 2014-11-21 18:01:08 -0800 |
---|---|---|
committer | Ricardo Cerqueira <ricardo@cyngn.com> | 2015-11-24 16:16:09 +0000 |
commit | 966f66517070731a3a67be6e73f22a73768b6e34 (patch) | |
tree | 9e164d5d3cd860f5580cd33fe49a4ff6a08e2899 | |
parent | fc73ae3d9432a00519d684bd73d714d04de3da83 (diff) | |
download | system_core-966f66517070731a3a67be6e73f22a73768b6e34.zip system_core-966f66517070731a3a67be6e73f22a73768b6e34.tar.gz system_core-966f66517070731a3a67be6e73f22a73768b6e34.tar.bz2 |
ueventd: Fix bootdevice by-name/by-num link creation
Create bootdevice by-name/by-num links only if the block
device is the bootdevice. This fixes the issue of
bootdevice path being created incorrectly if the first
reported device with by-name/by-num is not the bootdevice.
It also fixes devices in which the bootdevice property
doesn't exist, or the symlink is created by a later step in
the init sequence (such as init.rc itself)
Change-Id: Ifb68080e3149917f9ee88a4a421007f29e8d83d2
-rw-r--r-- | init/devices.cpp | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/init/devices.cpp b/init/devices.cpp index d8de450..bb54cca 100644 --- a/init/devices.cpp +++ b/init/devices.cpp @@ -505,6 +505,7 @@ static char **get_block_device_symlinks(struct uevent *uevent) char link_path[256]; int link_num = 0; char *p; + int is_bootdevice = -1; int mtd_fd = -1; int nr; char mtd_name_path[256]; @@ -556,6 +557,13 @@ static char **get_block_device_symlinks(struct uevent *uevent) free(p); } + if (pdev && boot_device[0] != '\0' && strstr(device, boot_device)) { + make_link_init(link_path, "/dev/block/bootdevice"); + is_bootdevice = 1; + } else { + is_bootdevice = 0; + } + if (uevent->partition_name) { p = strdup(uevent->partition_name); sanitize(p); @@ -565,11 +573,13 @@ static char **get_block_device_symlinks(struct uevent *uevent) link_num++; else links[link_num] = NULL; - if (asprintf(&links[link_num], "/dev/block/bootdevice/by-name/%s", p) > 0) - link_num++; - else - links[link_num] = NULL; + if (is_bootdevice > 0) { + if (asprintf(&links[link_num], "/dev/block/bootdevice/by-name/%s", p) > 0) + link_num++; + else + links[link_num] = NULL; + } free(p); } @@ -579,10 +589,12 @@ static char **get_block_device_symlinks(struct uevent *uevent) else links[link_num] = NULL; - if (asprintf(&links[link_num], "/dev/block/bootdevice/by-num/p%d", uevent->partition_num) > 0) - link_num++; - else - links[link_num] = NULL; + if (is_bootdevice > 0) { + if (asprintf(&links[link_num], "/dev/block/bootdevice/by-num/p%d", uevent->partition_num) > 0) + link_num++; + else + links[link_num] = NULL; + } } slash = strrchr(uevent->path, '/'); @@ -591,11 +603,6 @@ static char **get_block_device_symlinks(struct uevent *uevent) else links[link_num] = NULL; - if (pdev && boot_device[0] != '\0' && strstr(device, boot_device)) { - /* Create bootdevice symlink for platform boot stroage device */ - make_link_init(link_path, "/dev/block/bootdevice"); - } - return links; } |