Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/All/Dockerfile.All
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM ghcr.io/nanoframework/dev-container-all:v2.59
FROM ghcr.io/nanoframework/dev-container-all:v2.60
2 changes: 1 addition & 1 deletion .devcontainer/All/Dockerfile.All.SRC
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ RUN git clone --branch v6.5.0.202601_rel --recursive https://github.com/eclipse-

# Clone dependent repos (mbedtls, fatfs and littlefs)
RUN git clone --branch R0.15a https://github.com/abbrev/fatfs.git --depth 1 ./sources/fatfs \
&& git clone --branch v2.9.3 https://github.com/littlefs-project/littlefs --depth 1 ./sources/littlefs \
&& git clone --branch v2.11.2 https://github.com/littlefs-project/littlefs --depth 1 ./sources/littlefs \
&& git clone --branch mbedtls-3.6.5 https://github.com/ARMmbed/mbedtls.git --depth 1 ./sources/mbedtls \
&& cd ./sources/mbedtls \
&& git submodule update --init --recursive
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/All/scripts/git-pull-repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ git pull origin 5.5.1
cd /sources/lwip
git pull origin STABLE-2_1_3_RELEASE
cd /sources/littlefs
git pull origin v2.9.3
git pull origin v2.11.2
cd /sources/SimpleLinkCC32
git pull origin 4.10.00.07
cd /sources/SimpleLinkCC13
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/ChibiOS/Dockerfile.ChibiOS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM ghcr.io/nanoframework/dev-container-chibios:v1.36
FROM ghcr.io/nanoframework/dev-container-chibios:v1.37
2 changes: 1 addition & 1 deletion .devcontainer/ChibiOS/Dockerfile.ChibiOS.SRC
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ RUN git clone --branch nf-build https://github.com/nanoframework/STM32CubeL4.git

# Clone dependent repos (mbedtls, fatfs and littlefs etc.)
RUN git clone --branch R0.15a https://github.com/abbrev/fatfs.git --depth 1 ./sources/fatfs \
&& git clone --branch v2.9.3 https://github.com/littlefs-project/littlefs --depth 1 ./sources/littlefs \
&& git clone --branch v2.11.2 https://github.com/littlefs-project/littlefs --depth 1 ./sources/littlefs \
&& git clone --branch STABLE-2_1_3_RELEASE https://github.com/lwip-tcpip/lwip.git --depth 1 ./sources/lwip \
&& git clone --branch mbedtls-3.6.5 https://github.com/ARMmbed/mbedtls.git --depth 1 ./sources/mbedtls \
&& cd ./sources/mbedtls \
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/ThreadX/Dockerfile.ThreadX
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM ghcr.io/nanoframework/dev-container-threadx:v1.36
FROM ghcr.io/nanoframework/dev-container-threadx:v1.37
2 changes: 1 addition & 1 deletion .devcontainer/ThreadX/Dockerfile.ThreadX.SRC
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ RUN git clone --branch v6.5.0.202601_rel --recursive https://github.com/eclipse-

# Clone dependent repos (mbedtls, fatfs and littlefs)
RUN git clone --branch R0.15a https://github.com/abbrev/fatfs.git --depth 1 ./sources/fatfs \
&& git clone --branch v2.9.3 https://github.com/littlefs-project/littlefs --depth 1 ./sources/littlefs \
&& git clone --branch v2.11.2 https://github.com/littlefs-project/littlefs --depth 1 ./sources/littlefs \
&& git clone --branch mbedtls-3.6.5 https://github.com/ARMmbed/mbedtls.git --depth 1 ./sources/mbedtls \
&& cd ./sources/mbedtls \
&& git submodule update --init --recursive
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ resources:
type: github
name: littlefs-project/littlefs
endpoint: nanoframework
ref: refs/tags/v2.9.3
ref: refs/tags/v2.11.2

jobs:
##############################
Expand Down
2 changes: 1 addition & 1 deletion targets/ChibiOS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ if(NF_FEATURE_USE_LITTLEFS_OPTION)
if(LITTLEFS_VERSION_EMPTY)
# no littlefs version actualy specified, must be empty which is fine, we'll default to a known good version
# WHEN CHANGING THIS MAKE SURE TO UPDATE THE DEV CONTAINERS AND PIPELINE YAML
set(LITTLEFS_VERSION_TAG "v2.9.3")
set(LITTLEFS_VERSION_TAG "v2.11.2")
else()
# set version
set(LITTLEFS_VERSION_TAG ${LITTLEFS_VERSION})
Expand Down
10 changes: 9 additions & 1 deletion targets/ChibiOS/_littlefs/littlefs_FS_Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,8 @@ static int NormalizePath(const char *path, char *buffer, size_t bufferSize)
*bufferP = '\0';

// remove trailing slash, if any
if (bufferP[-1] == '/')
// guard against undefined behavior: only check bufferP[-1] when buffer is non-empty
if (bufferP > buffer && bufferP[-1] == '/')
{
bufferP--;
*bufferP = '\0';
Expand All @@ -1172,6 +1173,13 @@ static int NormalizePath(const char *path, char *buffer, size_t bufferSize)
memmove(buffer, buffer + 1, hal_strlen_s(buffer));
}

// use "/" instead to reference the root
if (buffer[0] == '\0')
{
buffer[0] = '/';
buffer[1] = '\0';
}

return 0;
}

Expand Down
27 changes: 18 additions & 9 deletions targets/netcore/littlefs/littlefs_FS_Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ HRESULT LITTLEFS_FS_Driver::Seek(void *handle, int64_t offset, uint32_t origin,
}

// seek to the position
*position = lfs_file_seek(fileHandle->fs, &fileHandle->file, offset, whence);
*position = lfs_file_seek(fileHandle->fs, &fileHandle->file, (lfs_soff_t)offset, whence);

if (*position < LFS_ERR_OK)
{
Expand Down Expand Up @@ -467,7 +467,7 @@ HRESULT LITTLEFS_FS_Driver::SetLength(void *handle, int64_t length)
if (currentLength > length)
{
// truncate the file
if (lfs_file_truncate(fileHandle->fs, &fileHandle->file, length) != LFS_ERR_OK)
if (lfs_file_truncate(fileHandle->fs, &fileHandle->file, (lfs_off_t)length) != LFS_ERR_OK)
{
return CLR_E_FILE_IO;
}
Expand All @@ -480,7 +480,7 @@ HRESULT LITTLEFS_FS_Driver::SetLength(void *handle, int64_t length)
int64_t currentPosition = lfs_file_tell(fileHandle->fs, &fileHandle->file);

// grow the file to the required size
if (lfs_file_seek(fileHandle->fs, &fileHandle->file, length, LFS_SEEK_END) < LFS_ERR_OK)
if (lfs_file_seek(fileHandle->fs, &fileHandle->file, (lfs_soff_t)length, LFS_SEEK_END) < LFS_ERR_OK)
{
return CLR_E_FILE_IO;
}
Expand All @@ -492,7 +492,7 @@ HRESULT LITTLEFS_FS_Driver::SetLength(void *handle, int64_t length)
}

// restore the position
if (lfs_file_seek(fileHandle->fs, &fileHandle->file, currentPosition, LFS_SEEK_SET) < LFS_ERR_OK)
if (lfs_file_seek(fileHandle->fs, &fileHandle->file, (lfs_soff_t)currentPosition, LFS_SEEK_SET) < LFS_ERR_OK)
{
return CLR_E_FILE_IO;
}
Expand Down Expand Up @@ -606,7 +606,7 @@ HRESULT LITTLEFS_FS_Driver::FindNext(void *handle, FS_FILEINFO *fi, bool *fileFo
*fileFound = true;

// set file name size
fi->FileNameSize = hal_strlen_s(info.name);
fi->FileNameSize = (uint32_t)hal_strlen_s(info.name);

// allocate memory for the file name
// MUST BE FREED BY THE CALLER
Expand Down Expand Up @@ -866,6 +866,7 @@ HRESULT LITTLEFS_FS_Driver::CreateDirectory(const VOLUME_ID *volume, const char
char normalizedPath[FS_MAX_DIRECTORY_LENGTH];
char tempPath[FS_MAX_DIRECTORY_LENGTH + 1];
char *segment;
char *strtokContext = NULL;
int32_t dirExists;

(void)dirExists;
Expand All @@ -884,7 +885,7 @@ HRESULT LITTLEFS_FS_Driver::CreateDirectory(const VOLUME_ID *volume, const char
memset(tempPath, 0, sizeof(tempPath));

// iterate over the path segments and create the directories
segment = strtok(normalizedPath, "/");
segment = strtok_s(normalizedPath, "/", &strtokContext);

while (segment && (result == LFS_ERR_OK || result == LFS_ERR_EXIST))
{
Expand All @@ -898,9 +899,9 @@ HRESULT LITTLEFS_FS_Driver::CreateDirectory(const VOLUME_ID *volume, const char
}

// add back the '/' separator
strcat(tempPath, "/");
strcat_s(tempPath, sizeof(tempPath), "/");

segment = strtok(NULL, "/");
segment = strtok_s(NULL, "/", &strtokContext);
}

// remove trailing '/'
Expand Down Expand Up @@ -1127,7 +1128,8 @@ static int NormalizePath(const char *path, char *buffer, size_t bufferSize)
*bufferP = '\0';

// remove trailing slash, if any
if (bufferP[-1] == '/')
// guard against undefined behavior: only check bufferP[-1] when buffer is non-empty
if (bufferP > buffer && bufferP[-1] == '/')
{
bufferP--;
*bufferP = '\0';
Expand All @@ -1139,6 +1141,13 @@ static int NormalizePath(const char *path, char *buffer, size_t bufferSize)
memmove(buffer, buffer + 1, hal_strlen_s(buffer));
}

// use "/" instead to reference the root
if (buffer[0] == '\0')
{
buffer[0] = '/';
buffer[1] = '\0';
}

return 0;
}

Expand Down
Loading