block: Do not add INSERT operation for unformatted device (except mmc) 66/154366/2 accepted/tizen/4.0/unified/20171010.163310 submit/tizen_4.0/20171010.082413
authorpr.jung <pr.jung@samsung.com>
Tue, 10 Oct 2017 06:23:49 +0000 (15:23 +0900)
committerpr.jung <pr.jung@samsung.com>
Tue, 10 Oct 2017 08:12:50 +0000 (17:12 +0900)
Change-Id: I73ed8bf74b367397f25ec043d690d7caa63e7b30
Signed-off-by: pr.jung <pr.jung@samsung.com>
src/block/block.c

index bc8e798..edda2e8 100644 (file)
@@ -2152,20 +2152,20 @@ static int add_block_device(struct udev_device *dev, const char *devnode, bool i
 
        pthread_mutex_unlock(&(th_manager[thread_id].mutex));
 
-       ret = add_operation(bdev, BLOCK_DEV_INSERT, NULL, (void *)data);
-       if (ret < 0) {
-               _E("Failed to add operation (insert %s)", devnode);
-               free_block_device(bdev);
-               return ret;
-       }
-
        /* Check this sdcard is already formatted for extended internal sdcard */
        if (block_conf[bdev->data->block_type].extendedinternal &&
                bdev->data->block_type == BLOCK_MMC_DEV &&
-               bdev->data->primary) {
+               bdev->data->primary) { // sdcard primary partition and extended internal option is on
                _I("Check whether sdcard will be used as extended internal storage");
 
-               if (!init) { // after booting is done
+               if (!init) { // after booting is done launch popup for setting
+                       ret = add_operation(bdev, BLOCK_DEV_INSERT, NULL, (void *)data);
+                       if (ret < 0) {
+                               _E("Failed to add operation (insert %s)", devnode);
+                               free_block_device(bdev);
+                               return ret;
+                       }
+
                        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);
                        if (ret < 0)
@@ -2183,6 +2183,7 @@ static int add_block_device(struct udev_device *dev, const char *devnode, bool i
                                ret = change_mount_point(bdev, EXTENDED_SD_PATH);
                                if (ret < 0) {
                                        ret = -EPERM;
+                                       free_block_device(bdev);
                                        return ret;
                                }
 
@@ -2196,6 +2197,13 @@ static int add_block_device(struct udev_device *dev, const char *devnode, bool i
                }
        }
 
+       ret = add_operation(bdev, BLOCK_DEV_INSERT, NULL, (void *)data);
+       if (ret < 0) {
+               _E("Failed to add operation (insert %s)", devnode);
+               free_block_device(bdev);
+               return ret;
+       }
+
        /* Create file for block device /run/external-storage/id */
        if (bdev->data->block_type == BLOCK_MMC_EXTENDED_INTERNAL_DEV)
                create_file(bdev->data->id, bdev->data->mount_point, true);