amiaopensource / ltopers

Bash scripts to manage LTO cartridges with LTFS
https://github.com/amiaopensource/ltopers
MIT License
39 stars 8 forks source link

fix barcode extraction #190

Closed retokromer closed 5 years ago

retokromer commented 5 years ago

should resolve https://github.com/amiaopensource/ltopers/issues/189 (untested!)

cc @DK10101

DK10101 commented 5 years ago

Thanks for that Reto, it worked just fine for me now. At least I now know thatI'm dealing with a damaged tape.

Cheers.

$ ./mountlto Checking for ready tapes... Checking for tape barcode. Deck 0 found with tape AAL216 MOUNTING TAPE : THE TAPE WILL MOUNT TO THE /Volumes/AAL216 FOLDER MOUNTING TAPE : AFTER MOUNT PRESS CONTROL-C$ TO EJECT mkdir: /Volumes/AAL216: Permission denied 307 LTFS14000I LTFS starting, LTFS version 2.4.0.2 (10071), log level 2. 307 LTFS14058I LTFS Format Specification version 2.4.0. 307 LTFS14104I Launched by "ltfs -f -o work_directory=/Users/editor/Documents/lto_indexes -o eject -o noatime -o capture_index -o devname=0 -o volname=AAL216 -o uid=502 /Volumes/AAL216". 307 LTFS14105I This binary is built for Mac OS X . 307 LTFS14106I GCC version is 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66)). 307 LTFS17087I Kernel version: Darwin Kernel Version 17.5.0: Mon Mar 5 22:24:32 PST 2018; root:xnu-4570.51.1~1/RELEASE_X86_64. 307 LTFS14063I Sync type is "time", Sync time is 300 sec. 307 LTFS17085I Plugin: Loading "iokit" tape backend. 307 LTFS17085I Plugin: Loading "unified" iosched backend. 307 LTFS30810I Opening a device through iokit driver (0). 307 LTFS30814I Vendor ID is IBM . 307 LTFS30815I Product ID is 'ULTRIUM-HH6 '. 307 LTFS30816I Firmware revision is JAX1. 307 LTFS30817I Drive serial is 10WT135434. 307 LTFS17160I Maximum device block size is 1048576. 307 LTFS11330I Loading cartridge. 307 LTFS30854I Logical block protection is disabled. 307 LTFS11332I Load successful. 307 LTFS17157I Changing the drive setting to append-only mode. 307 LTFS11005I Mounting the volume. 307 LTFS30854I Logical block protection is disabled. 307 LTFS17227I Tape attribute: Vendor = IBM . 307 LTFS17227I Tape attribute: Application Name = LTFS . 307 LTFS17227I Tape attribute: Application Version = 2.4.0.2 . 307 LTFS17227I Tape attribute: Medium Label = AAL216. 307 LTFS17228I Tape attribute: Text Localization ID = 0x81. 307 LTFS17227I Tape attribute: Barcode = AAL216 . 307 LTFS17227I Tape attribute: Application Format Version = 2.4.0 . 307 LTFS17228I Tape attribute: Volume Lock Status = 0x00. 307 LTFS17227I Tape attribute: Media Pool name = . 307 LTFS14111I Initial setup completed successfully. 307 LTFS14112I Invoke 'mount' command to check the result of final setup. 307 LTFS14113I Specified mount point is listed if succeeded. 307 LTFS14029I Ready to receive file system requests.

retokromer commented 5 years ago

At least I now know thatI'm dealing with a damaged tape.

@DK10101 Are you sure? You could try to re-format the cartridge.

DK10101 commented 5 years ago

Thankfully yes, after successfully reformatting the tape I've been able to write to it using ltopers.

retokromer commented 5 years ago

Glad it worked out. Thank you for reporting back!

retokromer commented 5 years ago

Good point, @dericed, thank you very much! (Now it matches too much and I will try another time to restrict it to valid values only.)

retokromer commented 5 years ago

@dericed This regex would match only valid barcodes

\b[A-Z0-9]{6}\b|\b[A-Z0-9]{6}L[5-8]\b|\b[A-Z0-9]{6}M8\b

which can possibly be written… more elegantly.

dericed commented 5 years ago

True, but this would need to be maintained, whereas current mountlto regex would survive (likely) upcoming generations.

retokromer commented 5 years ago

Indeed, as it needs to be maintained in the other scripts as well… We could made all scripts accepting length of 6 or 8 without checking that the length 8 is a possible one. Should I open a PR for this?

retokromer commented 5 years ago

A nicer regex for the actual test would probably be

\b[A-Z0-9]{6}(L[5-8]|M8)?\b

(untested).