diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/persistence_client_library.c | 6 | ||||
-rw-r--r-- | src/persistence_client_library_backup_filelist.c | 11 | ||||
-rw-r--r-- | src/persistence_client_library_backup_filelist.h | 50 | ||||
-rw-r--r-- | src/persistence_client_library_db_access.c | 2 | ||||
-rw-r--r-- | src/persistence_client_library_db_access.h | 2 | ||||
-rw-r--r-- | src/persistence_client_library_dbus_cmd.c | 3 | ||||
-rw-r--r-- | src/persistence_client_library_key.c | 34 | ||||
-rw-r--r-- | src/persistence_client_library_pas_interface.c | 7 | ||||
-rw-r--r-- | src/persistence_client_library_pas_interface.h | 3 |
9 files changed, 71 insertions, 47 deletions
diff --git a/src/persistence_client_library.c b/src/persistence_client_library.c index 0d0612a..f2226c9 100644 --- a/src/persistence_client_library.c +++ b/src/persistence_client_library.c @@ -115,7 +115,7 @@ int pclInitLibrary(const char* appName, int shutdownMode) } else { - DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclInitLibrary => Successfully established IPC protocol for PCL.")); + DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("pclInitLibrary => Successfully established IPC protocol for PCL.")); } #else DLT_LOG(gPclDLTContext, DLT_LOG_WARN, DLT_STRING("PAS interface is not enabled, enable with \"./configure --enable-pasinterface\"")); @@ -209,11 +209,11 @@ int pclDeinitLibrary(void) rval = unregister_pers_admin_service(); if(0 != rval) { - DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclDeinitLibrary => Failed to de-initialize IPC protocol for PCL.")); + DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("pclDeinitLibrary => Failed to de-initialize IPC protocol for PCL.")); } else { - DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclDeinitLibrary => Successfully de-initialized IPC protocol for PCL.")); + DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("pclDeinitLibrary => Successfully de-initialized IPC protocol for PCL.")); } #endif diff --git a/src/persistence_client_library_backup_filelist.c b/src/persistence_client_library_backup_filelist.c index 9f6e768..79188ee 100644 --- a/src/persistence_client_library_backup_filelist.c +++ b/src/persistence_client_library_backup_filelist.c @@ -77,6 +77,11 @@ unsigned int gConfigFileSize = 0; /// the rb tree static jsw_rbtree_t *gRb_tree_bl = NULL; + +// local function prototypes +int need_backup_key(unsigned int key); + + void fillCharTokenArray() { unsigned int i=0; @@ -679,6 +684,10 @@ int pclCalcCrc32Csum(int fd, char crc32sum[]) free(buf); } + else + { + rval = -1; + } } return rval; } @@ -694,7 +703,7 @@ int pclBackupNeeded(const char* path) int pclGetPosixPermission(PersistencePermission_e permission) { - int posixPerm = 0; + int posixPerm = -1; switch( (int)permission) { diff --git a/src/persistence_client_library_backup_filelist.h b/src/persistence_client_library_backup_filelist.h index 1350bbf..4c105b7 100644 --- a/src/persistence_client_library_backup_filelist.h +++ b/src/persistence_client_library_backup_filelist.h @@ -23,6 +23,7 @@ //#include "../include_protected/persistence_client_library_rc_table.h" #include <persComRct.h> + /** * @brief Read the blacklist configuration file * @@ -34,19 +35,9 @@ int readBlacklistConfigFile(const char* filename); /** - * @brief - * - * @param - * - * @return - */ -int need_backup_key(unsigned int key); - - -/** * @brief create the file * - * @param + * @param path of the file to be created * * @return the handle to his file */ @@ -54,11 +45,14 @@ int pclCreateFile(const char* path); /** - * @brief create a backup of a file + * @brief create a backup copy of a file * - * @param + * @param srcPath the path of the file + * @param srcfd the file descriptor of the file + * @param csumpath the path where to checksum will be stored + * @param csumBuf the checksum string * - * @return + * @return -1 on error or a positive value indicating number of bytes of the backup file created */ int pclCreateBackup(const char* srcPath, int srcfd, const char* csumPath, const char* csumBuf); @@ -66,9 +60,10 @@ int pclCreateBackup(const char* srcPath, int srcfd, const char* csumPath, const /** * @brief recover file form backup * - * @param + * @param backupfd the file descriptor of the backup file + * @param original the path of the file to be recovered * - * @return + * @return 0 on success -1 on error */ int pclRecoverFromBackup(int backupFd, const char* original); @@ -76,9 +71,10 @@ int pclRecoverFromBackup(int backupFd, const char* original); /** * @brief calculate crc32 checksum * - * @param + * @param fd the file descriptor to create the checksum from + * @param crc32sum the array to store the checksum * - * @return + * @return -1 on error or 1 if succeeded */ int pclCalcCrc32Csum(int fd, char crc32sum[]); @@ -86,7 +82,10 @@ int pclCalcCrc32Csum(int fd, char crc32sum[]); /** * @brief verify file for consistency * - * @param + * @param origPath the path of the file to verify + * @param backupPath the path of the backup file + * @param csumPath the path to the checksum file + * @param openFlag the file open flags * * @return */ @@ -94,11 +93,12 @@ int pclVerifyConsistency(const char* origPath, const char* backupPath, const cha /** - * @brief check if file needs to be backuped + * @brief check if file needs a backup * - * @param + * @param path the path of the file * - * @return + * @return 1 if a backup will shall be created, + * 0 if a backup shall be not created or -1 for an error */ inline int pclBackupNeeded(const char* path); @@ -106,9 +106,11 @@ inline int pclBackupNeeded(const char* path); /** * @brief translate persistence permission into POSIX file open permissions * - * @param + * @param permission the permission enumerator ::PersistencePermission_e * - * @return + * @return the POSIX file permission will be returned of -1 in an error case. + * If an unknown PersistencePermission_e will be detected the + * default permission O_RDONLY will be returned */ int pclGetPosixPermission(PersistencePermission_e permission); diff --git a/src/persistence_client_library_db_access.c b/src/persistence_client_library_db_access.c index e4d634c..2c0bf03 100644 --- a/src/persistence_client_library_db_access.c +++ b/src/persistence_client_library_db_access.c @@ -546,7 +546,7 @@ int persistence_delete_data(char* dbPath, char* key, PersistenceInfo_s* info) } -int persistence_notify_on_change(char* key, unsigned int ldbid, unsigned int user_no, unsigned int seat_no, +int persistence_notify_on_change(const char* key, unsigned int ldbid, unsigned int user_no, unsigned int seat_no, pclChangeNotifyCallback_t callback, PersNotifyRegPolicy_e regPolicy) { int rval = 0; diff --git a/src/persistence_client_library_db_access.h b/src/persistence_client_library_db_access.h index e7185d0..3418e92 100644 --- a/src/persistence_client_library_db_access.h +++ b/src/persistence_client_library_db_access.h @@ -164,7 +164,7 @@ void database_close_all(); * * @return 0 of registration was successfull; -1 if registration failes */ -int persistence_notify_on_change(char* key, unsigned int ldbid, unsigned int user_no, unsigned int seat_no, +int persistence_notify_on_change(const char* key, unsigned int ldbid, unsigned int user_no, unsigned int seat_no, pclChangeNotifyCallback_t callback, PersNotifyRegPolicy_e regPolicy); diff --git a/src/persistence_client_library_dbus_cmd.c b/src/persistence_client_library_dbus_cmd.c index 296f8d9..9c07dd1 100644 --- a/src/persistence_client_library_dbus_cmd.c +++ b/src/persistence_client_library_dbus_cmd.c @@ -163,9 +163,6 @@ void process_block_and_write_data_back(unsigned int requestID, unsigned int stat // lock persistence data access pers_lock_access(); // sync data back to memory device - pers_data_sync(); - // send complete notification - //pers_admin_service_data_sync_complete(requestID, status); } diff --git a/src/persistence_client_library_key.c b/src/persistence_client_library_key.c index 9c1cbf8..daf8f8a 100644 --- a/src/persistence_client_library_key.c +++ b/src/persistence_client_library_key.c @@ -192,7 +192,19 @@ int pclKeyHandleReadData(int key_handle, unsigned char* buffer, int buffer_size) int pclKeyHandleRegisterNotifyOnChange(int key_handle, pclChangeNotifyCallback_t callback) { - return handleRegNotifyOnChange(key_handle, callback, Notify_register); + int rval = EPERS_COMMON; + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyHandleRegisterNotifyOnChange: "), + // DLT_INT(gKeyHandleArray[key_handle].info.context.ldbid), DLT_STRING(gKeyHandleArray[key_handle].resourceID) ); + if((gChangeNotifyCallback == callback) || (gChangeNotifyCallback == NULL)) + { + rval = handleRegNotifyOnChange(key_handle, callback, Notify_register); + } + else + { + DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyHandleRegisterNotifyOnChange: Only one callback is allowed for change notifications.")); + rval = EPERS_NOTIFY_NOT_ALLOWED; + } + return rval; } int pclKeyHandleUnRegisterNotifyOnChange(int key_handle, pclChangeNotifyCallback_t callback) @@ -485,7 +497,19 @@ int pclKeyUnRegisterNotifyOnChange( unsigned int ldbid, const char * resource_ int pclKeyRegisterNotifyOnChange(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no, pclChangeNotifyCallback_t callback) { - return regNotifyOnChange(ldbid, resource_id, user_no, seat_no, callback, Notify_register); + int rval = EPERS_COMMON; + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyRegisterNotifyOnChange: "), + // DLT_INT(ldbid), DLT_STRING(resource_id) ); + if((gChangeNotifyCallback == callback) || (gChangeNotifyCallback == NULL)) + { + rval = regNotifyOnChange(ldbid, resource_id, user_no, seat_no, callback, Notify_register); + } + else + { + DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyRegisterNotifyOnChange: Only one callback is allowed for change notifications.")); + rval = EPERS_NOTIFY_NOT_ALLOWED; + } + return rval; } @@ -516,13 +540,15 @@ int regNotifyOnChange(unsigned int ldbid, const char* resource_id, unsigned int if( (dbContext.configKey.storage != PersistenceStorage_local) && (dbContext.configKey.type == PersistenceResourceType_key) ) { - rval = persistence_notify_on_change(dbKey, ldbid, user_no, seat_no, callback, regPolicy); + rval = persistence_notify_on_change(resource_id, ldbid, user_no, seat_no, callback, regPolicy); } else { DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("regNotifyOnChange: Not allowed! Resource is local or it is a file:"), - DLT_STRING(resource_id)); + DLT_STRING(resource_id), + DLT_STRING("LDBID:"), + DLT_UINT(ldbid)); rval = EPERS_NOTIFY_NOT_ALLOWED; } } diff --git a/src/persistence_client_library_pas_interface.c b/src/persistence_client_library_pas_interface.c index 3e60228..820ff64 100644 --- a/src/persistence_client_library_pas_interface.c +++ b/src/persistence_client_library_pas_interface.c @@ -30,13 +30,6 @@ static int gLockAccess = 0; -int pers_data_sync(void) -{ - DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("PCL: pers_data_sync()")); - sync(); - return 1; -} - void pers_lock_access(void) { __sync_fetch_and_add(&gLockAccess,1); diff --git a/src/persistence_client_library_pas_interface.h b/src/persistence_client_library_pas_interface.h index ad7f539..b074272 100644 --- a/src/persistence_client_library_pas_interface.h +++ b/src/persistence_client_library_pas_interface.h @@ -39,9 +39,6 @@ DBusHandlerResult checkPersAdminMsg(DBusConnection * connection, DBusMessage * m int signal_persModeChange(DBusConnection *connection, DBusMessage *message); -/// synchronize data back to memory device -int pers_data_sync(void); - /// lock access to persistence data void pers_lock_access(void); |