summaryrefslogtreecommitdiff
path: root/extmod/vfs_posix.c
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2025-07-19 06:38:18 -0500
committerDamien George <damien@micropython.org>2025-07-24 10:39:41 +1000
commit59ee59901b9223697cf96f5859fcbf49fe9d21f4 (patch)
tree4a37a1a23101b02985974667375e8d2f23958d4f /extmod/vfs_posix.c
parent3c603f7baf25b089a30f41d3cd57d13ba50b194c (diff)
extmod/vfs_posix: Add MICROPY_VFS_POSIX_WRITABLE option.
When this configuration flag is set, VfsPosix instances can be written. Otherwise, they will always be created "read only". This flag is useful when fuzzing micropython: Without VfsPosix, the fuzzing input script cannot be read; but with writable VfsPosix, fuzzing scripts can potentially perform undesired operations on the host filesystem. Signed-off-by: Jeff Epler <jepler@gmail.com>
Diffstat (limited to 'extmod/vfs_posix.c')
-rw-r--r--extmod/vfs_posix.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/extmod/vfs_posix.c b/extmod/vfs_posix.c
index 9393d3b5e..27f833e80 100644
--- a/extmod/vfs_posix.c
+++ b/extmod/vfs_posix.c
@@ -137,7 +137,7 @@ static mp_obj_t vfs_posix_make_new(const mp_obj_type_t *type, size_t n_args, siz
vstr_add_char(&vfs->root, '/');
}
vfs->root_len = vfs->root.len;
- vfs->readonly = false;
+ vfs->readonly = !MICROPY_VFS_POSIX_WRITABLE;
return MP_OBJ_FROM_PTR(vfs);
}
@@ -161,7 +161,7 @@ static mp_obj_t vfs_posix_umount(mp_obj_t self_in) {
static MP_DEFINE_CONST_FUN_OBJ_1(vfs_posix_umount_obj, vfs_posix_umount);
static inline bool vfs_posix_is_readonly(mp_obj_vfs_posix_t *self) {
- return self->readonly;
+ return !MICROPY_VFS_POSIX_WRITABLE || self->readonly;
}
static void vfs_posix_require_writable(mp_obj_t self_in) {