Fix partition search for ramdisk-recovery image 78/195978/1
authorDongwoo Lee <dwoo08.lee@samsung.com>
Thu, 20 Dec 2018 07:34:43 +0000 (16:34 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Thu, 20 Dec 2018 07:58:15 +0000 (16:58 +0900)
Since ramdisk-recovery.img is mounted on memory space and it also has
the same label with physical partition, the target partition could be
wrong if the ram-mounted partition is searched first. To resolve it,
this fixes partition search as excepting the devices including 'ram'
on its node name.

Change-Id: I15b6124eb202f0c5ddbe8ca518bfcc892309aa9a
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
src/dfu.c

index a0a3bed..5fe2854 100644 (file)
--- a/src/dfu.c
+++ b/src/dfu.c
@@ -185,6 +185,16 @@ static char *get_partition_devname(const char *label)
                        if (!strncmp(type, "LABEL", 5) && !strncmp(value, label, strlen(label))) {
                                char *devname = strdup(blkid_dev_devname(dev));
 
+                               /*
+                                * To distinguish physical partition and ram mounted partition,
+                                * continue to search the next entry if the devname includes
+                                * 'ram'(eg. /dev/ram0).
+                                */
+                               if (strstr(devname, "ram")) {
+                                       free(devname);
+                                       continue;
+                               }
+
                                blkid_tag_iterate_end(tag_iter);
                                blkid_dev_iterate_end(dev_iter);
                                blkid_put_cache(cache);