Check type for registered callback 65/164065/1 accepted/tizen/unified/20171218.143835 submit/tizen/20171218.023220
authorpr.jung <pr.jung@samsung.com>
Thu, 14 Dec 2017 08:13:31 +0000 (17:13 +0900)
committerJung <pr.jung@samsung.com>
Fri, 15 Dec 2017 05:57:37 +0000 (05:57 +0000)
- 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 e4985293b6e75f30054792ec1fc7f5e4289490ae..aee5d6ca0d96490bf941982052fc55708006f44a 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;
 }