PiSCSI / piscsi

PiSCSI allows a Raspberry Pi to function as emulated SCSI devices (hard disk, CD-ROM, and others) for vintage SCSI-based computers and devices. This is a fork of the RaSCSI project by GIMONS.
https://piscsi.org
BSD 3-Clause "New" or "Revised" License
545 stars 82 forks source link

INQUIRY Product string too long for image size >9999MiB #1146

Closed rdmark closed 1 year ago

rdmark commented 1 year ago

We generate too long a generic INQUIRY Product string for image sizes larger than 9999MiB

Apr 19 18:19:28 rasp32 PISCSI[2604]: [2023-04-19 18:19:28.057] [info] Validating: operation=ATTACH, command params='locale=en', 'token=???', device id=6, lun=0, type=SCHD, device params='file=10000.hds', vendor='', product='', revision='', block size=0
Apr 19 18:19:28 rasp32 PISCSI[2604]: terminate called after throwing an instance of 'std::invalid_argument'
Apr 19 18:19:28 rasp32 PISCSI[2604]:   what():  Product 'SCSI HD 10000 MiB' must be between 1 and 16 characters
Apr 19 18:19:28 rasp32 systemd[1]: Started Process Core Dump (PID 2660/UID 0).
Apr 19 18:19:28 rasp32 systemd-coredump[2661]: [🡕] Process 2604 (piscsi) of user 0 dumped core.

                                               Stack trace of thread 2606:
                                               #0  0x0000000076900420 __GI_raise (libc.so.6 + 0x2e420)
                                               #1  0x00000000768e9364 __GI_abort (libc.so.6 + 0x17364)
                                               #2  0x0000000076b41f88 _ZN9__gnu_cxx27__verbose_terminate_handlerEv (libstdc++.so.6 + 0x7ff88)
rdmark commented 1 year ago

The capacity part of the string is generated in https://github.com/PiSCSI/piscsi/blob/8dd5071122b31fd0418f67c3816b4f086bbe88c2/cpp/devices/scsihd.cpp#L34

What seems to be the problem is that the 10 GB conditional checks against 1 TB (1'099'511'627'776 bytes). I think the correct check should be 10,737,418,240 bytes.

rdmark commented 1 year ago

I think the sweet spot is to display MiB unit up to 9999MiB, then switch to GB from 10485760000 bytes onwards (10,000MiB).

rdmark commented 1 year ago

PR in https://github.com/PiSCSI/piscsi/pull/1147

rdmark commented 1 year ago

This issue would still occur with >9TB image files, but as per Eric: 2tb is the biggest scsi-2 32bit lba can address