4848//| directly.
4949//|
5050
51- //| .. function:: mount(filesystem, mount_path, \*, readonly=False)
51+ //| .. function:: mount(filesystem, mount_path, \*, readonly=False, disable_concurrent_write_protection=False )
5252//|
5353//| Mounts the given filesystem object at the given path.
5454//|
5555//| This is the CircuitPython analog to the UNIX ``mount`` command.
5656//|
57+ //| :param bool readonly: True when the filesystem should be readonly to CircuitPython.
58+ //|
5759mp_obj_t storage_mount (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
5860 enum { ARG_readonly };
5961 static const mp_arg_t allowed_args [] = {
60- { MP_QSTR_readonly , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_obj = mp_const_false } },
62+ { MP_QSTR_readonly , MP_ARG_KW_ONLY | MP_ARG_BOOL , {.u_bool = false } },
6163 };
6264
6365 // parse args
@@ -77,7 +79,7 @@ mp_obj_t storage_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_arg
7779 mp_raise_ValueError (translate ("filesystem must provide mount method" ));
7880 }
7981
80- common_hal_storage_mount (vfs_obj , mnt_str , mp_obj_is_true ( args [ARG_readonly ].u_obj ) );
82+ common_hal_storage_mount (vfs_obj , mnt_str , args [ARG_readonly ].u_bool );
8183
8284 return mp_const_none ;
8385}
@@ -101,14 +103,21 @@ mp_obj_t storage_umount(mp_obj_t mnt_in) {
101103}
102104MP_DEFINE_CONST_FUN_OBJ_1 (storage_umount_obj , storage_umount );
103105
104- //| .. function:: remount(mount_path, readonly=False)
106+ //| .. function:: remount(mount_path, readonly=False, *, disable_concurrent_write_protection=False )
105107//|
106108//| Remounts the given path with new parameters.
107109//|
110+ //| :param bool readonly: True when the filesystem should be readonly to CircuitPython.
111+ //| :param bool disable_concurrent_write_protection: When True, the check that makes sure the
112+ //| underlying filesystem data is written by one computer is disabled. Disabling the protection
113+ //| allows CircuitPython and a host to write to the same filesystem with the risk that the
114+ //| filesystem will be corrupted.
115+ //|
108116mp_obj_t storage_remount (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
109- enum { ARG_readonly };
117+ enum { ARG_readonly , ARG_disable_concurrent_write_protection };
110118 static const mp_arg_t allowed_args [] = {
111- { MP_QSTR_readonly , MP_ARG_BOOL | MP_ARG_REQUIRED , {.u_bool = false} },
119+ { MP_QSTR_readonly , MP_ARG_BOOL , {.u_bool = false} },
120+ { MP_QSTR_disable_concurrent_write_protection , MP_ARG_KW_ONLY | MP_ARG_BOOL , {.u_bool = false} },
112121 };
113122
114123 // get the mount point
@@ -118,7 +127,7 @@ mp_obj_t storage_remount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_a
118127 mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
119128 mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
120129
121- common_hal_storage_remount (mnt_str , args [ARG_readonly ].u_bool );
130+ common_hal_storage_remount (mnt_str , args [ARG_readonly ].u_bool , args [ ARG_disable_concurrent_write_protection ]. u_bool );
122131
123132 return mp_const_none ;
124133}
0 commit comments