From 03bfe86a6b48339d1ba82cb94bcfb1a2cd4b7f88 Mon Sep 17 00:00:00 2001 From: Luxferre Date: Sun, 21 Dec 2025 11:52:40 +0200 Subject: [PATCH] Added methods for unlocking and relocking rootfs to the ed module --- app/ed.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/ed.py b/app/ed.py index 4f9acac..002f7c7 100644 --- a/app/ed.py +++ b/app/ed.py @@ -1,10 +1,17 @@ # A simple line-oriented text editor for MicroPython/CircuitPython # implementing the POSIX 'ed' subset -# Usage: from app.ed import edit +# Usage: from app.ed import edit, unlock_rootfs, lock_rootfs # Created by Luxferre in 2025, released into public domain from deck.input import input +MCU_STORAGE = False +try: + import storage + MCU_STORAGE = True +except: + pass + class Ed: def __init__(self, filename=None): self.filename = filename @@ -196,6 +203,14 @@ class Ed: except Exception as e: print(f"Exception occurred: {e}") +def unlock_rootfs(): + if MCU_STORAGE: + storage.remount("/", readonly=False) + +def lock_rootfs(): + if MCU_STORAGE: + storage.remount("/", readonly=True) + def edit(fname): editor = Ed(fname) editor.run()