internal: storage list is used just for internal storage
[platform/core/system/libstorage.git] / include / common.h
1 /*
2  * storage
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18
19 #ifndef __COMMON_H__
20 #define __COMMON_H__
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 #include "storage-expand.h"
27
28 #ifndef API
29 #define API __attribute__ ((visibility("default")))
30 #endif
31
32 #ifndef __WEAK__
33 #define __WEAK__ __attribute__ ((weak))
34 #endif
35
36 #ifndef __CONSTRUCTOR__
37 #define __CONSTRUCTOR__ __attribute__ ((constructor))
38 #endif
39
40 #ifndef __DESTRUCTOR__
41 #define __DESTRUCTOR__ __attribute__ ((destructor))
42 #endif
43
44 enum storage_cb_type {
45         STORAGE_CALLBACK_STATE,
46         STORAGE_CALLBACK_MAX,
47 };
48
49 struct storage_cb_info {
50         int id;
51         storage_state_changed_cb state_cb;
52         void *user_data;
53 };
54
55 struct storage_ops {
56         storage_type_e type;
57         const char *(*root) (void);
58         int (*get_state) (void);
59         int (*get_space) (unsigned long long *total, unsigned long long *available);
60         int (*register_cb) (enum storage_cb_type type, struct storage_cb_info *info);
61         int (*unregister_cb) (enum storage_cb_type type, struct storage_cb_info *info);
62         int storage_id;
63 };
64
65 #define STORAGE_OPS_REGISTER(st)        \
66 static void __CONSTRUCTOR__ module_init(void)   \
67 {       \
68         add_device(st); \
69 }       \
70 static void __DESTRUCTOR__ module_exit(void)    \
71 {       \
72         remove_device(st);      \
73 }
74
75 void add_device(const struct storage_ops *st);
76 void remove_device(const struct storage_ops *st);
77
78 #ifdef __cplusplus
79 }
80 #endif
81 #endif