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