free(callback);
}
}
+
+int storage_ext_get_device_info(int storage_id, storage_ext_device *info)
+{
+ GVariant *result;
+
+ result = dbus_method_call_sync(STORAGE_EXT_BUS_NAME,
+ STORAGE_EXT_PATH_MANAGER,
+ STORAGE_EXT_IFACE_MANAGER,
+ "GetDeviceInfoByID",
+ g_variant_new("(i)", storage_id));
+ if (!result) {
+ _E("There is no storage with the storage id (%d)", storage_id);
+ return -ENODEV;
+ }
+
+ g_variant_get(result, "(issssssisibii)",
+ &info->type, &info->devnode, &info->syspath,
+ &info->fs_usage, &info->fs_type,
+ &info->fs_version, &info->fs_uuid,
+ &info->readonly, &info->mount_point,
+ &info->state, &info->primary,
+ &info->flags, &info->storage_id);
+
+ g_variant_unref(result);
+
+ return 0;
+}
int storage_ext_register_device_change(storage_ext_changed_cb func, void *data);
void storage_ext_unregister_device_change(storage_ext_changed_cb func);
+int storage_ext_get_device_info(int storage_id, storage_ext_device *info);
+
#endif /* __STORAGE_EXTERNAL_DBUS_H__ */
storage_ext_unregister_device_change(storage_ext_state_changed);
return 0;
-}
\ No newline at end of file
+}
+
+int storage_ext_get_root(int storage_id, char *path, size_t len)
+{
+ storage_ext_device *dev;
+ int ret;
+
+ if (storage_id < 0 || !path)
+ return -EINVAL;
+
+ dev = calloc(1, sizeof(storage_ext_device));
+ if (!dev) {
+ _E("calloc failed");
+ return -ENOMEM;
+ }
+
+ ret = storage_ext_get_device_info(storage_id, dev);
+ if (ret < 0) {
+ _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret);
+ goto out;
+ }
+
+ snprintf(path, len, "%s", dev->mount_point);
+ ret = 0;
+
+out:
+ storage_ext_release_device(&dev);
+ return ret;
+}
int storage_ext_foreach_device_list(storage_device_supported_cb callback, void *user_data);
int storage_ext_register_cb(enum storage_cb_type type, struct storage_cb_info *info);
int storage_ext_unregister_cb(enum storage_cb_type type, struct storage_cb_info *info);
+int storage_ext_get_root(int storage_id, char *path, size_t len);
#endif /* __STORAGE_EXTERNAL_H__ */
{
const struct storage_ops *st;
dd_list *elem;
+ char root[PATH_MAX];
+ int ret;
if (!path || storage_id < 0) {
_E("Invalid parameger");
return STORAGE_ERROR_NONE;
}
- /* TODO external storage */
+ /* external storage */
+ ret = storage_ext_get_root(storage_id, root, sizeof(root));
+ if (ret < 0) {
+ _E("Failed to get root path of external storage(%d, %d", storage_id, ret);
+ return STORAGE_ERROR_INVALID_PARAMETER;
+ }
+
+ *path = strdup(root);
+ if (!*path) {
+ _E("Failed to copy the root string : %d", errno);
+ return STORAGE_ERROR_OUT_OF_MEMORY;
+ }
return STORAGE_ERROR_NONE;
}