block: Move create file logic for block device 43/220843/1
authorYunmi Ha <yunmi.ha@samsung.com>
Tue, 24 Dec 2019 02:16:00 +0000 (11:16 +0900)
committerYunmi Ha <yunmi.ha@samsung.com>
Tue, 24 Dec 2019 02:16:00 +0000 (11:16 +0900)
- After mount, create "/run/external-storage/id" file.

Change-Id: I7ba6f8fb94206d742742ac422adad8ce2526eec3
Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
src/block/block.c

index f48dede..0c06b66 100644 (file)
@@ -1020,6 +1020,12 @@ static bool pipe_cb(int fd, void *data)
                }
                goto out;
        }
+
+       if (pdata.op == BLOCK_DEV_MOUNT && (pdata.result == 0)) {
+               /* Create file for block device /run/external-storage/id */
+               create_file(pdata.bdev->data->id, pdata.bdev->data->mount_point, pdata.bdev->data->block_type == BLOCK_EXTENDEDSD_DEV);
+       }
+
        if (pdata.op == BLOCK_DEV_MOUNT &&
                pdata.bdev->data->state == BLOCK_MOUNT &&
                pdata.bdev->data->block_type == BLOCK_MMC_DEV &&
@@ -1035,6 +1041,7 @@ static bool pipe_cb(int fd, void *data)
                if (ret != 0)
                        _E("Failed to popup: %d", ret);
        }
+
        if (pdata.op == BLOCK_DEV_UNMOUNT) {
                /* Remove file for block device /run/xxxxxx/id */
                remove_file(pdata.bdev->data->id, pdata.bdev->data->block_type == BLOCK_EXTENDEDSD_DEV);
@@ -2313,8 +2320,6 @@ static int add_block_device(struct udev_device *dev, const char *devnode, bool m
                return 0;
        }
 
-       /* Create file for block device /run/external-storage/id */
-       create_file(bdev->data->id, bdev->data->mount_point, bdev->data->block_type == BLOCK_EXTENDEDSD_DEV);
        ret = add_operation(bdev, BLOCK_DEV_MOUNT, NULL, NULL);
        if (ret < 0) {
                _E("Failed to add operation(mount, %s).", devnode);
@@ -2879,12 +2884,6 @@ static GVariant *request_mount_block(GDBusConnection *conn,
                        ret = -EPERM;
                        goto out;
                }
-
-               /* Create /run/external-storage/id file */
-               create_file(bdev->data->id, bdev->data->mount_point, false);
-       } else {
-               /* Create file for block device /run/external-storage/id */
-               create_file(bdev->data->id, bdev->data->mount_point, false);
        }
 
        ret = add_operation(bdev, BLOCK_DEV_MOUNT, invocation, NULL);