Fix dashcam mount-point creation permission error

mount_device() used a bare os.makedirs() to create the mount point,
but the app runs as an unprivileged user while /mnt is root-owned -
surfaced as a real PermissionError during the first actual hardware
test. Create the mount point via sudo mkdir -p instead, consistent
with the existing sudo mount/umount calls in this module.

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Mathieu Moran
2026-08-08 20:52:15 -04:00
co-authored by Copilot
parent acaf1747f3
commit 833f008671
+18 -2
View File
@@ -108,8 +108,24 @@ def find_dashcam_partition():
def mount_device(device_path, mount_point=DEFAULT_MOUNT_POINT):
"""Mount device_path read-only at mount_point. Returns True on success."""
os.makedirs(mount_point, exist_ok=True)
"""Mount device_path read-only at mount_point. Returns True on success.
The app runs as an unprivileged user while /mnt is root-owned, so the
mount point directory itself has to be created via sudo too (not just
the mount call) - first real-hardware test surfaced this as a plain
PermissionError from a bare os.makedirs().
"""
try:
subprocess.run(
["sudo", "mkdir", "-p", mount_point],
capture_output=True,
text=True,
check=True,
)
except subprocess.CalledProcessError as e:
print(f"Failed to create mount point {mount_point}: {e.stderr.strip()}")
return False
try:
subprocess.run(
["sudo", "mount", "-o", "ro", device_path, mount_point],