+
+API int storage_unset_changed_cb(storage_type_e type, storage_changed_cb callback)
+{
+ struct storage_cb_info info;
+ int ret_val;
+
+ if (type == STORAGE_TYPE_INTERNAL) {
+ _E("Internal storage is not supported");
+ return STORAGE_ERROR_INVALID_PARAMETER;
+ }
+
+ if (type != STORAGE_TYPE_EXTERNAL && type != STORAGE_TYPE_EXTENDED_INTERNAL) {
+ _E("Invalid type (%d)", type);
+ return STORAGE_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!callback) {
+ _E("Callback is NULL");
+ return STORAGE_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!storage_ext_is_supported()) {
+ //LCOV_EXCL_START
+ _E("Block module is not enabled");
+ return STORAGE_ERROR_NOT_SUPPORTED;
+ //LCOV_EXCL_STOP
+ }
+
+ /* external storage */
+ info.type = type;
+ info.type_cb = callback;
+
+ ret_val = storage_ext_unregister_cb(STORAGE_CALLBACK_TYPE, &info);
+ if (ret_val < 0) {
+ //LCOV_EXCL_START
+ _E("Failed to unregister storage callback(ret:%d)", ret_val);
+ return STORAGE_ERROR_OPERATION_FAILED;
+ //LCOV_EXCL_STOP
+ }
+
+ return STORAGE_ERROR_NONE;
+}
+
+API int storage_get_type_dev(int storage_id, storage_type_e *type, storage_dev_e *dev)
+{
+ storage_ext_device *ext_dev;
+ int ret;
+
+ if (storage_id < 0 || !type || !dev) {
+ _E("Invalid parameter");
+ return STORAGE_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = storage_get_type(storage_id, type);
+ if (ret != STORAGE_ERROR_NONE) {
+ //LCOV_EXCL_START
+ _E("Failed to get storage type: %d", ret);
+ return ret;
+ //LCOV_EXCL_STOP
+ }
+ if (*type == STORAGE_TYPE_INTERNAL || *type == STORAGE_TYPE_EXTENDED_INTERNAL)
+ return STORAGE_ERROR_INVALID_PARAMETER;
+
+ if (!storage_ext_is_supported()) {
+ //LCOV_EXCL_START
+ _D("Block module is not enabled");
+ return STORAGE_ERROR_NOT_SUPPORTED;
+ //LCOV_EXCL_STOP
+ }
+
+ ext_dev = calloc(1, sizeof(storage_ext_device));
+ if (!ext_dev) {
+ //LCOV_EXCL_START System Error
+ _E("calloc failed");
+ return STORAGE_ERROR_OUT_OF_MEMORY;
+ //LCOV_EXCL_STOP
+ }
+
+ ret = storage_ext_get_device_info(storage_id, ext_dev);
+ if (ret < 0) {
+ _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE
+ if (ret == -ENODEV) {
+ ret = STORAGE_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+ //LCOV_EXCL_START
+ ret = STORAGE_ERROR_OPERATION_FAILED;
+ goto out;
+ //LCOV_EXCL_STOP
+ }
+
+ if (ext_dev->type == STORAGE_EXT_SCSI)
+ *dev = STORAGE_DEV_EXT_USB_MASS_STORAGE;
+ else if (ext_dev->type == STORAGE_EXT_MMC)
+ *dev = STORAGE_DEV_EXT_SDCARD;
+ ret = STORAGE_ERROR_NONE;
+ _I("type: %d(internal:0, external:1) dev: %d(sdcard: 1001, usb: 1002)", *type, *dev);
+
+out:
+ storage_ext_release_device(&ext_dev);
+ return ret;
+}
+
+static void __CONSTRUCTOR__ init(void)
+{
+ const char *tmp;
+ char *token;
+ int i;
+
+ for (i = 0 ; i <= STORAGE_DIRECTORY_OTHERS ; i++) {
+ tmp = tzplatform_getenv(tz_id[i]);
+ if (tmp != NULL) {
+ token = rindex(tmp, '/');
+ if (token != NULL) {
+ token++;
+ dir_path[i] = strdup(token);
+ }
+ }
+ }
+}