summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
authorScott Shawcroft <scott.shawcroft@gmail.com>2017-06-28 16:18:13 -0700
committerScott Shawcroft <scott.shawcroft@gmail.com>2017-06-28 16:18:13 -0700
commit725d715a1bcaa5f7c05fd64c1b9da87768b1cbc0 (patch)
tree256bc14063c3d49a502efd0200dcac7816a7d026 /shared-bindings
parent1e16e813e8f1f4534db75a6cc251ffaef76e2162 (diff)
shared-bindings: Introduce storage.remount() so you can set root as
writeable and prevent USB from editing it.
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/storage/__init__.c17
-rw-r--r--shared-bindings/storage/__init__.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c
index 2b289a11f..b8d3e69fc 100644
--- a/shared-bindings/storage/__init__.c
+++ b/shared-bindings/storage/__init__.c
@@ -101,11 +101,28 @@ mp_obj_t storage_umount(mp_obj_t mnt_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(storage_umount_obj, storage_umount);
+//| .. function:: remount(mount_path, readonly)
+//|
+//| Remounts the given path with new parameters.
+//|
+mp_obj_t storage_remount(mp_obj_t mount_path, mp_obj_t readonly) {
+ if (!MP_OBJ_IS_STR(mount_path)) {
+ mp_raise_ValueError("mount_path must be string");
+ }
+
+ common_hal_storage_remount(mp_obj_str_get_str(mount_path),
+ mp_obj_is_true(readonly));
+
+ return mp_const_none;
+}
+MP_DEFINE_CONST_FUN_OBJ_2(storage_remount_obj, storage_remount);
+
STATIC const mp_rom_map_elem_t storage_module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_storage) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_mount), MP_ROM_PTR(&storage_mount_obj) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_umount), MP_ROM_PTR(&storage_umount_obj) },
+ { MP_OBJ_NEW_QSTR(MP_QSTR_remount), MP_ROM_PTR(&storage_remount_obj) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_VfsFat), MP_ROM_PTR(&mp_fat_vfs_type) },
};
diff --git a/shared-bindings/storage/__init__.h b/shared-bindings/storage/__init__.h
index 806bbc8b3..a5d8d6253 100644
--- a/shared-bindings/storage/__init__.h
+++ b/shared-bindings/storage/__init__.h
@@ -33,5 +33,6 @@
void common_hal_storage_mount(mp_obj_t vfs_obj, const char* path, bool readonly);
void common_hal_storage_umount_path(const char* path);
void common_hal_storage_umount_object(mp_obj_t vfs_obj);
+void common_hal_storage_remount(const char* path, bool readonly);
#endif // __MICROPY_INCLUDED_SHARED_BINDINGS_STORAGE___INIT___H__