4 * Copyright (c) 2017 - 2022 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_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
45 *******************************************************************************
48 * Must create the path to the new file as required. Must overwrite any contents
49 * in the old file, if any. Must check if the source file is a symbolic link.
50 * If it is, instead create a new symbolic link using \ref SS_Link.
52 * \param strFromPath Path to old file
53 * \param strToPath Path to new file
55 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
56 *******************************************************************************
59 long SS_CopyFile(const char *strFromPath, const char *strToPath);
62 *******************************************************************************
63 * Move (rename) file.<p>
65 * \param strFromPath Path to old file location
66 * \param strToPath Path to new file location
68 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
69 *******************************************************************************
72 long SS_MoveFile(const char *strFromPath, const char *strToPath);
75 *******************************************************************************
78 * Must return success if the file is deleted or didn't exist.
80 * \param strPath Path to file
82 * \return S_SS_SUCCESS on success, E_SS_DELETEFILE if the file cannot be
83 * deleted, or an \ref SS_vRM_Errors.h error code
84 *******************************************************************************
87 long SS_DeleteFile(const char *strPath);
90 *******************************************************************************
93 * Must return success if the folder is now deleted or didn't exist.
95 * \param strPath Path to folder
97 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
98 *******************************************************************************
101 long SS_DeleteFolder(const char *strPath);
104 *******************************************************************************
107 * Must return success if the folder is created or already existsed. It is
108 * recommended that the new folder's attributes are a copy of its parent's
111 * \param strPath Path to folder
113 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
114 *******************************************************************************
117 long SS_CreateFolder(const char *strPath);
120 *******************************************************************************
123 * Must create the the file (and the path to the file) if it doesn't exist. Must
124 * open in binary mode.
126 * \param strPath Path to file
127 * \param wFlag Read/write mode, an \ref E_RW_TYPE value
128 * \param pwHandle (out) File handle
130 * \return S_SS_SUCCESS on success, E_SS_OPENFILE_ONLYR if attempting to open a
131 * non-existant file in R/O mode, E_SS_OPENFILE_WRITE if there is an
132 * error opening a file for writing, or an \ref SS_vRM_Errors.h error code
133 *******************************************************************************
136 long SS_OpenFile(const char *strPath, E_RW_TYPE wFlag, long *pwHandle);
139 *******************************************************************************
142 * \param wHandle File handle
144 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
145 *******************************************************************************
148 long SS_CloseFile(long wHandle);
151 *******************************************************************************
152 * Write data to a specified position within a file.<p>
154 * Must return success if the block is written or at least resides in
155 * non-volatile memory. Use \ref SS_SyncFile to commit the file to storage.
157 * \param wHandle File handle
158 * \param dwPosition Position within the file to which to write
159 * \param pbBuffer Data to write
160 * \param dwSize Size of \a pbBuffer
162 * \return S_SS_SUCCESS on success, or an \ref SS_vRM_Errors.h error code
163 *******************************************************************************
166 long SS_WriteFile(long wHandle, SS_UINT32 dwPosition, unsigned char *pbBuffer, SS_UINT32 dwSize);
169 *******************************************************************************
170 * Read data from a specified position within a file.
171 * If fewer bytes than requested are available in the specified position, this
172 * function should read up to the end of file and return S_SS_SUCCESS.
174 * \param wHandle File handle
175 * \param dwPosition Position within the file from which to read
176 * \param pbBuffer Buffer to contain data
177 * \param dwSize Size of data to read
179 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
180 *******************************************************************************
183 long SS_ReadFile(long wHandle, SS_UINT32 dwPosition, unsigned char *pbBuffer, SS_UINT32 dwSize);
186 *******************************************************************************
189 * \param wHandle File handle
191 * \return File size, -1 if file not found, or < -1 on error
192 *******************************************************************************
194 long SS_GetFileSize(long wHandle);
197 *******************************************************************************
198 * Get free space of a mounted file system.
200 * \param path Name of any directory within the mounted
202 * \param available_flash_size (out) Available space
204 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
205 *******************************************************************************
207 long SS_GetAvailableFreeSpace(const char *path, SS_UINT32 * available_flash_size);
210 *******************************************************************************
211 * Remove symbolic link.<p>
213 * Must return an error if the file does not exist or is not a symbolic link.<p>
215 * If your platform does not support symbolic links, you do not need to
218 * \param pLinkName Link
220 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
221 *******************************************************************************
223 long SS_Unlink(char *pLinkName);
226 *******************************************************************************
227 * Create symbolic link.<p>
229 * Must create the path to the link as required. If a file already exists at the
230 * named location, must return success if the file is a symbolic link or an
231 * error if the file is a regular file. The non-existance of the target of the
232 * link must NOT cause an error.<p>
234 * If your platform does not support symbolic links, you do not need to
237 * \param pbUserData Optional opaque data-structure to pass to IPL
239 * \param pLinkName Path to the link file to create
240 * \param pReferenceFileName Path to which to point the link
242 * \return S_SS_SUCCESS on success or an \ref SS_vRM_Errors.h error code
243 *******************************************************************************
245 long SS_Link(void *pbUserData, char *pLinkName, char *pReferenceFileName);
248 *******************************************************************************
249 * Set file attributes.<p>
251 * The file attributes token (\a ui8pAttribs) is defined at generation time.
252 * If attributes are not defined explicitly, they are given the following,
253 * OS-dependent values:
254 * \li Windows: _foo_ro_ for R/O files, _foo_rw_ for R/W files
255 * \li Linux: _foo_oooooo:xxxx:yyyy indicating the file mode, uid, and gid
256 * (uid and gid use capitalized hex digits as required)
258 * \param pbUserData Optional opaque data-structure to pass to IPL
260 * \param ui16pFilePath File path
261 * \param ui32AttribSize Size of \a ui8pAttribs
262 * \param ui8pAttribs Attributes to set
264 * \return S_SS_SUCCESS on success or < 0 on error
265 *******************************************************************************
268 long SS_SetFileAttributes(const char *ui16pFilePath,
269 const SS_UINT32 ui32AttribSize, const unsigned char *ui8pAttribs);
272 *******************************************************************************
273 * Allocate a memory block.
275 * \param size Memory block size, in blocks
277 * \return A pointer to the memory block on success, NULL on failure
278 *******************************************************************************
280 void *SS_Malloc(SS_UINT32 size);
283 *******************************************************************************
284 * Free a memory block.
286 * \param pMemBlock Pointer to the memory block
287 *******************************************************************************
289 void SS_Free(void *pMemBlock);
291 *******************************************************************************
292 * Get capability feature flag value
294 * \return The value of feature_support_capability
295 *******************************************************************************
297 int SS_get_feature_support_capability(void);
300 *******************************************************************************
301 * Set capability feature flag
303 * \param val The value to set feature_support_capability
304 *******************************************************************************
306 void SS_set_feature_support_capability(int val);
309 *******************************************************************************
310 * Create a hardlink to a file
312 * \param hardLinkName Name of the hardlink to be created
313 * \param referenceName Name of the file that we link to
315 * \return S_SS_SUCCESS on success, E_SS_FAILURE otherwise
316 *******************************************************************************
319 long SS_HardLink(char *hardLinkName, char *referenceName);
323 #endif /* __cplusplus */