2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
26 #include "storage-internal.h"
27 #include "storage-external-dbus.h"
29 API int storage_get_primary_sdcard(int *storage_id, char **path)
32 storage_ext_device info;
34 if (!storage_id || !path)
35 return STORAGE_ERROR_INVALID_PARAMETER;
37 result = dbus_method_call_sync(STORAGE_EXT_BUS_NAME,
38 STORAGE_EXT_PATH_MANAGER,
39 STORAGE_EXT_IFACE_MANAGER,
43 _E("Failed to get primary sdcard partition"); //LCOV_EXCL_LINE
44 return STORAGE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
47 g_variant_get(result, "(issssssisibii)",
48 &info.type, &info.devnode, &info.syspath,
49 &info.fs_usage, &info.fs_type,
50 &info.fs_version, &info.fs_uuid,
51 &info.readonly, &info.mount_point,
52 &info.state, &info.primary,
53 &info.flags, &info.storage_id);
55 g_variant_unref(result);
57 if (info.storage_id < 0)
58 return STORAGE_ERROR_NO_DEVICE;
60 *path = strdup(info.mount_point);
62 return STORAGE_ERROR_OUT_OF_MEMORY;
64 *storage_id = info.storage_id;
66 return STORAGE_ERROR_NONE;