Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
circuitpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
circuitpython
Commits
03a1f94e
Commit
03a1f94e
authored
Oct 29, 2020
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extmod/vfs_lfs: Support mounting LFS filesystems in read-only mode.
Signed-off-by:
Damien George
<
damien@micropython.org
>
parent
0118c079
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
3 deletions
+32
-3
extmod/vfs_lfsx.c
extmod/vfs_lfsx.c
+9
-3
tests/extmod/vfs_lfs_mount.py
tests/extmod/vfs_lfs_mount.py
+17
-0
tests/extmod/vfs_lfs_mount.py.exp
tests/extmod/vfs_lfs_mount.py.exp
+6
-0
No files found.
extmod/vfs_lfsx.c
View file @
03a1f94e
...
...
@@ -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
));
...
...
tests/extmod/vfs_lfs_mount.py
View file @
03a1f94e
...
...
@@ -67,6 +67,23 @@ def test(bdev, vfs_class):
# umount
uos
.
umount
(
"/lfs"
)
# mount read-only
vfs
=
vfs_class
(
bdev
)
uos
.
mount
(
vfs
,
"/lfs"
,
readonly
=
True
)
# test reading works
with
open
(
"/lfs/subdir/lfsmod2.py"
)
as
f
:
print
(
"lfsmod2.py:"
,
f
.
read
())
# test writing fails
try
:
open
(
"/lfs/test_write"
,
"w"
)
except
OSError
as
er
:
print
(
repr
(
er
))
# umount
uos
.
umount
(
"/lfs"
)
# clear imported modules
usys
.
modules
.
clear
()
...
...
tests/extmod/vfs_lfs_mount.py.exp
View file @
03a1f94e
...
...
@@ -2,7 +2,13 @@ test <class 'VfsLfs1'>
hello
from
lfs
package
hello
from
lfs
lfsmod2
.
py
:
print
(
"hello from lfs"
)
OSError
(
30
,)
test
<
class
'VfsLfs2'
>
hello
from
lfs
package
hello
from
lfs
lfsmod2
.
py
:
print
(
"hello from lfs"
)
OSError
(
36
,)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment