From 0e921d2fd0f7c356bad87fb635920c20d5cd352e Mon Sep 17 00:00:00 2001 From: Denis 'GNUtoo' Carikli Date: Wed, 17 Jul 2019 17:20:16 +0200 Subject: Add crude debugging for nv_data_path Signed-off-by: Denis 'GNUtoo' Carikli --- include/rfs.h | 3 ++- samsung-ipc/rfs.c | 41 ++++++++++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/include/rfs.h b/include/rfs.h index 7950f16..12d83d0 100644 --- a/include/rfs.h +++ b/include/rfs.h @@ -67,7 +67,8 @@ struct ipc_rfs_nv_write_item_response_data { * Helpers */ -char *ipc_nv_data_md5_calculate(const char *path, const char *secret, +char *ipc_nv_data_md5_calculate(struct ipc_client *client, + const char *path, const char *secret, size_t size, size_t chunk_size); int ipc_nv_data_path_check(struct ipc_client *client); int ipc_nv_data_md5_path_check(struct ipc_client *client); diff --git a/samsung-ipc/rfs.c b/samsung-ipc/rfs.c index 86205ba..9e52ace 100644 --- a/samsung-ipc/rfs.c +++ b/samsung-ipc/rfs.c @@ -40,8 +40,9 @@ char *ipc_nv_data_md5_calculate(const char *path, const char *secret, unsigned char md5_hash[MD5_DIGEST_LENGTH] = { 0 }; MD5_CTX ctx; - if (secret == NULL) + if (secret == NULL) { return NULL; + } data = file_data_read(path, size, chunk_size, 0); if (data == NULL) @@ -72,6 +73,9 @@ int ipc_nv_data_path_check(struct ipc_client *client) if (path == NULL || size == 0) return -1; + ipc_client_log(client, "%s: nv_data path: %s", __FUNCTION__ , path); + ipc_client_log(client, "%s: nv_data size: %d", __FUNCTION__ , size); + rc = stat(path, &st); if (rc < 0) { ipc_client_log(client, "Checking nv_data path failed"); @@ -203,7 +207,8 @@ int ipc_nv_data_check(struct ipc_client *client) rc = ipc_nv_data_path_check(client); if (rc < 0) { - ipc_client_log(client, "Checking nv_data path failed"); + ipc_client_log(client, "%s: Checking nv_data path failed", + __FUNCTION__ ); goto error; } @@ -215,7 +220,8 @@ int ipc_nv_data_check(struct ipc_client *client) md5_string = ipc_nv_data_md5_calculate(path, secret, size, chunk_size); if (md5_string == NULL) { - ipc_client_log(client, "Calculating nv_data md5 failed"); + ipc_client_log(client, "%s: Calculating nv_data md5 failed", + __FUNCTION__); goto error; } ipc_client_log(client, "Calculated nv_data md5: %s", md5_string); @@ -294,7 +300,8 @@ int ipc_nv_data_backup_check(struct ipc_client *client) backup_md5_string = ipc_nv_data_md5_calculate(backup_path, secret, size, chunk_size); if (backup_md5_string == NULL) { - ipc_client_log(client, "Calculating nv_data backup md5 failed"); + ipc_client_log(client, "%s: Calculating nv_data backup md5 failed", + __FUNCTION__); goto error; } ipc_client_log(client, "Calculated nv_data backup md5: %s", backup_md5_string); @@ -362,8 +369,9 @@ int ipc_nv_data_backup(struct ipc_client *client) rc = ipc_nv_data_path_check(client); if (rc < 0) { - ipc_client_log(client, "Checking nv_data path failed"); - goto error; + ipc_client_log(client, "%s : Checking nv_data path failed", + __FUNCTION__); + goto error; } data = file_data_read(path, size, chunk_size, 0); @@ -374,7 +382,8 @@ int ipc_nv_data_backup(struct ipc_client *client) md5_string = ipc_nv_data_md5_calculate(path, secret, size, chunk_size); if (md5_string == NULL) { - ipc_client_log(client, "Calculating nv_data md5 failed"); + ipc_client_log(client, "%s: Calculating nv_data md5 failed", + __FUNCTION__); goto error; } @@ -521,17 +530,20 @@ void *ipc_nv_data_load(struct ipc_client *client) rc = ipc_nv_data_check(client); if (rc < 0) { - ipc_client_log(client, "Checking nv_data failed"); + ipc_client_log(client, "%s: Checking nv_data failed", + __FUNCTION__); rc = ipc_nv_data_restore(client); if (rc < 0) { - ipc_client_log(client, "Restoring nv_data failed"); + ipc_client_log(client, "%s: Restoring nv_data failed", + __FUNCTION__); return NULL; } rc = ipc_nv_data_check(client); if (rc < 0) { - ipc_client_log(client, "Checking nv_data failed"); + ipc_client_log(client, "%s: Checking nv_data failed", + __FUNCTION__); return NULL; } } @@ -572,7 +584,8 @@ void *ipc_nv_data_read(struct ipc_client *client, size_t size, rc = ipc_nv_data_path_check(client); if (rc < 0) { - ipc_client_log(client, "Checking nv_data path failed"); + ipc_client_log(client, "%s: Checking nv_data path failed", + __FUNCTION__); return NULL; } @@ -608,7 +621,8 @@ int ipc_nv_data_write(struct ipc_client *client, const void *data, size_t size, rc = ipc_nv_data_path_check(client); if (rc < 0) { - ipc_client_log(client, "Checking nv_data path failed"); + ipc_client_log(client, "%s: Checking nv_data path failed", + __FUNCTION__); goto error; } @@ -624,7 +638,8 @@ int ipc_nv_data_write(struct ipc_client *client, const void *data, size_t size, md5_string = ipc_nv_data_md5_calculate(path, secret, size, chunk_size); if (md5_string == NULL) { - ipc_client_log(client, "Calculating nv_data md5 failed"); + ipc_client_log(client, "%s: Calculating nv_data md5 failed", + __FUNCTION__); goto error; } -- cgit v1.2.3