Reconciler: uid/gid and ntfsfix for NTFS secondary mounts.

QA on 10.0.0.8 (mount-issues.md findings 2 and 3) showed the reconciler
path missed both NTFS accommodations that mount_drive() and
add_fstab_entry() already have: secondary NTFS drives mounted owned by
root (writable only via ntfs-3g's permissive default), and a dirty NTFS
volume would fail to mount at boot with no cleanup attempted.

Inject uid/gid for ntfs/ntfs3 in the reconciler, and run ntfsfix -d in
SubprocessMountExecutor before NTFS mounts (translating UUID=/LABEL=
specs to /dev/disk/by-* paths, which ntfsfix needs).  Also return an
error MountResult instead of raising when a binary is missing, per the
executor protocol.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Roland 2026-07-06 16:52:11 -06:00
parent 9f2d9ed82b
commit 910503b641
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
4 changed files with 102 additions and 3 deletions

View file

@ -59,6 +59,18 @@ class MountExecutor(Protocol):
MOUNT_TIMEOUT_SECONDS = 30
def _device_path(device: str) -> str:
"""Translate a UUID=/LABEL= mount spec to a real device node.
mount(8) resolves these specs itself, but tools like ntfsfix need a
path. udev maintains the by-uuid/by-label symlinks."""
if device.startswith("UUID="):
return f"/dev/disk/by-uuid/{device[len('UUID='):]}"
if device.startswith("LABEL="):
return f"/dev/disk/by-label/{device[len('LABEL='):]}"
return device
class SubprocessMountExecutor:
"""Executes mount/umount via subprocess and parses /proc/mounts."""
@ -72,6 +84,17 @@ class SubprocessMountExecutor:
fstype: str,
options: str,
) -> MountResult:
# NTFS volumes are frequently left "dirty" (Windows Fast Startup, or
# an unclean unplug), which makes the driver refuse to mount them.
# ntfsfix -d clears the dirty flag and replays the journal; it is a
# no-op on clean volumes. Never fatal: the mount below reports the
# real error. Matches mount_drive() in lib/disks.py.
if fstype in ("ntfs", "ntfs3"):
fix = self._run(["ntfsfix", "-d", _device_path(device)],
label=f"ntfsfix {device}")
if not fix.ok:
logger.warning("ntfsfix failed for %s (mount will still be attempted): %s",
device, fix.error)
cmd = ["mount", "-t", fstype, "-o", options, device, mount_point]
return self._run(cmd, label=f"mount {device} {mount_point}")
@ -104,6 +127,10 @@ class SubprocessMountExecutor:
ok=False,
error=f"{label}: timed out after {self._timeout}s",
)
except OSError as e:
# e.g. FileNotFoundError for a missing binary — the executor
# protocol forbids raising for I/O failures.
return MountResult(ok=False, error=f"{label}: {e}")
if result.returncode != 0:
return MountResult(
ok=False,