Apply requirement for gcov automation
[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 #include <sys/statvfs.h>
28
29 #ifndef API
30 #define API __attribute__ ((visibility("default")))
31 #endif
32
33 #ifndef __WEAK__
34 #define __WEAK__ __attribute__ ((weak))
35 #endif
36
37 #ifndef __CONSTRUCTOR__
38 #define __CONSTRUCTOR__ __attribute__ ((constructor))
39 #endif
40
41 #ifndef __DESTRUCTOR__
42 #define __DESTRUCTOR__ __attribute__ ((destructor))
43 #endif
44
45 enum storage_cb_type {
46         STORAGE_CALLBACK_ID,
47         STORAGE_CALLBACK_TYPE,
48         STORAGE_CALLBACK_MAX,
49 };
50
51 struct storage_cb_info {
52         int id;
53         storage_type_e type;
54         storage_state_changed_cb state_cb;
55         storage_changed_cb type_cb;
56         void *user_data;
57 };
58
59 struct storage_ops {
60         storage_type_e type;
61         const char *(*root) (void);
62         int (*get_state) (void);
63         int (*get_space) (unsigned long long *total, unsigned long long *available);
64         int (*register_cb) (enum storage_cb_type type, struct storage_cb_info *info);
65         int (*unregister_cb) (enum storage_cb_type type, struct storage_cb_info *info);
66         int storage_id;
67 };
68
69 #define STORAGE_OPS_REGISTER(st)        \
70 static void __CONSTRUCTOR__ module_init(void)   \
71 {       \
72         add_device(st); \
73 }       \
74 static void __DESTRUCTOR__ module_exit(void)    \
75 {       \
76         remove_device(st);      \
77 }
78
79 void add_device(const struct storage_ops *st);
80 void remove_device(const struct storage_ops *st);
81
82 int storage_get_external_memory_size_with_path(char *path, struct statvfs *buf);
83 int storage_get_external_memory_size64_with_path(char *path, struct statvfs *buf);
84
85 #define COMPAT_DIR "/opt/usr/media"
86 int is_compat_bind_mount(void);
87 int storage_ext_is_supported(void);
88 int mount_check(const char *path);
89
90 #define USER_UID_START          5000
91
92 #ifdef __cplusplus
93 }
94 #endif
95 #endif