Only one side may write the mounted image or the /data partition at a time,
and uploaded images are validated before they are stored.
Image mounts:
* Serve every mounted image read-only, in CD-ROM and mass storage mode alike:
detach the LUN first and set the read-only flag before the image is
attached, so the target machine can neither write to nor format it. The
flags were previously only written for CD-ROM mounts, so a mass storage
mount inherited ro=0 and the image stayed writable from the host.
* Report the virtual disk as on only while the LUN really carries the /data
partition. With an image mounted the switch used to stay active but
unchangeable, and enabling the disk is now a confirmed action instead of a
rejected one: it cancels the mounted image, and the confirm also warns that
the image download is interrupted because /data becomes read-only here.
* Ask before mounting: the image list warns that the virtual disk is released
for the image, or offers to enable it first when it is off, instead of
dropping the /data share silently. The new strings are translated for every
locale.
* Name the mounted medium and the USB device after the image file, cut to the
16 bytes of the SCSI inquiry product field and the 126 bytes of the USB
product string, and restore the previous names on unmount.
* Reset the LUN flags on every gadget restart. They survived a restart, so
the shared partition came back to the host read-only, or as an optical
drive, after an image had been mounted.
The /data handover:
* Mount /data read-only at boot whenever the virtual disk serves the raw
partition as a writable disk, so the handover holds from the first boot on.
* Add SetDataWritable(), which remounts /data and verifies the new state.
Enabling the virtual disk makes /data read-only before the host can write
it, and refuses to expose the disk when the remount fails instead of taking
the risk. Unmounting an image, which hands the raw partition back to the
host, does the same, while mounting an image switches /data back to
writable because a served image is read-only for the host.
* Cancel a running image transfer before the handover and wait for it to
stop, and report the state in the image list, where mounting still works
while deleting and uploading do not. The delete action is disabled with a
hint, and the downloader offers to turn the virtual disk off.
Image uploads:
* Validate the volume descriptors while streaming, so an unusable image is
rejected in seconds instead of after the whole transfer: accept ISO 9660 and
UDF volume descriptors (CD001, BEA01) as well as raw disk images (GPT, APFS,
HFS+, MBR), and reject anything else. Require the image to fit in /data with
a 128 MiB reserve before any of it is received, log the underlying errors on
the rejection paths, and keep the temporary file, the progress ticker and the
close handling in defers.
Add unit tests for the upload header check, the free space preflight and the
image name truncation.
* Add ability to properly configure logrus (e.x. specify output file)
* Make the code slightly more ideomatic (sort imports, etc)
* Replace some of the shell calls with equivalent native code
* Fix update process
* Improve error handling (handle 2 previously unhandled errors)
* Add locking for HID operations and make a HID-operations struct a singleton