fix(diskctl): list mounted drives even without write access - #3380
fix(diskctl): list mounted drives even without write access#3380JamBalaya56562 wants to merge 8 commits into
Conversation
5337664 to
8be9021
Compare
Marijn0
left a comment
There was a problem hiding this comment.
A mounted USB/flash drive is now offered as a storage device even when the motion user can't (yet) write to it. Previously only "Custom Path" was selectable for such drives.
In my opinion, there should be some form of indication that a drive is not writable by the motion user (or whichever user is running the motionEye/Motion service). Otherwise, users may select it as their storage location without understanding why Motion fails to write any files.
8be9021 to
5912e6b
Compare
|
Good point — added in 1d435c2.
Two notes:
|
0fb3562 to
85f343a
Compare
Marijn0
left a comment
There was a problem hiding this comment.
Looks good now.
I cleaned up a few things and made some small changes; I hope that is okay.
What we are achieving here is that mounts which are detected but are not writable by the user running motionEye/motion are now shown to the user. This makes it clear that the mounts are available but cannot be used for storage until the appropriate write permissions are configured.
And for that use case, I think it looks good. Thanks!
zagrim
left a comment
There was a problem hiding this comment.
Looks good to me. I span it up for a quick test run in my dev env and indeed got some mounts listed with "[No write access]". So all good in the scope of the fix, I think.
|
However, I noticed that I only got a list of non-RAID mounts for local disks, but not any of the mounted RAID arrays or network shares. I guess omission of the latter might be intentional (and can always by used by chosing "Custom Path"), but why wouldn't the RAID array mounts show 🤔 Anyway, the RAID arrays are listed just like the non-RAID mounts in the content of The RAID arrays are also found by However, these RAID arrays do not fit the idea of "disks containing partitions" that (I redacted lines with MD array names as well as lines with ATA devices named after the device properties, both are essentially duplicates for the lines with plain IDs that are shown above) Anyway, this is something that is better fixed separately to keep things organised and clear, I'll try to check if there's already an issue for this and will create one in case there isn't one yet. Edit: issue created: #3393 |
A mounted USB/flash drive was not offered as a storage device (only "Custom Path" was selectable) when the motion user could not write to it. _list_mounts() skipped any mount failing os.W_OK, so the drive looked unrecognised even though it appeared in fdisk and /dev/disk/by-id. Drop the write-access filter so the drive is listed; granting the motion user write access to it is the remaining (OS-level) step. Reproduced and diagnosed by a maintainer in the issue. Closes motioneye-project#3024 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Per @Marijn0's review: a non-writable drive is now listed, but a user could pick it and not understand why Motion fails to store any media. diskctl._list_mounts now reports a `writable` flag (os.W_OK), and the storage-device dropdown appends a "[ne skribebla]" (not writable) marker to such drives so the limitation is visible. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
85f343a to
6669a4f
Compare
There was a problem hiding this comment.
Pull request overview
This PR adjusts disk/mount discovery so mounted removable drives are surfaced in the UI even when the running user lacks write permissions, addressing cases where such drives previously didn’t appear as selectable storage devices.
Changes:
- Remove the write-access filter in
diskctl._list_mounts()and instead expose a per-mountwritableflag. - Update the storage-device dropdown rendering to display a “no write access” hint for unwritable mounts.
- Add unit tests to lock in the new mount-listing behavior and existing bind-mount de-duplication.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
motioneye/controls/diskctl.py |
Stops filtering mounts by os.W_OK and adds a writable field to mount metadata. |
motioneye/static/js/main.js |
Renders unwritable mounts with a label hint and adjusts option creation logic. |
tests/test_diskctl.py |
Adds coverage for including unwritable mounts and still de-duplicating bind mounts. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
A selected-but-disabled storage_device option reads back as null via jQuery's .val(), crashing the backend on save. Add a validator that flags the field invalid whenever the selected option is disabled, with an ignoreVisibility flag on makeCustomValidator since the storage section is by default collapsed but still relevant.
|
Added a validator on Should now be fine to merge from my side. 😃 |
|
Thank you @Marijn0, this is a great addition. 🙏 I reviewed both commits and they look correct to me. The flow is now: unwritable drives stay listed and the existing selection is kept, and the user gets a clear warning on Apply if their storage location isn't writable. Fine to merge from my side too — thanks again for pushing this over the line! |
What
A mounted USB/flash drive is now offered as a storage device even when the
motionuser can't (yet) write to it — but it's shown as disabled with a "No write access" hint, rather than being silently omitted. Previously such a drive was invisible and only "Custom Path" was selectable.Why
diskctl._list_mounts()skipped every mount that failedos.access(mount_point, os.W_OK). A drive mounted but owned byroot(so not writable by themotionuser) was therefore filtered out and never appeared in the storage-device dropdown — it looked unrecognised, even though it showed up infdiskand/dev/disk/by-id/.@MichaIngreproduced this and pinpointed the write-access filter as the cause in #3024.How
Drop the
os.W_OKfilter in_list_mounts(); instead, tag every mount with awritableflag (os.access(mount_point, os.W_OK)).list_mounted_disks()already cross-references_list_disks()(real block devices from/dev/disk/by-idorfdisk -l), so this only surfaces genuine mounted partitions, not virtual/system mounts likeproc/tmpfs.In the UI, a non-writable drive is now listed with a "[No write access]" label but rendered as a disabled
<option>, so it cannot actually be selected as the storage device. Making it selectable was deliberately avoided — picking a drive themotionuser can't write to would silently point a camera's target directory at a location where writes fail. Granting themotionuser OS-level write access to the drive is the remaining step to actually use it; this PR only makes that limitation visible instead of hiding the drive entirely.Testing
tests/test_diskctl.py: asserts_list_mounts()still returns a mount whenos.accessreports no write permission, but flags itwritable: False(locks in the fix), and still de-duplicates bind mounts.ruff check/ruff format --checkpass.Closes #3024