5548d8461282df98abfaab1945abf1a3087119f9
[platform/core/system/libstorage.git] / include / storage-internal.h
1 /*
2  * storage
3  * Copyright (c) 2016 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 __STORAGE_INTERNAL_H__
20 #define __STORAGE_INTERNAL_H__
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26
27 /**
28  * @addtogroup CAPI_SYSTEM_STORAGE_MODULE
29  * @{
30  */
31
32 #include <tizen.h>
33 #include "storage.h"
34
35 #define STORAGE_ERROR_NO_DEVICE TIZEN_ERROR_NO_SUCH_DEVICE
36
37 /**
38  * @brief Get the mount path for the primary partition of sdcard.
39  *
40  * @since_tizen 3.0
41  *
42  * @remarks You must release the path using free() after use
43  *
44  * @param[out] storage_id The storage id
45  * @param[out] path The mount path of sdcard primary partition.
46  *
47  * @return @c 0 on success,
48  *         otherwise a negative error value
49  *
50  * @retval #STORAGE_ERROR_NONE               Successful
51  * @retval #STORAGE_ERROR_INVALID_PARAMETER  Invalid parameter
52  * @retval #STORAGE_ERROR_NO_DEVICE          No such device
53  * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
54  * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory
55  */
56 int storage_get_primary_sdcard(int *storage_id, char **path);
57
58 int storage_get_compat_internal_path(const char* origin, int len, char* compat);
59 int storage_get_origin_internal_path(const char* compat, int len, char* origin);
60 int storage_get_storage_level(const char *path, char **level);
61
62 /**
63  * @brief This structure defines the data for receive result of mmc operations(mount/unmount/format)
64  */
65 struct mmc_contents {
66         void (*mmc_cb) (int result, void* data); /**< user callback function for receive result of mmc operations */
67         void* user_data; /**< input data for callback function's second-param(data) */
68 };
69
70 /**
71  * @brief This API is used to mount mmc.\n
72  *
73  * @param[in] mmc_data for receive result of mount operation
74  *
75  * @return @c 0 on success,
76  *         otherwise a negative error value
77  *
78  * @retval #STORAGE_ERROR_NONE               Successful
79  * @retval #STORAGE_ERROR_INVALID_PARAMETER  Invalid parameter
80  * @retval #STORAGE_ERROR_NO_DEVICE          No such device
81  * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
82  * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory
83  */
84 int storage_request_mount_mmc(struct mmc_contents *mmc_data);
85
86 /**
87  * @brief This API is used to unmount mmc.\n
88  *
89  * @param[in] mmc_data for receive result of unmount operation
90  * @param[in] option type of unmount option \n
91  *              0 : Normal unmount \n
92  *                      (if other process still access a sdcard, \n
93  *                       unmount will be failed.) \n
94  *              1 : Force unmount \n
95  *                      (if other process still access a sdcard, \n
96  *                      this process will be received SIGTERM or SIGKILL.)
97  *
98  * @return @c 0 on success,
99  *         otherwise a negative error value
100  *
101  * @retval #STORAGE_ERROR_NONE               Successful
102  * @retval #STORAGE_ERROR_INVALID_PARAMETER  Invalid parameter
103  * @retval #STORAGE_ERROR_NO_DEVICE          No such device
104  * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
105  * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory
106  */
107 int storage_request_unmount_mmc(struct mmc_contents *mmc_data, int option);
108
109 /**
110  * @brief This API is used to format mmc.\n
111  *
112  * @param[in] mmc_data for receive result of format operation
113  *
114  * @return @c 0 on success,
115  *         otherwise a negative error value
116  *
117  * @retval #STORAGE_ERROR_NONE               Successful
118  * @retval #STORAGE_ERROR_INVALID_PARAMETER  Invalid parameter
119  * @retval #STORAGE_ERROR_NO_DEVICE          No such device
120  * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
121  * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory
122  */
123 int storage_request_format_mmc(struct mmc_contents *mmc_data);
124
125 /**
126  * @brief This API is used to format mmc.\n
127  *
128  * @param[in] mmc_data for receive result of format operation
129  * @param[in] option FMT_NORMAL is 0, FMT_FORCE is 1
130  *
131  * @return @c 0 on success,
132  *         otherwise a negative error value
133  *
134  * @retval #STORAGE_ERROR_NONE               Successful
135  * @retval #STORAGE_ERROR_INVALID_PARAMETER  Invalid parameter
136  * @retval #STORAGE_ERROR_NO_DEVICE          No such device
137  * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
138  * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory
139  */
140 int storage_format_mmc(struct mmc_contents *mmc_data, int option);
141
142 /**
143  * @brief This API is used to format mmc.\n
144  *
145  * @param[in] path for checking mounted
146  * @param[out] mounted True when path is mounted
147  *
148  * @return @c 0 on success,
149  *         otherwise a negative error value
150  *
151  * @retval #STORAGE_ERROR_NONE               Successful
152  */
153 int storage_is_mounted(char *path, bool *mounted);
154
155 /**
156  * @}
157  */
158
159 #ifdef __cplusplus
160 }
161 #endif
162 #endif /* __STORAGE_INTERNAL_H__ */