Skip to content

Commit 2bc5629

Browse files
JacobBarthelmehejohnstown
authored andcommitted
fix for zephyr time include and UTIME guard
1 parent 719cc31 commit 2bc5629

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/wolfscp.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,7 @@ static int SetTimestampInfo(WFILE* fp, const char* fileName,
22662266
#ifdef USE_WINDOWS_API
22672267
struct _utimbuf tmp;
22682268
int fd;
2269-
#else
2269+
#elif !defined(WOLFSSH_NO_UTIMES)
22702270
struct timeval tmp[2];
22712271
#endif
22722272

@@ -2287,6 +2287,11 @@ static int SetTimestampInfo(WFILE* fp, const char* fileName,
22872287
if (WFFLUSH(fp) != 0 || _commit(fd) != 0 || _futime(fd, &tmp) != 0)
22882288
ret = WS_FATAL_ERROR;
22892289
}
2290+
#elif defined(WOLFSSH_NO_UTIMES)
2291+
/* No utimes() on this port; the file keeps its creation timestamps. */
2292+
(void)fp;
2293+
(void)mTime;
2294+
(void)aTime;
22902295
#else
22912296
tmp[0].tv_sec = (time_t)aTime;
22922297
tmp[0].tv_usec = 0;

wolfssh/port.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,10 @@ extern "C" {
368368

369369
#include <zephyr/fs/fs.h>
370370
#include <zephyr/version.h>
371-
#if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(4, 1, 0)
372-
/* struct timeval: pre-4.1 it arrived via the socket headers when
373-
* NET_SOCKETS_POSIX_NAMES was set; 4.1+ needs the POSIX header
374-
* (CONFIG_POSIX_API). */
371+
/* struct timeval. Include it directly rather than relying on it arriving
372+
* transitively through wolfSSL's Zephyr POSIX includes. */
373+
#if defined(CONFIG_POSIX_API) || \
374+
ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(4, 1, 0)
375375
#include <zephyr/posix/sys/time.h>
376376
#endif
377377
#include <stdlib.h>
@@ -400,7 +400,8 @@ extern "C" {
400400
#define WFGETS(b,s,f) NULL /* Not ported yet */
401401
#undef WFPUTS
402402
#define WFPUTS(b,s) EOF /* Not ported yet */
403-
#define WUTIMES(a,b) ((void)(a),(void)(b),0) /* Not ported yet */
403+
#define WOLFSSH_NO_UTIMES
404+
#define WUTIMES(a,b) (0) /* Not ported yet */
404405
#define WCHDIR(fs,b) z_fs_chdir((b))
405406

406407
#elif defined(MICROCHIP_MPLAB_HARMONY)
@@ -434,6 +435,7 @@ extern "C" {
434435
#define WFGETS(b,s,f) SYS_FS_FileStringGet((f), (b), (s))
435436
#undef WFPUTS
436437
#define WFPUTS(b,f) SYS_FS_FileStringPut((f), (b))
438+
#define WOLFSSH_NO_UTIMES
437439
#define WUTIMES(a,b) (0) /* Not ported yet */
438440
#define WSETTIME(fs,f,a,m) (0)
439441
#define WFSETTIME(fs,fd,a,m) (0)
@@ -463,6 +465,7 @@ extern "C" {
463465
#define WSETTIME(fs,f,a,m) (0)
464466
#define WFSETTIME(fs,fd,a,m) (0)
465467
#ifdef WOLFSSL_VXWORKS
468+
#define WOLFSSH_NO_UTIMES
466469
#define WUTIMES(f,t) (WS_SUCCESS)
467470
#elif defined(USE_WINDOWS_API)
468471
#include <sys/utime.h>

0 commit comments

Comments
 (0)