mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
feat(newlib): add dummy implementations of pathconf, chmod, dirfd
Closes https://github.com/espressif/esp-idf/issues/14174
This commit is contained in:
parent
d79c4f7e28
commit
7a214c1fab
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -9,6 +9,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
/* realpath logic:
|
||||
@ -122,3 +123,20 @@ int chdir(const char *path)
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* std::filesystem functions call chmod and exit with an exception if it fails,
|
||||
* so not failing with ENOSYS seems a better solution.
|
||||
*/
|
||||
int chmod(const char *path, mode_t mode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* As a workaround for libstdc++ being built with _GLIBCXX_HAVE_DIRFD,
|
||||
* we have to provide at least a stub for dirfd function.
|
||||
*/
|
||||
int dirfd(DIR *dirp)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
@ -1,13 +1,18 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
static const char *TAG = "sysconf";
|
||||
|
||||
#ifdef CONFIG_FREERTOS_UNICORE
|
||||
#define CPU_NUM 1
|
||||
#else
|
||||
@ -25,3 +30,24 @@ long sysconf(int arg)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// pathconf
|
||||
long fpathconf(int fildes, int name)
|
||||
{
|
||||
if (name == _PC_PATH_MAX) {
|
||||
return PATH_MAX;
|
||||
}
|
||||
ESP_LOGW(TAG, "fpathconf: unsupported name %d", name);
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
long pathconf(const char *path, int name)
|
||||
{
|
||||
if (name == _PC_PATH_MAX) {
|
||||
return PATH_MAX;
|
||||
}
|
||||
ESP_LOGW(TAG, "pathconf: unsupported name %d", name);
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user