Added methods for unlocking and relocking rootfs to the ed module

This commit is contained in:
Luxferre
2025-12-21 11:52:40 +02:00
parent 4dccbd87de
commit 03bfe86a6b
+16 -1
View File
@@ -1,10 +1,17 @@
# A simple line-oriented text editor for MicroPython/CircuitPython # A simple line-oriented text editor for MicroPython/CircuitPython
# implementing the POSIX 'ed' subset # 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 # Created by Luxferre in 2025, released into public domain
from deck.input import input from deck.input import input
MCU_STORAGE = False
try:
import storage
MCU_STORAGE = True
except:
pass
class Ed: class Ed:
def __init__(self, filename=None): def __init__(self, filename=None):
self.filename = filename self.filename = filename
@@ -196,6 +203,14 @@ class Ed:
except Exception as e: except Exception as e:
print(f"Exception occurred: {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): def edit(fname):
editor = Ed(fname) editor = Ed(fname)
editor.run() editor.run()