Skip to content

Commit 1ecf78a

Browse files
committed
feat(platorm): add lstat(2) to platform library
`rm -rf` uses lstat(2) to properly handle symbolic links. Since Zephyr doesn't have them, it shall continue using stat(2). Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com>
1 parent 41a83b6 commit 1ecf78a

5 files changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @copyright Copyright (c) contributors to Project Ocre,
3+
* which has been established as Project Ocre a Series of LF Projects, LLC
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
#include <sys/stat.h>
9+
10+
int ocre_lstat(const char *path, struct stat *buf);

src/platform/posix/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ target_sources(OcrePlatform
1111
log.c
1212
file_mmap.c
1313
# file_alloc_read.c
14+
lstat.c
1415
)
1516

1617
target_include_directories(OcrePlatform

src/platform/posix/lstat.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @copyright Copyright (c) contributors to Project Ocre,
3+
* which has been established as Project Ocre a Series of LF Projects, LLC
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
#include <sys/stat.h>
9+
10+
int ocre_lstat(const char *path, struct stat *buf)
11+
{
12+
return lstat(path, buf);
13+
}

src/platform/zephyr/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ target_sources(OcrePlatform
99
PRIVATE
1010
memory.c
1111
../posix/file_alloc_read.c
12+
lstat.c
1213
)
1314

1415
target_include_directories(OcrePlatform

src/platform/zephyr/lstat.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @copyright Copyright (c) contributors to Project Ocre,
3+
* which has been established as Project Ocre a Series of LF Projects, LLC
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
#include <sys/stat.h>
9+
10+
int ocre_lstat(const char *path, struct stat *buf)
11+
{
12+
return stat(path, buf);
13+
}

0 commit comments

Comments
 (0)