4 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 *******************************************************************************
21 * \file SS_FileSystemUpdate.h
23 * \brief UPI FS Update API
24 *******************************************************************************
26 #ifndef _SS_FILESYSTEM_UPDATE_H_
27 #define _SS_FILESYSTEM_UPDATE_H_
29 #include "SS_Engine_Update.h"
30 #include "SS_Engine_Errors.h"
34 #endif /* __cplusplus */
39 typedef enum tag_RW_TYPE {
40 ONLY_R, //!< Read-only
41 ONLY_W, //!< Write-only
42 BOTH_RW //!< Read-write
46 *******************************************************************************
49 * Must create the path to the new file as required. Must overwrite any contents
50 * in the old file, if any. Must check if the source file is a symbolic link.
51 * If it is, instead create a new symbolic link using \ref SS_Link.
53 * \param pbUserData Optional opaque data-structure to pass to IPL
55 * \param strFromPath Path to old file
56 * \param strToPath Path to new file
58 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
59 *******************************************************************************
62 long SS_CopyFile(void *pbUserData, const char *strFromPath, const char *strToPath);
65 *******************************************************************************
66 * Move (rename) file.<p>
68 * \param pbUserData Optional opaque data-structure to pass to IPL
70 * \param strFromPath Path to old file location
71 * \param strToPath Path to new file location
73 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
74 *******************************************************************************
77 long SS_MoveFile(void *pbUserData, const char *strFromPath, const char *strToPath);
80 *******************************************************************************
83 * Must return success if the file is deleted or didn't exist.
85 * \param pbUserData Optional opaque data-structure to pass to IPL
87 * \param strPath Path to file
89 * \return S_SS_SUCCESS on success, E_SS_DELETEFILE if the file cannot be
90 * deleted, or an \ref SS_vRM_Errors.h error code
91 *******************************************************************************
94 long SS_DeleteFile(void *pbUserData, const char *strPath);
97 *******************************************************************************
100 * Must return success if the folder is now deleted or didn't exist.
102 * \param pbUserData Optional opaque data-structure to pass to IPL
104 * \param strPath Path to folder
106 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
107 *******************************************************************************
110 long SS_DeleteFolder(void *pbUserData, const char *strPath);
113 *******************************************************************************
116 * Must return success if the folder is created or already existsed. It is
117 * recommended that the new folder's attributes are a copy of its parent's
120 * \param pbUserData Optional opaque data-structure to pass to IPL
122 * \param strPath Path to folder
124 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
125 *******************************************************************************
128 long SS_CreateFolder(void *pbUserData, const char *strPath);
131 *******************************************************************************
134 * Must create the the file (and the path to the file) if it doesn't exist. Must
135 * open in binary mode.
137 * \param pbUserData Optional opaque data-structure to pass to IPL
139 * \param strPath Path to file
140 * \param wFlag Read/write mode, an \ref E_RW_TYPE value
141 * \param pwHandle (out) File handle
143 * \return S_SS_SUCCESS on success, E_SS_OPENFILE_ONLYR if attempting to open a
144 * non-existant file in R/O mode, E_SS_OPENFILE_WRITE if there is an
145 * error opening a file for writing, or an \ref SS_vRM_Errors.h error code
146 *******************************************************************************
149 long SS_OpenFile(void *pbUserData, const char *strPath, E_RW_TYPE wFlag, long *pwHandle);
152 *******************************************************************************
155 * \param pbUserData Optional opaque data-structure to pass to IPL
157 * \param wHandle File handle
158 * \param dwSize New file size
160 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
161 *******************************************************************************
164 long SS_ResizeFile(void *pbUserData, long wHandle, SS_UINT32 dwSize);
167 *******************************************************************************
170 * \param pbUserData Optional opaque data-structure to pass to IPL
172 * \param wHandle File handle
174 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
175 *******************************************************************************
178 long SS_CloseFile(void *pbUserData, long wHandle);
181 *******************************************************************************
182 * Write data to a specified position within a file.<p>
184 * Must return success if the block is written or at least resides in
185 * non-volatile memory. Use \ref SS_SyncFile to commit the file to storage.
187 * \param pbUserData Optional opaque data-structure to pass to IPL
189 * \param wHandle File handle
190 * \param dwPosition Position within the file to which to write
191 * \param pbBuffer Data to write
192 * \param dwSize Size of \a pbBuffer
194 * \return S_SS_SUCCESS on success, or an \ref SS_vRM_Errors.h error code
195 *******************************************************************************
198 long SS_WriteFile(void *pbUserData, long wHandle, SS_UINT32 dwPosition, unsigned char *pbBuffer, SS_UINT32 dwSize);
201 *******************************************************************************
202 * Commit file to storage.<p>
204 * Generally called after \ref SS_WriteFile.
206 * \param pbUserData Optional opaque data-structure to pass to IPL
208 * \param wHandle File handle
210 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
211 *******************************************************************************
213 long SS_SyncFile(void *pbUserData, long wHandle);
216 *******************************************************************************
217 * Read data from a specified position within a file.
218 * If fewer bytes than requested are available in the specified position, this
219 * function should read up to the end of file and return S_SS_SUCCESS.
221 * \param pbUserData Optional opaque data-structure to pass to IPL
223 * \param wHandle File handle
224 * \param dwPosition Position within the file from which to read
225 * \param pbBuffer Buffer to contain data
226 * \param dwSize Size of data to read
228 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
229 *******************************************************************************
232 long SS_ReadFile(void *pbUserData, long wHandle, SS_UINT32 dwPosition, unsigned char *pbBuffer, SS_UINT32 dwSize);
235 *******************************************************************************
238 * \param pbUserData Optional opaque data-structure to pass to IPL
240 * \param wHandle File handle
242 * \return File size, -1 if file not found, or < -1 on error
243 *******************************************************************************
245 long SS_GetFileSize(void *pbUserData, long wHandle);
248 *******************************************************************************
249 * Get free space of a mounted file system.
251 * \param pbUserData Optional opaque data-structure to pass to
253 * \param path Name of any directory within the mounted
255 * \param available_flash_size (out) Available space
257 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
258 *******************************************************************************
260 long SS_GetAvailableFreeSpace(void *pbUserData, const char *path, SS_UINT32 * available_flash_size);
263 *******************************************************************************
264 * Remove symbolic link.<p>
266 * Must return an error if the file does not exist or is not a symbolic link.<p>
268 * If your platform does not support symbolic links, you do not need to
271 * \param pbUserData Optional opaque data-structure to pass to IPL
273 * \param pLinkName Link
275 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
276 *******************************************************************************
278 long SS_Unlink(void *pbUserData, char *pLinkName);
281 *******************************************************************************
282 * Create symbolic link.<p>
284 * Must create the path to the link as required. If a file already exists at the
285 * named location, must return success if the file is a symbolic link or an
286 * error if the file is a regular file. The non-existance of the target of the
287 * link must NOT cause an error.<p>
289 * If your platform does not support symbolic links, you do not need to
292 * \param pbUserData Optional opaque data-structure to pass to IPL
294 * \param pLinkName Path to the link file to create
295 * \param pReferenceFileName Path to which to point the link
297 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
298 *******************************************************************************
300 long SS_Link(void *pbUserData, char *pLinkName, char *pReferenceFileName);
303 *******************************************************************************
304 * Set file attributes.<p>
306 * The file attributes token (\a ui8pAttribs) is defined at generation time.
307 * If attributes are not defined explicitly, they are given the following,
308 * OS-dependent values:
309 * \li Windows: _redbend_ro_ for R/O files, _redbend_rw_ for R/W files
310 * \li Linux: _redbend_oooooo:xxxx:yyyy indicating the file mode, uid, and gid
311 * (uid and gid use capitalized hex digits as required)
313 * \param pbUserData Optional opaque data-structure to pass to IPL
315 * \param ui16pFilePath File path
316 * \param ui32AttribSize Size of \a ui8pAttribs
317 * \param ui8pAttribs Attributes to set
319 * \return S_SS_SUCCESS on success or < 0 on error
320 *******************************************************************************
323 long SS_SetFileAttributes(const char *ui16pFilePath,
324 const SS_UINT32 ui32AttribSize, const unsigned char *ui8pAttribs);
327 *******************************************************************************
328 * Print status and debug information.
330 * \param pbUserData Optional opaque data-structure to pass to IPL
332 * \param aFormat A NULL-terminated printf-like string with support for
333 * the following tags:
335 * \li %0x: Hex number with leading zeros
336 * \li %u: Unsigned decimal
337 * \li %s: NULL-terminated string
338 * \param ... Strings to insert in \a aFormat
340 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
341 *******************************************************************************
343 SS_UINT32 SS_Trace(void *pbUserData, const char *aFormat, ...
348 #endif /* __cplusplus */