diff options
-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; } |