1 #ifndef PERSISTENCE_CLIENT_LIBRARY_BACKUP_FILELIST_H
2 #define PERSISTENCE_CLIENT_LIBRARY_BACKUP_FILELIST_H
4 /******************************************************************************
7 * Company XS Embedded GmbH
8 *****************************************************************************/
9 /******************************************************************************
10 * This Source Code Form is subject to the terms of the
11 * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
12 * with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
13 ******************************************************************************/
15 * @file persistence_client_library_backup_filelist.h
16 * @ingroup Persistence client library
17 * @author Ingo Huerner
18 * @brief Header of the persistence client library backup file list
23 //#include "../include_protected/persistence_client_library_rc_table.h"
24 #include <persComRct.h>
28 * @brief Read the blacklist configuration file
30 * @param filename the filename and path to the configuration fiel
32 * @return 1 success, 0 error
34 int readBlacklistConfigFile(const char* filename);
38 * @brief create the file
40 * @param path of the file to be created
42 * @return the handle to his file
44 int pclCreateFile(const char* path);
48 * @brief create a backup copy of a file
50 * @param srcPath the path of the file
51 * @param srcfd the file descriptor of the file
52 * @param csumpath the path where to checksum will be stored
53 * @param csumBuf the checksum string
55 * @return -1 on error or a positive value indicating number of bytes of the backup file created
57 int pclCreateBackup(const char* srcPath, int srcfd, const char* csumPath, const char* csumBuf);
61 * @brief recover file form backup
63 * @param backupfd the file descriptor of the backup file
64 * @param original the path of the file to be recovered
66 * @return 0 on success -1 on error
68 int pclRecoverFromBackup(int backupFd, const char* original);
72 * @brief calculate crc32 checksum
74 * @param fd the file descriptor to create the checksum from
75 * @param crc32sum the array to store the checksum
77 * @return -1 on error or 1 if succeeded
79 int pclCalcCrc32Csum(int fd, char crc32sum[]);
83 * @brief verify file for consistency
85 * @param origPath the path of the file to verify
86 * @param backupPath the path of the backup file
87 * @param csumPath the path to the checksum file
88 * @param openFlag the file open flags
90 * @return -1 if the file could not be recovered or a positive value (>=0) on successful recovery
92 int pclVerifyConsistency(const char* origPath, const char* backupPath, const char* csumPath, int openFlags);
96 * @brief check if file needs a backup
98 * @param path the path of the file
100 * @return 1 if a backup will shall be created,
101 * 0 if a backup shall be not created or -1 for an error
103 inline int pclBackupNeeded(const char* path);
107 * @brief translate persistence permission into POSIX file open permissions
109 * @param permission the permission enumerator ::PersistencePermission_e
111 * @return the POSIX file permission will be returned of -1 in an error case.
112 * If an unknown PersistencePermission_e will be detected the
113 * default permission O_RDONLY will be returned
115 int pclGetPosixPermission(PersistencePermission_e permission);
118 #endif /* PERS_BACKUP_BLACKLIST_H */