Fix sleep function waiting for udev properties 13/156213/1
authorHyotaek Shim <hyotaek.shim@samsung.com>
Tue, 17 Oct 2017 12:06:25 +0000 (21:06 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Tue, 17 Oct 2017 12:06:25 +0000 (21:06 +0900)
Change-Id: Ie893ebe310f20bcaab3630c139e1329e0167eed6
Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
src/block/block.c

index 23e450d..8884307 100644 (file)
@@ -1084,6 +1084,7 @@ static int retrieve_udev_device(struct block_data *data, bool mount_point_update
        struct udev *udev;
        struct udev_device *dev;
        int r;
+       int wait;
 
        if (!data)
                return -EINVAL;
@@ -1101,6 +1102,13 @@ static int retrieve_udev_device(struct block_data *data, bool mount_point_update
                return -EPERM;
        }
 
+       for (wait = 0; wait < 3; wait++) {
+               if (!udev_device_get_property_value(dev, "ID_FS_TYPE"))
+                       sleep(1);
+               else
+                       break;
+       }
+
        r = update_block_data(data,
                        udev_device_get_property_value(dev, "ID_FS_USAGE"),
                        udev_device_get_property_value(dev, "ID_FS_TYPE"),
@@ -1451,9 +1459,6 @@ static int block_format(struct block_data *data,
                goto out;
        }
 
-       /* it takes some seconds til kernel set udev property */
-       sleep(2);
-
        /* need to update the partition data.
         * It can be changed in doing format. */
        if (udev_update)
@@ -2191,12 +2196,6 @@ static int add_block_device(struct udev_device *dev, const char *devnode, bool m
                free_block_device(bdev);
                return -EPERM;
        } else if (!strncmp(bdev->data->fs_type, LUKS_NAME, strlen(LUKS_NAME))) {
-               if (ret < 0) {
-                       ret = -EPERM;
-                       free_block_device(bdev);
-                       return ret;
-               }
-
                /* ---- ODE UI launch ----
                snprintf(id_string, PATH_LEN, "%d", bdev->data->id);
                ret = launch_system_app(POPUP_DEFAULT, 4, POPUP_KEY_CONTENT, "sdcardsetup", POPUP_SDCARD_ID, id_string);