mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
feat(esp_stdio): add custom IO registration
This commit is contained in:
@@ -6,11 +6,13 @@ if(${target} STREQUAL "linux")
|
||||
set(inc)
|
||||
set(priv_inc)
|
||||
|
||||
list(APPEND inc include)
|
||||
# linux_include provides stubs (sys/reent.h, dirent.h, errno.h) required by
|
||||
# esp_vfs.h unconditionally, so expose it for all Linux builds regardless of
|
||||
# VFS_SUPPORT_IO, which now defaults to n on Linux.
|
||||
list(APPEND inc include linux_include)
|
||||
if(CONFIG_VFS_SUPPORT_IO)
|
||||
list(APPEND inc linux_include)
|
||||
list(APPEND priv_inc private_include)
|
||||
list(APPEND srcs "vfs_linux.c" "vfs_linux_default_coop.c" "vfs.c" "vfs_calls.c")
|
||||
list(APPEND srcs "vfs_linux.c" "vfs_linux_default_coop.c" "vfs.c" "vfs_calls.c" "nullfs.c")
|
||||
endif()
|
||||
|
||||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -32,10 +32,16 @@ typedef struct {
|
||||
|
||||
/**
|
||||
* @brief Directory entry structure
|
||||
*
|
||||
* Fields match the glibc layout so that this header is binary-compatible with
|
||||
* glibc's readdir() when CONFIG_VFS_SUPPORT_IO is disabled on Linux (in which
|
||||
* case glibc's readdir() fills the struct, not the VFS wrapper).
|
||||
*/
|
||||
struct dirent {
|
||||
ino_t d_ino; /*!< file number */
|
||||
uint8_t d_type; /*!< not defined in POSIX, but present in BSD and Linux */
|
||||
ino_t d_ino; /*!< file number */
|
||||
off_t d_off; /*!< implementation-defined offset (glibc extension) */
|
||||
unsigned short d_reclen; /*!< length of this record (glibc extension) */
|
||||
uint8_t d_type; /*!< not defined in POSIX, but present in BSD and Linux */
|
||||
#define DT_UNKNOWN 0
|
||||
#define DT_REG 1
|
||||
#define DT_DIR 2
|
||||
|
||||
@@ -148,7 +148,7 @@ static ssize_t vfs_null_read(__attribute__((unused)) void *ctx, int fd, void *da
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int vfs_null_pread(__attribute__((unused)) void *ctx, int fd, void *data, size_t size, off_t offset)
|
||||
static ssize_t vfs_null_pread(__attribute__((unused)) void *ctx, int fd, void *data, size_t size, off_t offset)
|
||||
{
|
||||
UNUSED(data);
|
||||
UNUSED(size);
|
||||
@@ -165,7 +165,7 @@ static int vfs_null_pread(__attribute__((unused)) void *ctx, int fd, void *data,
|
||||
|
||||
}
|
||||
|
||||
static int vfs_null_pwrite(__attribute__((unused)) void *ctx, int fd, const void *data, size_t size, off_t offset)
|
||||
static ssize_t vfs_null_pwrite(__attribute__((unused)) void *ctx, int fd, const void *data, size_t size, off_t offset)
|
||||
{
|
||||
UNUSED(data);
|
||||
UNUSED(offset);
|
||||
|
||||
Reference in New Issue
Block a user