Skip to content

Commit 0fd8b20

Browse files
committed
Fix FATFS compiling
FATFS compiling is currently broken due to several reasons. This fixes: * Bad parameter count for `WRENAME` * Missing `WFFLUSH` define * `WOLFSSH_STOREHANDLE` required for `WOLFSSH_FATFS` to work * Conflict when `NO_FILESYSTEM` is defined for wolfSSL and `WOLFSSH_FATFS` is defined by wolfSSH * Function called that can't be used with `WOLFSSH_FATFS` * Functions defined but not used with `WOLFSSH_FATFS` * Function parameters defined but not used
1 parent 76e8b9f commit 0fd8b20

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

src/wolfsftp.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,8 @@ int wolfSSH_SFTP_read(WOLFSSH* ssh)
14791479
wolfSSH_SFTP_buffer_data(&state->buffer),
14801480
wolfSSH_SFTP_buffer_size(&state->buffer));
14811481
break;
1482-
#if !defined(_WIN32_WCE) && !defined(WOLFSSH_ZEPHYR)
1482+
#if !defined(_WIN32_WCE) && !defined(WOLFSSH_ZEPHYR) && \
1483+
!defined(WOLFSSH_FATFS)
14831484
case WOLFSSH_FTP_SETSTAT:
14841485
ret = wolfSSH_SFTP_RecvSetSTAT(ssh, state->reqId,
14851486
wolfSSH_SFTP_buffer_data(&state->buffer),
@@ -4685,6 +4686,9 @@ int SFTP_GetAttributes_Handle(WOLFSSH* ssh, byte* handle, int handleSz,
46854686
static int SFTP_GetAttributes(void* fs, const char* fileName,
46864687
WS_SFTP_FILEATRB* atr, byte noFollow, void* heap)
46874688
{
4689+
(void) fs;
4690+
(void) noFollow;
4691+
(void) heap;
46884692
FILINFO info;
46894693
FRESULT ret;
46904694
int sz = (int)WSTRLEN(fileName);
@@ -5191,7 +5195,7 @@ int wolfSSH_SFTP_RecvLSTAT(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
51915195
}
51925196

51935197
#if !defined(USE_WINDOWS_API) && !defined(WOLFSSH_ZEPHYR) \
5194-
&& !defined(WOLFSSH_SFTP_SETMODE)
5198+
&& !defined(WOLFSSH_SFTP_SETMODE) && !defined(WOLFSSH_FATFS)
51955199
/* Set the files mode
51965200
* return WS_SUCCESS on success */
51975201
static int SFTP_SetMode(void* fs, char* name, word32 mode) {
@@ -5204,7 +5208,7 @@ static int SFTP_SetMode(void* fs, char* name, word32 mode) {
52045208
#endif
52055209

52065210
#if !defined(USE_WINDOWS_API) && !defined(WOLFSSH_ZEPHYR) \
5207-
&& !defined(WOLFSSH_SFTP_SETMODEHANDLE)
5211+
&& !defined(WOLFSSH_SFTP_SETMODEHANDLE) && !defined(WOLFSSH_FATFS)
52085212
/* Set the files mode
52095213
* return WS_SUCCESS on success */
52105214
static int SFTP_SetModeHandle(void* fs, WFD handle, word32 mode) {
@@ -5216,7 +5220,7 @@ static int SFTP_SetModeHandle(void* fs, WFD handle, word32 mode) {
52165220
}
52175221
#endif
52185222

5219-
#if !defined(_WIN32_WCE) && !defined(WOLFSSH_ZEPHYR)
5223+
#if !defined(_WIN32_WCE) && !defined(WOLFSSH_ZEPHYR) && !defined(WOLFSSH_FATFS)
52205224

52215225
/* sets a files attributes
52225226
* returns WS_SUCCESS on success */

wolfssh/port.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ extern "C" {
101101
#endif
102102
#endif /* !WOLFSSH_HANDLE */
103103

104-
#ifdef NO_FILESYSTEM
104+
#if defined(NO_FILESYSTEM) && !defined(WOLFSSH_FATFS)
105105
#define WS_DELIM '/'
106106
#elif defined(WOLFSSL_NUCLEUS)
107107
#include "storage/nu_storage.h"
@@ -255,6 +255,7 @@ extern "C" {
255255
#define WSEEK_SET 0
256256
#define WSEEK_CUR 1
257257
#define WSEEK_END 2
258+
#define WFFLUSH(s) ((void)(s))
258259
static inline int ff_fopen(WFILE** f, const char* filename,
259260
const char* mode)
260261
{
@@ -585,7 +586,8 @@ extern "C" {
585586

586587
#if (defined(WOLFSSH_SFTP) || \
587588
defined(WOLFSSH_SCP) || defined(WOLFSSH_SSHD)) && \
588-
!defined(NO_WOLFSSH_SERVER) && !defined(NO_FILESYSTEM)
589+
!defined(NO_WOLFSSH_SERVER) && \
590+
(!defined(NO_FILESYSTEM) || defined(WOLFSSH_FATFS))
589591

590592
#ifndef SIZEOF_OFF_T
591593
/* if not using autoconf then make a guess on off_t size based on sizeof
@@ -1192,7 +1194,7 @@ extern "C" {
11921194
#define WSTAT(fs,p,b) f_stat(p,b)
11931195
#define WLSTAT(fs,p,b) f_stat(p,b)
11941196
#define WREMOVE(fs,d) f_unlink((d))
1195-
#define WRENAME(fs,fd,o,n) f_rename((o),(n))
1197+
#define WRENAME(fs,o,n) f_rename((o),(n))
11961198
#define WMKDIR(fs, p, m) f_mkdir(p)
11971199
#define WFD int
11981200

wolfssh/settings.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ extern "C" {
5252
#define USE_WOLFSSH_MEMORY /* default memory handlers */
5353
#endif /* WMALLOC_USER */
5454

55+
/* SFTP requires storehandle when fatfs is in use */
56+
#ifdef WOLFSSH_FATFS
57+
#define WOLFSSH_STOREHANDLE
58+
#endif
5559

5660
#if defined (_WIN32)
5761
#define USE_WINDOWS_API

0 commit comments

Comments
 (0)