Check parameter and return error
[platform/core/system/libstorage.git] / include / storage-internal.h
index 53795d2..a7ac3f8 100644 (file)
@@ -49,7 +49,9 @@ extern "C" {
  *
  * @retval #STORAGE_ERROR_NONE               Successful
  * @retval #STORAGE_ERROR_INVALID_PARAMETER  Invalid parameter
- * @retval #STORAGE_ERROR_NO_DEVICE          No such device
+ * @retval #STORAGE_ERROR_NOT_SUPPORTED      Storage not supported
+ * @retval #STORAGE_ERROR_OPERATION_FAILED   Operation failed
+ * @retval #STORAGE_ERROR_OUT_OF_MEMORY      Out of memory
  */
 int storage_get_primary_sdcard(int *storage_id, char **path);
 
@@ -58,6 +60,108 @@ int storage_get_origin_internal_path(const char* compat, int len, char* origin);
 int storage_get_storage_level(const char *path, char **level);
 
 /**
+ * @brief This structure defines the data for receive result of mmc operations(mount/unmount/format)
+ */
+struct mmc_contents {
+       void (*mmc_cb) (int result, void* data); /**< user callback function for receive result of mmc operations */
+       void* user_data; /**< input data for callback function's second-param(data) */
+};
+
+/**
+ * @brief This API is used to mount mmc.\n
+ *
+ * @param[in] mmc_data for receive result of mount operation
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #STORAGE_ERROR_NONE               Successful
+ * @retval #STORAGE_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #STORAGE_ERROR_NO_DEVICE          No such device
+ * @retval #STORAGE_ERROR_OPERATION_FAILED   Operation failed
+ * @retval #STORAGE_ERROR_OUT_OF_MEMORY      Out of memory
+ */
+int storage_request_mount_mmc(struct mmc_contents *mmc_data);
+
+/**
+ * @brief This API is used to unmount mmc.\n
+ *
+ * @param[in] mmc_data for receive result of unmount operation
+ * @param[in] option type of unmount option \n
+ *             0 : Normal unmount \n
+ *                     (if other process still access a sdcard, \n
+ *                      unmount will be failed.) \n
+ *             1 : Force unmount \n
+ *                     (if other process still access a sdcard, \n
+ *                     this process will be received SIGTERM or SIGKILL.)
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #STORAGE_ERROR_NONE               Successful
+ * @retval #STORAGE_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #STORAGE_ERROR_NO_DEVICE          No such device
+ * @retval #STORAGE_ERROR_OPERATION_FAILED   Operation failed
+ * @retval #STORAGE_ERROR_OUT_OF_MEMORY      Out of memory
+ */
+int storage_request_unmount_mmc(struct mmc_contents *mmc_data, int option);
+
+/**
+ * @brief This API is used to format mmc.\n
+ *
+ * @param[in] mmc_data for receive result of format operation
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #STORAGE_ERROR_NONE               Successful
+ * @retval #STORAGE_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #STORAGE_ERROR_NO_DEVICE          No such device
+ * @retval #STORAGE_ERROR_OPERATION_FAILED   Operation failed
+ * @retval #STORAGE_ERROR_OUT_OF_MEMORY      Out of memory
+ */
+int storage_request_format_mmc(struct mmc_contents *mmc_data);
+
+/**
+ * @brief This API is used to format mmc.\n
+ *
+ * @param[in] mmc_data for receive result of format operation
+ * @param[in] option FMT_NORMAL is 0, FMT_FORCE is 1
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #STORAGE_ERROR_NONE               Successful
+ * @retval #STORAGE_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #STORAGE_ERROR_NO_DEVICE          No such device
+ * @retval #STORAGE_ERROR_OPERATION_FAILED   Operation failed
+ * @retval #STORAGE_ERROR_OUT_OF_MEMORY      Out of memory
+ */
+int storage_format_mmc(struct mmc_contents *mmc_data, int option);
+
+typedef enum {
+       STORAGE_PART_ERROR = -1, /**< Checking partition is failed */
+       STORAGE_PART_NOT_MOUNTED = 0, /**< Partition is not mounted */
+       STORAGE_PART_MOUNTED = 1, /**< Partition is mounted */
+       STORAGE_PART_NOT_SUPPORTED = 2, /**< Partition is not supported */
+} storage_part_mount_e;
+
+/**
+ * @brief This API is used to check user data partition is mounted.\n
+ *
+ * @param[out] mounted 1 when user partition is mounted, 0 when user partition is not mounted, 2 when user partition is not supported(2 partitions), and Less then 0 when error return.
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #STORAGE_ERROR_NONE               Successful
+ * @retval #STORAGE_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #STORAGE_ERROR_OPERATION_FAILED   Operation failed
+ * @retval #STORAGE_ERROR_OUT_OF_MEMORY      Out of memory
+ */
+int storage_is_mounted_opt_usr(storage_part_mount_e *mounted);
+
+/**
  * @}
  */