mountpoint detection: wrong marker path, and requestedCount stops one short #6

Open
opened 2026-08-30 13:34:22 +02:00 by clawbot · 0 comments

Two defects in findDCFMountPoints (pkg/dcf/helpers.go), found while bringing the repo to standards. Both predate that work and its PR leaves the behaviour exactly as it was, because deciding either is a behaviour change rather than a lint fix.

1. The marker directory checked is M4ROOT, not PRIVATE/M4ROOT.

The original code computed filepath.Join(mountpoint, "PRIVATE") and then immediately overwrote it with filepath.Join(mountpoint, "M4ROOT"), so only the second was ever stat'd. That dead store was a lint finding and had to go; the surviving check is the one that was live, so a Sony card is detected only if it happens to have M4ROOT at the filesystem root. README and the spec both say the directory is PRIVATE/M4ROOT.

2. requestedCount returns one fewer store than asked for.

The loop breaks on len(filteredMountpoints)+1 >= requestedCount, so requestedCount == 2 returns 1 store and requestedCount == 3 returns 2. Only requestedCount == 1 and 0 (all) behave as documented.

Both want a decision about intended behaviour, plus a test each.

Two defects in `findDCFMountPoints` (`pkg/dcf/helpers.go`), found while bringing the repo to standards. Both predate that work and its PR leaves the behaviour exactly as it was, because deciding either is a behaviour change rather than a lint fix. **1. The marker directory checked is `M4ROOT`, not `PRIVATE/M4ROOT`.** The original code computed `filepath.Join(mountpoint, "PRIVATE")` and then immediately overwrote it with `filepath.Join(mountpoint, "M4ROOT")`, so only the second was ever stat'd. That dead store was a lint finding and had to go; the surviving check is the one that was live, so a Sony card is detected only if it happens to have `M4ROOT` at the filesystem root. README and the spec both say the directory is `PRIVATE/M4ROOT`. **2. `requestedCount` returns one fewer store than asked for.** The loop breaks on `len(filteredMountpoints)+1 >= requestedCount`, so `requestedCount == 2` returns 1 store and `requestedCount == 3` returns 2. Only `requestedCount == 1` and `0` (all) behave as documented. Both want a decision about intended behaviour, plus a test each.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/dcf#6