From 4588a995068752e0867acfc0fbca39a237d56a40 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Thu, 14 Dec 2017 17:13:31 +0900 Subject: [PATCH] Check type for registered callback - Storage type and registered callback type should be the same Change-Id: If9bc286b93595f5f92889b435bdeddfbfb7abc19 Signed-off-by: pr.jung --- src/storage-external.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/storage-external.c b/src/storage-external.c index e498529..aee5d6c 100755 --- a/src/storage-external.c +++ b/src/storage-external.c @@ -32,6 +32,8 @@ #define EXTENDED_INTERNAL_PATH "/run/extended-internal-sd" #define PATH_LEN 55 +#define LUKS_NAME "crypto_LUKS" + static dd_list *cb_list[STORAGE_CALLBACK_MAX]; static int storage_ext_get_dev_state(storage_ext_device *dev, @@ -203,6 +205,7 @@ static int storage_ext_type_changed(storage_ext_device *dev, enum storage_ext_st storage_state_e state; int ret; storage_dev_e strdev; + storage_type_e storage_type; const char *fstype, *fsuuid, *mountpath; if (!dev) @@ -217,13 +220,16 @@ static int storage_ext_type_changed(storage_ext_device *dev, enum storage_ext_st return ret; } - if (dev->type == STORAGE_EXT_SCSI) + if (dev->type == STORAGE_EXT_SCSI) { strdev = STORAGE_DEV_EXT_USB_MASS_STORAGE; - else if (dev->type == STORAGE_EXT_MMC) + storage_type = STORAGE_TYPE_EXTERNAL; + } else if (dev->type == STORAGE_EXT_MMC) { strdev = STORAGE_DEV_EXT_SDCARD; - else if (dev->type == STORAGE_EXT_MMC_EXTENDED_INTERNAL) + storage_type = STORAGE_TYPE_EXTERNAL; + } else if (dev->type == STORAGE_EXT_MMC_EXTENDED_INTERNAL) { strdev = STORAGE_DEV_EXTENDED_INTERNAL; - else { + storage_type = STORAGE_TYPE_EXTENDED_INTERNAL; + } else { _E("Invalid dev type (%d)", dev->type); return -EINVAL; } @@ -232,11 +238,17 @@ static int storage_ext_type_changed(storage_ext_device *dev, enum storage_ext_st fsuuid = (dev->fs_uuid ? (const char *)dev->fs_uuid : ""); mountpath = (dev->mount_point ? (const char *)dev->mount_point : ""); - DD_LIST_FOREACH(cb_list[STORAGE_CALLBACK_TYPE], elem, cb_info) + if (!strncmp(fstype, LUKS_NAME, strlen(LUKS_NAME))) + storage_type = STORAGE_TYPE_EXTENDED_INTERNAL; + + DD_LIST_FOREACH(cb_list[STORAGE_CALLBACK_TYPE], elem, cb_info) { + if (cb_info->type != storage_type) + continue; if (cb_info->type_cb) cb_info->type_cb(dev->storage_id, strdev, state, fstype, fsuuid, mountpath, dev->primary, dev->flags, cb_info->user_data); + } return 0; } -- 2.7.4