mirror of
https://github.com/micropython/micropython.git
synced 2025-07-21 21:11:12 +02:00
extmod/vfs: Guard mutating fs functions with MICROPY_VFS_WRITABLE.
Some checks failed
JavaScript code lint and formatting with Biome / eslint (push) Failing after 0s
unix port / macos (push) Waiting to run
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-mingw (i686, mingw32, dev) (push) Waiting to run
windows port / build-mingw (i686, mingw32, standard) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, dev) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, standard) (push) Waiting to run
Check code formatting / code-formatting (push) Failing after 0s
Check spelling with codespell / codespell (push) Failing after 0s
Build docs / build (push) Failing after 0s
Check examples / embedding (push) Failing after 0s
Package mpremote / build (push) Failing after 0s
.mpy file format and tools / test (push) Failing after 0s
Build ports metadata / build (push) Failing after 0s
cc3200 port / build (push) Failing after 0s
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Failing after 0s
esp32 port / build_idf (esp32_build_s3_c3) (push) Failing after 0s
esp8266 port / build (push) Failing after 0s
mimxrt port / build (push) Failing after 0s
nrf port / build (push) Failing after 0s
powerpc port / build (push) Failing after 0s
qemu port / build_and_test_arm (push) Failing after 0s
qemu port / build_and_test_rv32 (push) Failing after 0s
renesas-ra port / build_renesas_ra_board (push) Failing after 0s
rp2 port / build (push) Failing after 0s
samd port / build (push) Failing after 0s
stm32 port / build_stm32 (stm32_misc_build) (push) Failing after 0s
stm32 port / build_stm32 (stm32_nucleo_build) (push) Failing after 0s
stm32 port / build_stm32 (stm32_pyb_build) (push) Failing after 0s
unix port / minimal (push) Failing after 0s
unix port / reproducible (push) Failing after 0s
unix port / standard (push) Failing after 0s
unix port / standard_v2 (push) Failing after 0s
unix port / coverage (push) Failing after 0s
unix port / coverage_32bit (push) Failing after 0s
unix port / nanbox (push) Failing after 0s
unix port / float (push) Failing after 0s
unix port / stackless_clang (push) Failing after 0s
unix port / float_clang (push) Failing after 0s
unix port / settrace (push) Failing after 0s
unix port / settrace_stackless (push) Failing after 0s
unix port / qemu_mips (push) Failing after 0s
unix port / qemu_arm (push) Failing after 0s
unix port / qemu_riscv64 (push) Failing after 0s
webassembly port / build (push) Failing after 0s
windows port / cross-build-on-linux (push) Failing after 0s
zephyr port / build (push) Failing after 0s
Python code lint and formatting with ruff / ruff (push) Failing after 0s
Some checks failed
JavaScript code lint and formatting with Biome / eslint (push) Failing after 0s
unix port / macos (push) Waiting to run
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-mingw (i686, mingw32, dev) (push) Waiting to run
windows port / build-mingw (i686, mingw32, standard) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, dev) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, standard) (push) Waiting to run
Check code formatting / code-formatting (push) Failing after 0s
Check spelling with codespell / codespell (push) Failing after 0s
Build docs / build (push) Failing after 0s
Check examples / embedding (push) Failing after 0s
Package mpremote / build (push) Failing after 0s
.mpy file format and tools / test (push) Failing after 0s
Build ports metadata / build (push) Failing after 0s
cc3200 port / build (push) Failing after 0s
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Failing after 0s
esp32 port / build_idf (esp32_build_s3_c3) (push) Failing after 0s
esp8266 port / build (push) Failing after 0s
mimxrt port / build (push) Failing after 0s
nrf port / build (push) Failing after 0s
powerpc port / build (push) Failing after 0s
qemu port / build_and_test_arm (push) Failing after 0s
qemu port / build_and_test_rv32 (push) Failing after 0s
renesas-ra port / build_renesas_ra_board (push) Failing after 0s
rp2 port / build (push) Failing after 0s
samd port / build (push) Failing after 0s
stm32 port / build_stm32 (stm32_misc_build) (push) Failing after 0s
stm32 port / build_stm32 (stm32_nucleo_build) (push) Failing after 0s
stm32 port / build_stm32 (stm32_pyb_build) (push) Failing after 0s
unix port / minimal (push) Failing after 0s
unix port / reproducible (push) Failing after 0s
unix port / standard (push) Failing after 0s
unix port / standard_v2 (push) Failing after 0s
unix port / coverage (push) Failing after 0s
unix port / coverage_32bit (push) Failing after 0s
unix port / nanbox (push) Failing after 0s
unix port / float (push) Failing after 0s
unix port / stackless_clang (push) Failing after 0s
unix port / float_clang (push) Failing after 0s
unix port / settrace (push) Failing after 0s
unix port / settrace_stackless (push) Failing after 0s
unix port / qemu_mips (push) Failing after 0s
unix port / qemu_arm (push) Failing after 0s
unix port / qemu_riscv64 (push) Failing after 0s
webassembly port / build (push) Failing after 0s
windows port / cross-build-on-linux (push) Failing after 0s
zephyr port / build (push) Failing after 0s
Python code lint and formatting with ruff / ruff (push) Failing after 0s
Enabled by default. Useful for ports that need the VFS but don't have any writable filesystems. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -171,13 +171,15 @@ static const mp_rom_map_elem_t os_module_globals_table[] = {
|
|||||||
{ MP_ROM_QSTR(MP_QSTR_chdir), MP_ROM_PTR(&mp_vfs_chdir_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_chdir), MP_ROM_PTR(&mp_vfs_chdir_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_getcwd), MP_ROM_PTR(&mp_vfs_getcwd_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_getcwd), MP_ROM_PTR(&mp_vfs_getcwd_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_listdir), MP_ROM_PTR(&mp_vfs_listdir_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_listdir), MP_ROM_PTR(&mp_vfs_listdir_obj) },
|
||||||
|
#if MICROPY_VFS_WRITABLE
|
||||||
{ MP_ROM_QSTR(MP_QSTR_mkdir), MP_ROM_PTR(&mp_vfs_mkdir_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_mkdir), MP_ROM_PTR(&mp_vfs_mkdir_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&mp_vfs_remove_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&mp_vfs_remove_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_rename), MP_ROM_PTR(&mp_vfs_rename_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_rename), MP_ROM_PTR(&mp_vfs_rename_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_rmdir), MP_ROM_PTR(&mp_vfs_rmdir_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_rmdir), MP_ROM_PTR(&mp_vfs_rmdir_obj) },
|
||||||
|
{ MP_ROM_QSTR(MP_QSTR_unlink), MP_ROM_PTR(&mp_vfs_remove_obj) }, // unlink aliases to remove
|
||||||
|
#endif
|
||||||
{ MP_ROM_QSTR(MP_QSTR_stat), MP_ROM_PTR(&mp_vfs_stat_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_stat), MP_ROM_PTR(&mp_vfs_stat_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_statvfs), MP_ROM_PTR(&mp_vfs_statvfs_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_statvfs), MP_ROM_PTR(&mp_vfs_statvfs_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_unlink), MP_ROM_PTR(&mp_vfs_remove_obj) }, // unlink aliases to remove
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// The following are MicroPython extensions.
|
// The following are MicroPython extensions.
|
||||||
|
@@ -443,6 +443,8 @@ mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args) {
|
|||||||
}
|
}
|
||||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_vfs_listdir_obj, 0, 1, mp_vfs_listdir);
|
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_vfs_listdir_obj, 0, 1, mp_vfs_listdir);
|
||||||
|
|
||||||
|
#if MICROPY_VFS_WRITABLE
|
||||||
|
|
||||||
mp_obj_t mp_vfs_mkdir(mp_obj_t path_in) {
|
mp_obj_t mp_vfs_mkdir(mp_obj_t path_in) {
|
||||||
mp_obj_t path_out;
|
mp_obj_t path_out;
|
||||||
mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out);
|
mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out);
|
||||||
@@ -479,6 +481,8 @@ mp_obj_t mp_vfs_rmdir(mp_obj_t path_in) {
|
|||||||
}
|
}
|
||||||
MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_rmdir_obj, mp_vfs_rmdir);
|
MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_rmdir_obj, mp_vfs_rmdir);
|
||||||
|
|
||||||
|
#endif // MICROPY_VFS_WRITABLE
|
||||||
|
|
||||||
mp_obj_t mp_vfs_stat(mp_obj_t path_in) {
|
mp_obj_t mp_vfs_stat(mp_obj_t path_in) {
|
||||||
mp_obj_t path_out;
|
mp_obj_t path_out;
|
||||||
mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out);
|
mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out);
|
||||||
|
@@ -95,10 +95,12 @@ mp_obj_t mp_vfs_chdir(mp_obj_t path_in);
|
|||||||
mp_obj_t mp_vfs_getcwd(void);
|
mp_obj_t mp_vfs_getcwd(void);
|
||||||
mp_obj_t mp_vfs_ilistdir(size_t n_args, const mp_obj_t *args);
|
mp_obj_t mp_vfs_ilistdir(size_t n_args, const mp_obj_t *args);
|
||||||
mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args);
|
mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args);
|
||||||
|
#if MICROPY_VFS_WRITABLE
|
||||||
mp_obj_t mp_vfs_mkdir(mp_obj_t path_in);
|
mp_obj_t mp_vfs_mkdir(mp_obj_t path_in);
|
||||||
mp_obj_t mp_vfs_remove(mp_obj_t path_in);
|
mp_obj_t mp_vfs_remove(mp_obj_t path_in);
|
||||||
mp_obj_t mp_vfs_rename(mp_obj_t old_path_in, mp_obj_t new_path_in);
|
mp_obj_t mp_vfs_rename(mp_obj_t old_path_in, mp_obj_t new_path_in);
|
||||||
mp_obj_t mp_vfs_rmdir(mp_obj_t path_in);
|
mp_obj_t mp_vfs_rmdir(mp_obj_t path_in);
|
||||||
|
#endif
|
||||||
mp_obj_t mp_vfs_stat(mp_obj_t path_in);
|
mp_obj_t mp_vfs_stat(mp_obj_t path_in);
|
||||||
mp_obj_t mp_vfs_statvfs(mp_obj_t path_in);
|
mp_obj_t mp_vfs_statvfs(mp_obj_t path_in);
|
||||||
|
|
||||||
@@ -111,10 +113,12 @@ MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_chdir_obj);
|
|||||||
MP_DECLARE_CONST_FUN_OBJ_0(mp_vfs_getcwd_obj);
|
MP_DECLARE_CONST_FUN_OBJ_0(mp_vfs_getcwd_obj);
|
||||||
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_vfs_ilistdir_obj);
|
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_vfs_ilistdir_obj);
|
||||||
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_vfs_listdir_obj);
|
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_vfs_listdir_obj);
|
||||||
|
#if MICROPY_VFS_WRITABLE
|
||||||
MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_mkdir_obj);
|
MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_mkdir_obj);
|
||||||
MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_remove_obj);
|
MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_remove_obj);
|
||||||
MP_DECLARE_CONST_FUN_OBJ_2(mp_vfs_rename_obj);
|
MP_DECLARE_CONST_FUN_OBJ_2(mp_vfs_rename_obj);
|
||||||
MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_rmdir_obj);
|
MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_rmdir_obj);
|
||||||
|
#endif
|
||||||
MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_stat_obj);
|
MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_stat_obj);
|
||||||
MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_statvfs_obj);
|
MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_statvfs_obj);
|
||||||
|
|
||||||
|
@@ -991,6 +991,11 @@ typedef double mp_float_t;
|
|||||||
#define MICROPY_VFS (0)
|
#define MICROPY_VFS (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Whether to include support for writable filesystems.
|
||||||
|
#ifndef MICROPY_VFS_WRITABLE
|
||||||
|
#define MICROPY_VFS_WRITABLE (1)
|
||||||
|
#endif
|
||||||
|
|
||||||
// Support for VFS POSIX component, to mount a POSIX filesystem within VFS
|
// Support for VFS POSIX component, to mount a POSIX filesystem within VFS
|
||||||
#ifndef MICROPY_VFS_POSIX
|
#ifndef MICROPY_VFS_POSIX
|
||||||
#define MICROPY_VFS_POSIX (0)
|
#define MICROPY_VFS_POSIX (0)
|
||||||
|
Reference in New Issue
Block a user