Change returned value from STORAGE_ERROR_NOT_SUPPORTED
[platform/core/system/libstorage.git] / src / storage-external-dbus.h
1 /*
2  * libstorage
3  *
4  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the License);
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19
20 #ifndef __STORAGE_EXTERNAL_DBUS_H__
21 #define __STORAGE_EXTERNAL_DBUS_H__
22
23 #include <stdbool.h>
24 #include <glib.h>
25 #include <gio/gio.h>
26 #include "list.h"
27
28 #define STORAGE_EXT_BUS_NAME              "org.tizen.system.storage"
29 #define STORAGE_EXT_PATH_MANAGER          "/Org/Tizen/System/Storage/Block/Manager"
30 #define STORAGE_EXT_IFACE_MANAGER         STORAGE_EXT_BUS_NAME".BlockManager"
31 #define STORAGE_EXT_PATH_STORAGE          "/Org/Tizen/System/Storage/Storage"
32 #define STORAGE_EXT_IFACE_STORAGE         STORAGE_EXT_BUS_NAME".storage"
33
34 enum mount_state {
35         STORAGE_EXT_UNMOUNTED,
36         STORAGE_EXT_MOUNTED,
37 };
38
39 enum storage_ext_state {
40         STORAGE_EXT_REMOVED,
41         STORAGE_EXT_ADDED,
42         STORAGE_EXT_CHANGED,
43         STORAGE_EXT_BLOCKED,
44 };
45
46 enum storage_ext_type {
47         STORAGE_EXT_SCSI,
48         STORAGE_EXT_MMC,
49         STORAGE_EXT_MMC_EXTENDED_INTERNAL,
50 };
51
52 enum storage_ext_flags {
53         FLAG_NONE        = 0,
54         UNMOUNT_UNSAFE   = 1 << 0,
55         FS_BROKEN        = 1 << 1,
56         FS_EMPTY         = 1 << 2,
57         FS_NOT_SUPPORTED = 1 << 3,
58         MOUNT_READONLY   = 1 << 4,
59 };
60
61 typedef struct _storage_ext_device {
62         enum storage_ext_type type;
63         char *devnode;
64         char *syspath;
65         char *fs_usage;
66         char *fs_type;
67         char *fs_version;
68         char *fs_uuid;
69         bool readonly;
70         char *mount_point;
71         enum mount_state state;
72         bool primary;   /* the first partition */
73         int flags;
74         int storage_id;
75 } storage_ext_device;
76
77 /* it's for 32bit file offset */
78 struct statvfs_32 {
79         unsigned long int f_bsize;
80         unsigned long int f_frsize;
81         unsigned long int f_blocks;
82         unsigned long int f_bfree;
83         unsigned long int f_bavail;
84         unsigned long int f_files;
85         unsigned long int f_ffree;
86         unsigned long int f_favail;
87         unsigned long int f_fsid;
88 #ifdef _STATVFSBUF_F_UNUSED
89         int __f_unused;
90 #endif
91         unsigned long int f_flag;
92         unsigned long int f_namemax;
93         int __f_spare[6];
94 };
95
96 typedef int (*storage_ext_changed_cb)(storage_ext_device *dev, enum storage_ext_state state, void *data);
97
98 int storage_ext_is_supported(void);
99 void storage_ext_release_device(storage_ext_device **dev);
100 void storage_ext_release_list(dd_list **list);
101 int storage_ext_get_list(dd_list **list);
102 int storage_ext_get_statvfs(char *path, struct statvfs_32 *buf);
103 int storage_ext_get_statvfs_size64(char *path, struct statvfs *buf);
104
105 int storage_ext_register_device_change(storage_ext_changed_cb func, void *data);
106 void storage_ext_unregister_device_change(storage_ext_changed_cb func);
107
108 int storage_ext_get_device_info(int storage_id, storage_ext_device *info);
109 int storage_ext_get_storage_level(const char *path, char **level);
110
111 typedef void (*dbus_pending_cb)(GVariant *var, void *user_data, GError *err);
112 int dbus_method_async_with_reply_var(const char *dest, const char *path,
113                 const char *iface, const char *method, GVariant *param,
114                 dbus_pending_cb cb, int timeout, void *data);
115 /* storage-internal.c */
116 GVariant *dbus_method_call_sync(const gchar *dest, const gchar *path,
117                 const gchar *iface, const gchar *method, GVariant *param);
118
119 #endif /* __STORAGE_EXTERNAL_DBUS_H__ */