tizen 2.3 release
[framework/system/deviced.git] / src / deviced / dd-mmc.h
1 /*
2  * deviced
3  *
4  * Copyright (c) 2012 - 2013 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 __DD_MMC_H__
21 #define __DD_MMC_H__
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 /**
28  * @file        dd-mmc.h
29  * @defgroup    CAPI_SYSTEM_DEVICED_MMC_MODULE MMC
30  * @ingroup     CAPI_SYSTEM_DEVICED
31  * @brief       This file provides the API for control of mmc(sd-card)
32  * @section CAPI_SYSTEM_DEVICED_MMC_MODULE_HEADER Required Header
33  *   \#include <dd-mmc.h>
34  */
35
36 /**
37  * @addtogroup CAPI_SYSTEM_DEVICED_MMC_MODULE
38  * @{
39  */
40
41 /**
42  * @fn int mmc_secure_mount(const char *mount_point)
43  * @brief This API is used to mount mmc.\n
44  *              [mount fail value] \n
45  *              -1 : operation not permmitted \n
46  *              -22 : Invalid argument \n
47  * @param[in] mount_point pointer to the character buffer containing the path
48  * @return 0 on success, negative value if failed
49  * @par Example
50  * @code
51  *  ...
52  *  if( mmc_secure_mount(mount_point) < 0 )
53  *      printf("Mount mmc failed\n");
54  *  ...
55  * @endcode
56  */
57 int mmc_secure_mount(const char *mount_point);
58
59 /**
60  * @fn int mmc_secure_unmount(const char *mount_point)
61  * @brief This API is used to unmount mmc.\n
62  *              [unmount fail value] \n
63  *              -1 : operation not permmitted \n
64  *              -22 : Invalid argument \n
65  * @param[in] mount_point pointer to the character buffer containing the path
66  * @return 0 on success, negative value if failed
67  * @par Example
68  * @code
69  *  ...
70  *  if( mmc_secure_unmount(mount_point) < 0 )
71  *      printf("Unmount mmc failed\n");
72  *  ...
73  * @endcode
74  */
75 int mmc_secure_unmount(const char *mount_point);
76
77 /**
78  * @brief This structure defines the data for receive result of mmc operations(mount/unmount/format)
79  */
80 struct mmc_contents {
81         void (*mmc_cb) (int result, void* data);/**< user callback function for receive result of mmc operations */
82         void* user_data;/**< input data for callback function's second-param(data) */
83 };
84
85 /**
86  * @fn int deviced_request_mount_mmc(struct mmc_contents *mmc_data)
87  * @brief This API is used to mount mmc.\n
88  *              Internally, this API call predefined action API. That is send a notify message. \n
89  *              and when mount operation is finished, cb of deviced_mmc_content struct is called with cb's param1(result). \n
90  *              means of param1 - 0(mount success) and negative value if failed \n
91  *              [mount fail value] \n
92  *              -1 : operation not permmitted \n
93  *              -2 : no such file or directory \n
94  *              -6 : no such device or address \n
95  *              -12 : out of memory \n
96  *              -13 : A component of a path was not searchable \n
97  *              -14 : bad address \n
98  *              -15 : block device is requested \n
99  *              -16 : device or resource busy \n
100  *              -19 : filesystemtype not configured in the kernel \n
101  *              -20 : target, or a prefix of source, is not a directory \n
102  *              -22 : point does not exist \n
103  *              -24 : table of dummy devices is full \n
104  *              -36 : requested name is too long \n
105  *              -40 : Too many links encountered during pathname resolution. \n
106  *                      Or, a move was attempted, while target is a descendant of source \n
107  * @param[in] mmc_data for receive result of mount operation
108  * @return  non-zero on success message sending, -1 if message sending is failed.
109  */
110 int deviced_request_mount_mmc(struct mmc_contents *mmc_data);
111
112 /**
113  * @fn int deviced_request_unmount_mmc(struct mmc_contents *mmc_data,int option)
114  * @brief This API is used to unmount mmc.\n
115  *              Internally, this API call predefined action API. That is send a notify message. \n
116  *              and when unmount opeation is finished, cb of deviced_mmc_content struct is called with cb's param1(result). \n
117  *              means of param1 - 0(unmount success) and negative value if failed \n
118  *              [unmount fail value] \n
119  *              -1 : operation not permmitted \n
120  *              -2 : no such file or directory \n
121  *              -11 : try again \n
122  *              -12 : out of memory \n
123  *              -14 : bad address \n
124  *              -16 : device or resource busy \n
125  *              -22 : point does not exist \n
126  *              -36 : requested name is too long \n
127  * @param[in] mmc_data for receive result of unmount operation
128  * @param[in] option type of unmount option \n
129  *              0 : Normal unmount \n
130  *                      (if other process still access a sdcard, \n
131  *                       unmount will be failed.) \n
132  *              1 : Force unmount \n
133  *                      (if other process still access a sdcard, \n
134  *                      this process will be received SIGTERM or SIGKILL.)
135  * @return  non-zero on success message sending, -1 if message sending is failed.
136  */
137 int deviced_request_unmount_mmc(struct mmc_contents *mmc_data, int option);
138
139 /**
140  * @fn int deviced_request_format_mmc(struct mmc_contents *mmc_data)
141  * @brief This API is used to format mmc.\n
142  *              Internally, this API call predefined action API. That is send a notify message. \n
143  *              and when format opeation is finished, cb of deviced_mmc_content struct is called with cb's param1(result). \n
144  *              means of param1 - 0(format success) , -1(format fail)
145  * @param[in] mmc_data for receive result of format operation
146  * @return  non-zero on success message sending, -1 if message sending is failed.
147  */
148 int deviced_request_format_mmc(struct mmc_contents *mmc_data);
149
150 /**
151  * @fn int deviced_format_mmc(struct mmc_contents *mmc_data, int option)
152  * @brief This API is used to format mmc.\n
153  *              Internally, this API call predefined action API. That is send a notify message. \n
154  *              and when format opeation is finished, cb of deviced_mmc_content struct is called with cb's param1(result). \n
155  *              means of param1 - 0(format success) and negative value if failed \n
156  *              [format fail value] \n
157  *              -22 : Invalid argument(EINVAL) \n
158  * @param[in] mmc_data for receive result of format operation
159  * @param[in] option FMT_NORMAL is 0, FMT_FORCE is 1
160  * @return  non-zero on success message sending, -1 if message sending is failed.
161  */
162 int deviced_format_mmc(struct mmc_contents *mmc_data, int option);
163
164 /**
165  * @} // end of CAPI_SYSTEM_DEVICED_MMC_MODULE
166  */
167
168 #ifdef __cplusplus
169 }
170 #endif
171 #endif