qatlib/0005-Make-hash_file_sample-to-hash-its-own-binary.patch
Vladis Dronov f0337a9db8 Fix small issues in qatlib-tests package
And update documentation from the upstream
2022-03-24 12:26:13 +01:00

63 lines
2.1 KiB
Diff

From e94a964a9c167e917496e63b5e379c327dd9b93f Mon Sep 17 00:00:00 2001
From: Vladis Dronov <vdronov@redhat.com>
Date: Tue, 22 Mar 2022 17:24:27 +0100
Subject: [PATCH] Make hash_file_sample to hash its own binary
Signed-off-by: Vladis Dronov <vdronov@redhat.com>
---
.../hash_file_sample/cpa_hash_file_sample_user.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/quickassist/lookaside/access_layer/src/sample_code/functional/sym/hash_file_sample/cpa_hash_file_sample_user.c b/quickassist/lookaside/access_layer/src/sample_code/functional/sym/hash_file_sample/cpa_hash_file_sample_user.c
index 758d7bd..38e0650 100644
--- a/quickassist/lookaside/access_layer/src/sample_code/functional/sym/hash_file_sample/cpa_hash_file_sample_user.c
+++ b/quickassist/lookaside/access_layer/src/sample_code/functional/sym/hash_file_sample/cpa_hash_file_sample_user.c
@@ -65,10 +65,12 @@
* @file cpa_hash_file_sample_user.c
*
*****************************************************************************/
+#include <limits.h>
+#include <unistd.h>
+
#include "cpa_sample_utils.h"
#include "icp_sal_user.h"
-#define FILE_NAME_LENGTH 100
char *gFileName = NULL;
extern CpaStatus hashFileSample(void);
@@ -78,7 +80,7 @@ int gDebugParam = 1;
int main(int argc, const char **argv)
{
CpaStatus stat = CPA_STATUS_SUCCESS;
- char fileToHash[FILE_NAME_LENGTH] = "hash_file_sample";
+ char fileToHash[PATH_MAX] = { 0 };
/* Read in debug setting if present */
if (argc > 1)
@@ -88,6 +90,13 @@ int main(int argc, const char **argv)
PRINT_DBG("Starting Hash File Sample Code App ...\n");
+ if (0 > readlink("/proc/self/exe", fileToHash, sizeof(fileToHash)))
+ {
+ PRINT_ERR("Failed to get path to a binary of self\n");
+ return 1;
+ }
+ gFileName = fileToHash;
+
stat = qaeMemInit();
if (CPA_STATUS_SUCCESS != stat)
{
@@ -102,7 +111,6 @@ int main(int argc, const char **argv)
qaeMemDestroy();
return (int)stat;
}
- gFileName = fileToHash;
stat = hashFileSample();
if (CPA_STATUS_SUCCESS != stat)
--
2.35.1