Skip to content

Commit cbbdd74

Browse files
committed
Fix SFTP_GetAttributes with fatfs for root
1 parent 978ef5c commit cbbdd74

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/wolfsftp.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4861,9 +4861,6 @@ static int SFTP_GetAttributes(void* fs, const char* fileName,
48614861
(void) noFollow;
48624862
(void) heap;
48634863

4864-
ret = f_stat(fileName, &info);
4865-
if (ret != FR_OK)
4866-
return -1;
48674864
WMEMSET(atr, 0, sizeof(WS_SFTP_FILEATRB));
48684865
if (sz > 2 && fileName[sz - 2] == ':') {
48694866
atr->flags |= WOLFSSH_FILEATRB_PERM;
@@ -4872,12 +4869,14 @@ static int SFTP_GetAttributes(void* fs, const char* fileName,
48724869
}
48734870

48744871
/* handle case of "/" */
4872+
/* Calling f_stat for "/" returns FR_INVALID_NAME. So we simulate the result. */
48754873
if (sz < 3 && fileName[0] == WS_DELIM) {
48764874
atr->flags |= WOLFSSH_FILEATRB_PERM;
48774875
atr->per |= 0x4000;
48784876
return WS_SUCCESS;
48794877
}
48804878

4879+
ret = f_stat(fileName, &info);
48814880
if (ret != FR_OK) {
48824881
return WS_BAD_FILE_E;
48834882
}

0 commit comments

Comments
 (0)