From f6fa3a3517d7e5e87ecf2c90ae87fe9a96a67252 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Tue, 17 Oct 2017 21:06:25 +0900 Subject: [PATCH] Fix sleep function waiting for udev properties Change-Id: Ie893ebe310f20bcaab3630c139e1329e0167eed6 Signed-off-by: Hyotaek Shim (cherry picked from commit 22b694ec443b45c2fab92af28af3f07a37e14589) --- src/block/block.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/block/block.c b/src/block/block.c index 23e450d..8884307 100644 --- a/src/block/block.c +++ b/src/block/block.c @@ -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); -- 2.7.4