Skip to content

Fix inverted status checks in the SCSI tape backends#610

Open
matejk wants to merge 2 commits into
LinearTapeFileSystem:mainfrom
matejk:fix/scsi-backends
Open

Fix inverted status checks in the SCSI tape backends#610
matejk wants to merge 2 commits into
LinearTapeFileSystem:mainfrom
matejk:fix/scsi-backends

Conversation

@matejk

@matejk matejk commented Jun 12, 2026

Copy link
Copy Markdown

Two fixes for inverted result handling:

  • Drive encryption detection: is_ame and sg_set_key treated a successful MODE SENSE as a failure, so encryption setup could fail even on drives that pass the capability check.
  • iokit_set_xattr (macOS): reported success as failure.

Related to #498: this corrects the MODE SENSE handling on the encryption path, but does not change the drive-capability rejection in is_encryption_capable that the issue also discusses, so it is not marked as fixing it.

matejk added 2 commits June 17, 2026 22:06
sg_modesense returns the transferred byte count (> 0) on success, but
is_ame and sg_set_key compared the result against 0/DEVICE_GOOD. is_ame
therefore always reported the drive as non-AME, and sg_set_key bailed
out before issuing SECURITY PROTOCOL OUT, so setting a data key always
failed on encrypting drives. Compare against < 0 like the other
sg_modesense callers, and normalize sg_set_key's success return.

Not verified on encrypting tape hardware; the logic follows the
documented sg_modesense return convention.
The function collected DEVICE_GOOD in ret when one of the vendor
attributes matched, but returned the hardcoded initial error, so every
successful set was reported as -LTFS_NO_XATTR. Return ret, matching
the sg backend. Found by -Wunused-but-set-variable.

Also remove two write-only variables in the same file.
@matejk matejk force-pushed the fix/scsi-backends branch from a27de2b to 4224ef2 Compare June 17, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant