Skip to content

Commit 1bd3bf1

Browse files
authored
Merge pull request wolfSSL#8531 from night1rider/zephyr-fs-rewind-fix
Fix for missing rewind function in zephyr
2 parents 7d102a1 + 7ea89a6 commit 1bd3bf1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

wolfcrypt/src/wc_port.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,15 @@ int z_fs_close(XFILE file)
10411041
return ret;
10421042
}
10431043

1044+
/* Rewind the file pointer to the beginning of the file */
1045+
/* This is not a 'rewind' is not supported in Zephyr so */
1046+
/* use fs_seek to move the file pointer to the beginning of the file */
1047+
/* calling it z_fs_rewind to avoid future conflicts if rewind is added */
1048+
int z_fs_rewind(XFILE file)
1049+
{
1050+
return fs_seek(file, 0, FS_SEEK_SET);
1051+
}
1052+
10441053
#endif /* !NO_FILESYSTEM && !WOLFSSL_ZEPHYR */
10451054

10461055
#if !defined(WOLFSSL_USER_MUTEX)

wolfssl/wolfcrypt/wc_port.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,13 +804,14 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
804804
* make the API more POSIX like. */
805805
XFILE z_fs_open(const char* filename, const char* mode);
806806
int z_fs_close(XFILE file);
807+
int z_fs_rewind(XFILE file);
807808

808809
#define XFOPEN z_fs_open
809810
#define XFCLOSE z_fs_close
810811
#define XFFLUSH fs_sync
811812
#define XFSEEK fs_seek
812813
#define XFTELL fs_tell
813-
#define XFREWIND fs_rewind
814+
#define XFREWIND z_fs_rewind
814815
#define XFREAD(P,S,N,F) fs_read(F, P, S*N)
815816
#define XFWRITE(P,S,N,F) fs_write(F, P, S*N)
816817
#define XSEEK_SET FS_SEEK_SET

0 commit comments

Comments
 (0)