4c105b75767c68539f444b2163804aa80a57a1a0
[profile/ivi/persistence-client-library.git] / src / persistence_client_library_backup_filelist.h
1 #ifndef PERSISTENCE_CLIENT_LIBRARY_BACKUP_FILELIST_H
2 #define PERSISTENCE_CLIENT_LIBRARY_BACKUP_FILELIST_H
3
4 /******************************************************************************
5  * Project         Persistency
6  * (c) copyright   2013
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 ******************************************************************************/
14  /**
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
19  * @see
20  */
21
22
23 //#include "../include_protected/persistence_client_library_rc_table.h"
24 #include <persComRct.h>
25
26
27 /**
28  * @brief Read the blacklist configuration file
29  *
30  * @param filename the filename and path to the configuration fiel
31  *
32  * @return 1 success, 0 error
33  */
34 int readBlacklistConfigFile(const char* filename);
35
36
37 /**
38  * @brief create the file
39  *
40  * @param path of the file to be created
41  *
42  * @return the handle to his file
43  */
44 int pclCreateFile(const char* path);
45
46
47 /**
48  * @brief create a backup copy of a file
49  *
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
54  *
55  * @return -1 on error or a positive value indicating number of bytes of the backup file created
56  */
57 int pclCreateBackup(const char* srcPath, int srcfd, const char* csumPath, const char* csumBuf);
58
59
60 /**
61  * @brief recover file form backup
62  *
63  * @param backupfd the file descriptor of the backup file
64  * @param original the path of the file to be recovered
65  *
66  * @return 0 on success -1 on error
67  */
68 int pclRecoverFromBackup(int backupFd, const char* original);
69
70
71 /**
72  * @brief calculate crc32 checksum
73  *
74  * @param fd the file descriptor to create the checksum from
75  * @param crc32sum the array to store the checksum
76  *
77  * @return -1 on error or 1 if succeeded
78  */
79 int pclCalcCrc32Csum(int fd, char crc32sum[]);
80
81
82 /**
83  * @brief verify file for consistency
84  *
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
89  *
90  * @return
91  */
92 int pclVerifyConsistency(const char* origPath, const char* backupPath, const char* csumPath, int openFlags);
93
94
95 /**
96  * @brief check if file needs a backup
97  *
98  * @param path the path of the file
99  *
100  * @return 1 if a backup will shall be created,
101  *         0 if a backup shall be not created or -1 for an error
102  */
103 inline int pclBackupNeeded(const char* path);
104
105
106 /**
107  * @brief translate persistence permission into POSIX file open permissions
108  *
109  * @param permission the permission enumerator ::PersistencePermission_e
110  *
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
114  */
115 int pclGetPosixPermission(PersistencePermission_e permission);
116
117
118 #endif /* PERS_BACKUP_BLACKLIST_H */