Check type for registered callback 61/164061/2 tizen_4.0_tv accepted/tizen/4.0/unified/20171219.072301 submit/tizen_4.0/20171218.023149 tizen_4.0.IoT.p2_release
authorpr.jung <pr.jung@samsung.com>
Thu, 14 Dec 2017 08:13:31 +0000 (17:13 +0900)
committerpr.jung <pr.jung@samsung.com>
Fri, 15 Dec 2017 05:57:04 +0000 (14:57 +0900)
- Storage type and registered callback type should be the same

Change-Id: If9bc286b93595f5f92889b435bdeddfbfb7abc19
Signed-off-by: pr.jung <pr.jung@samsung.com>
src/storage-external.c

index e498529..aee5d6c 100755 (executable)
@@ -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;
 }