diff options
| author | Damien George <damien@micropython.org> | 2020-10-29 11:31:53 +1100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2020-10-29 11:43:52 +1100 |
| commit | 03a1f94ea16a532bd4219092edb06e251d9a0ca5 (patch) | |
| tree | 85b12095c9e2a9dbddac8794cc0bddce9ea53ffa /extmod/vfs_lfsx.c | |
| parent | 0118c07916c24a6ccb6dbd0ea904312f01798b40 (diff) | |
extmod/vfs_lfs: Support mounting LFS filesystems in read-only mode.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'extmod/vfs_lfsx.c')
| -rw-r--r-- | extmod/vfs_lfsx.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/extmod/vfs_lfsx.c b/extmod/vfs_lfsx.c index 35d5f03c5..f865e4606 100644 --- a/extmod/vfs_lfsx.c +++ b/extmod/vfs_lfsx.c @@ -423,10 +423,16 @@ STATIC mp_obj_t MP_VFS_LFSx(statvfs)(mp_obj_t self_in, mp_obj_t path_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_2(MP_VFS_LFSx(statvfs_obj), MP_VFS_LFSx(statvfs)); STATIC mp_obj_t MP_VFS_LFSx(mount)(mp_obj_t self_in, mp_obj_t readonly, mp_obj_t mkfs) { - (void)self_in; - (void)readonly; + MP_OBJ_VFS_LFSx *self = MP_OBJ_TO_PTR(self_in); (void)mkfs; - // already called LFSx_API(mount) in MP_VFS_LFSx(make_new) + + // Make block device read-only if requested. + if (mp_obj_is_true(readonly)) { + self->blockdev.writeblocks[0] = MP_OBJ_NULL; + } + + // Already called LFSx_API(mount) in MP_VFS_LFSx(make_new) so the filesystem is ready. + return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(MP_VFS_LFSx(mount_obj), MP_VFS_LFSx(mount)); |
