From a764e4ba41d7c646246043f6b5263ffc2e523579 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Wed, 25 Oct 2017 18:28:53 +0900 Subject: [PATCH] Add a new operation type (BLOCK_LUKS_CLOSE) Change-Id: I83db5761c72df35c8b28126fff039014eacc00cf Signed-off-by: Hyotaek Shim --- src/block/block.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/block/block.c b/src/block/block.c index 9ab3f03..5385d02 100644 --- a/src/block/block.c +++ b/src/block/block.c @@ -94,7 +94,7 @@ #define EXTENDED_INTERNAL_PATH "/run/extended-internal-sd" #define PATH_LEN 55 -#define EXTENDEDSD_MOUNT_POINT "/opt/extendedsd" +#define EXTENDEDSD_MOUNT_PATH "/opt/extendedsd" #define EXTENDEDSD_STRING "ExtendedInternalSD" #define EXT4_NAME "ext4" @@ -123,6 +123,7 @@ enum block_dev_operation { BLOCK_DEV_FORMAT, BLOCK_DEV_INSERT, BLOCK_DEV_REMOVE, + BLOCK_LUKS_CLOSE, }; enum private_operation_state { @@ -570,7 +571,7 @@ static char *generate_mount_path(struct block_data *data) ret = get_scsi_mount_node(name, node, sizeof(node)); break; case BLOCK_EXTENDEDSD_DEV: - return strdup(EXTENDEDSD_MOUNT_POINT); + return strdup(EXTENDEDSD_MOUNT_PATH); default: _E("Invalid block type (%d)", data->block_type); return NULL; @@ -1835,11 +1836,12 @@ static void trigger_operation(struct block_device *bdev, dd_list *queue, struct _D("Unmount (%s) result:(%d)", devnode, ret); break; case BLOCK_DEV_REMOVE: - if (!strncmp(bdev->data->fs_type, LUKS_NAME, strlen(LUKS_NAME))) { - ret = ode_luks_close_sync(EXTENDEDSD_NAME); - if (ret < 0) - _E("Failed on ode_luks_close(%s)", EXTENDEDSD_NAME); - } + /* Do nothing */ + break; + case BLOCK_LUKS_CLOSE: + ret = ode_luks_close_sync(EXTENDEDSD_NAME); + if (ret < 0) + _E("Failed on ode_luks_close(%s)", EXTENDEDSD_NAME); break; default: _E("Operation type is invalid (%d)", op->op); @@ -2252,7 +2254,7 @@ static int add_block_device(struct udev_device *dev, const char *devnode, bool m return 0; } else if (mapper && !strncmp(bdev->data->fs_type, EXT4_NAME, strlen(EXT4_NAME))) { bdev->data->block_type = BLOCK_EXTENDEDSD_DEV; - ret = change_mount_point(bdev, EXTENDEDSD_MOUNT_POINT); + ret = change_mount_point(bdev, EXTENDEDSD_MOUNT_PATH); if (ret < 0) { ret = -EPERM; free_block_device(bdev); @@ -2304,7 +2306,8 @@ static int remove_block_device(struct udev_device *dev, const char *devnode) } if (!strncmp(bdev->data->fs_type, LUKS_NAME, strlen(LUKS_NAME))) { - bdev_extended = find_block_device_path(EXTENDEDSD_MOUNT_POINT); + bdev_extended = find_block_device_path(EXTENDEDSD_MOUNT_PATH); + if (bdev_extended) { BLOCK_FLAG_SET(bdev_extended->data, UNMOUNT_UNSAFE); @@ -2325,6 +2328,12 @@ static int remove_block_device(struct udev_device *dev, const char *devnode) _E("Failed to add operation (remove %s)", devnode); return ret; } + + ret = add_operation(bdev_extended, BLOCK_LUKS_CLOSE, NULL, NULL); + if (ret < 0) { + _E("Failed to add operation (luks_close %s)", devnode); + return ret; + } } else _E("fail to find block data for extended sd card"); } @@ -2787,7 +2796,7 @@ static DBusMessage *request_mount_block(dbus_method_reply_handle_h reply_handle, goto out; } else { bdev->data->block_type = BLOCK_EXTENDEDSD_DEV; - ret = change_mount_point(bdev, EXTENDEDSD_MOUNT_POINT); + ret = change_mount_point(bdev, EXTENDEDSD_MOUNT_PATH); if (ret < 0) { ret = -EPERM; goto out; -- 2.7.4