LTFS in Go
- Go 97.4%
- Shell 1.6%
- C 0.6%
- Nix 0.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
changer: MOVE MEDIUM slot 1 (element address 1001) -> drive 0 (element address 1):
…/lun=0 is already held on this host by pid 3450648
— a mount holds that drive; unmount it before moving its cartridge
with 3450648 being the changer. Loading a cartridge into a drive refused when the
target exports the drive and the robot together, which is what real libraries do,
and no mount was involved.
flock locks an open file description, not a process: two opens of the same lock file
conflict inside one program. The drive guard needs both opens — the changer holds a
handle on the drive behind the robot to know what the drive holds, and guardMove
takes the same drive's lock to protect the move — so the guard contended with the
command it belongs to and refused it. The message then named our own pid as the
other party, which reads as somebody else's mount.
Take now counts this process's takes per lock file: the second Take joins the first,
the flock drops on the last release, and a release called twice (a deferred one and
an explicit one on the same path) is a no-op rather than a second close. Cross-process
arbitration is untouched — a foreign open description is still refused, and that is
asserted with a raw flock rather than with this package's own bookkeeping.
Also folds the duplicate away at its source: drivesTouchedBy could return the same
drive twice when two element addresses resolve to it, which is ordinary for an
EXCHANGE that runs through one drive, and locking it twice is what the guard did
before this.
The tests had to become honest about what a mount is. Five of them simulated one by
taking the lock again in the test process, which after this change joins the holder
instead of blocking it — and which had always been testing flock's per-description
rule rather than contention between two programs. They now spawn the test binary as a
child that holds the lock until the parent says otherwise (holdprocess_test.go), so
"refuses a load while mounted" refuses what a mount actually refuses: another
process.
|
||
| .pi | ||
| cmd | ||
| docs | ||
| examples/native-read | ||
| internal | ||
| testdata | ||
| tests | ||
| .gitignore | ||
| go.mod | ||
| go.sum | ||
| main | ||
| MEMORY.md | ||
| PLAN.md | ||
| PROGRESS.md | ||
| SCSI_REQ.md | ||
| stage1_mount_trace.log | ||