From 7ea89a62ba692421bf7b2f78737d2b52a798b472 Mon Sep 17 00:00:00 2001 From: msi-debian Date: Wed, 5 Mar 2025 12:49:58 -0700 Subject: [PATCH] Fix for missing rewind function in zephyr --- wolfcrypt/src/wc_port.c | 9 +++++++++ wolfssl/wolfcrypt/wc_port.h | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index 5a77d860a..a57e54c44 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -1041,6 +1041,15 @@ int z_fs_close(XFILE file) return ret; } +/* Rewind the file pointer to the beginning of the file */ +/* This is not a 'rewind' is not supported in Zephyr so */ +/* use fs_seek to move the file pointer to the beginning of the file */ +/* calling it z_fs_rewind to avoid future conflicts if rewind is added */ +int z_fs_rewind(XFILE file) +{ + return fs_seek(file, 0, FS_SEEK_SET); +} + #endif /* !NO_FILESYSTEM && !WOLFSSL_ZEPHYR */ #if !defined(WOLFSSL_USER_MUTEX) diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index b53c1586f..b0778dfb9 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -804,13 +804,14 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void); * make the API more POSIX like. */ XFILE z_fs_open(const char* filename, const char* mode); int z_fs_close(XFILE file); + int z_fs_rewind(XFILE file); #define XFOPEN z_fs_open #define XFCLOSE z_fs_close #define XFFLUSH fs_sync #define XFSEEK fs_seek #define XFTELL fs_tell - #define XFREWIND fs_rewind + #define XFREWIND z_fs_rewind #define XFREAD(P,S,N,F) fs_read(F, P, S*N) #define XFWRITE(P,S,N,F) fs_write(F, P, S*N) #define XSEEK_SET FS_SEEK_SET