- Primary mmc information is used to install apps on the mmc.
Thus primary mmc information api is necessary to avoid
iterations with previous apis
Change-Id: Id27f575d0442225d0cb909220716e5d527ad506d
Signed-off-by: taeyoung <ty317.kim@samsung.com>
SET(HEADERS
include/storage.h
- include/storage-expand.h)
+ include/storage-expand.h
+ include/storage-internal.h)
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g")
src/storage.c
src/storage-internal.c
src/storage-external.c
- src/storage-external-dbus.c)
+ src/storage-external-dbus.c
+ src/storage-external-inhouse.c)
ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS} ${TARGET_SRCS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${rpkgs_LDFLAGS})
--- /dev/null
+/*
+ * storage
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __STORAGE_INTERNAL_H__
+#define __STORAGE_INTERNAL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * @addtogroup CAPI_SYSTEM_STORAGE_MODULE
+ * @{
+ */
+
+#include <tizen.h>
+#include "storage.h"
+
+#define STORAGE_ERROR_NO_DEVICE TIZEN_ERROR_NO_SUCH_DEVICE
+
+/**
+ * @brief Get the mount path for the primary partition of sdcard.
+ *
+ * @since_tizen 3.0
+ *
+ * @remarks You must release the path using free() after use
+ *
+ * @param[out] storage_id The storage id
+ * @param[out] path The mount path of sdcard primary partition.
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #STORAGE_ERROR_NONE Successful
+ * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STORAGE_ERROR_NO_DEVICE No such device
+ */
+int storage_get_primary_sdcard(int *storage_id, char **path);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __STORAGE_INTERNAL_H__ */
return conn;
}
-static GVariant *dbus_method_call_sync(const gchar *dest, const gchar *path,
+GVariant *dbus_method_call_sync(const gchar *dest, const gchar *path,
const gchar *iface, const gchar *method, GVariant *param)
{
GDBusConnection *conn;
GError *err = NULL;
GVariant *ret;
- if (!dest || !path || !iface || !method || !param)
+ if (!dest || !path || !iface || !method)
return NULL;
conn = get_dbus_connection();
int storage_ext_get_device_info(int storage_id, storage_ext_device *info);
+/* storage-internal.c */
+GVariant *dbus_method_call_sync(const gchar *dest, const gchar *path,
+ const gchar *iface, const gchar *method, GVariant *param);
+
#endif /* __STORAGE_EXTERNAL_DBUS_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include "common.h"
+#include "list.h"
+#include "log.h"
+#include "storage-internal.h"
+#include "storage-external-dbus.h"
+
+API int storage_get_primary_sdcard(int *storage_id, char **path)
+{
+ GVariant *result;
+ storage_ext_device info;
+
+ if (!storage_id || !path)
+ return STORAGE_ERROR_INVALID_PARAMETER;
+
+ result = dbus_method_call_sync(STORAGE_EXT_BUS_NAME,
+ STORAGE_EXT_PATH_MANAGER,
+ STORAGE_EXT_IFACE_MANAGER,
+ "GetMmcPrimary",
+ NULL);
+ if (!result) {
+ _E("Failed to get primary sdcard partition"); //LCOV_EXCL_LINE
+ return STORAGE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ 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);
+
+ if (info.storage_id < 0)
+ return STORAGE_ERROR_NO_DEVICE;
+
+ *path = strdup(info.mount_point);
+ if (*path == NULL)
+ return STORAGE_ERROR_OUT_OF_MEMORY;
+
+ *storage_id = info.storage_id;
+
+ return STORAGE_ERROR_NONE;
+}