LTFS in Go
  • Go 97.4%
  • Shell 1.6%
  • C 0.6%
  • Nix 0.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
ltfs-go 3d63a980ca A command must not be refused by itself: the robot locked its own drive
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.
2026-11-20 14:59:45 -08:00
.pi Fix non-persistent inodes 2026-11-20 00:19:43 -08:00
cmd A failed open must leave the device interface nil, or teardown crashes 2026-11-20 14:15:55 -08:00
docs A command must not be refused by itself: the robot locked its own drive 2026-11-20 14:59:45 -08:00
examples/native-read Device lock, /stats endpoint, native read API example + docs 2026-10-27 14:33:12 -07:00
internal A command must not be refused by itself: the robot locked its own drive 2026-11-20 14:59:45 -08:00
testdata Added dynamic timeout discover 2026-11-02 13:15:23 -08:00
tests Fix non-persistent inodes 2026-11-20 00:19:43 -08:00
.gitignore Anchor ltfs-crosscheck gitignore to repo root only 2026-10-15 11:29:44 -07:00
go.mod changertui: the library as a grid, and moves you have to mean 2026-10-27 16:57:24 -07:00
go.sum changertui: the library as a grid, and moves you have to mean 2026-10-27 16:57:24 -07:00
main blockdev,ltfs-mount: write-rate pacing (-write-rate) 2026-11-17 21:15:03 -08:00
MEMORY.md Fix non-persistent inodes 2026-11-20 00:19:43 -08:00
PLAN.md Encryption plan 2026-11-16 11:28:36 -08:00
PROGRESS.md Fix non-persistent inodes 2026-11-20 00:19:43 -08:00
SCSI_REQ.md Add SCSI_REQ.md: SCSI command requirements for the iSCSI tape transport 2026-10-15 12:07:20 -07:00
stage1_mount_trace.log Stage 1: LTFS layout investigation — MEMORY.md, traces, test volume 2026-10-14 21:21:44 -07:00