https://bugs.winehq.org/show_bug.cgi?id=49788
--- Comment #6 from TasosSah winebugzilla@tasossah.com --- A few notes. It's not as easy as I thought to get the sg path from /sys/bus/scsi.
At first I assumed there would be a symlink to it, but this did not seem to be the case. It is possible to parse /sys/bus/scsi/devices/xx:0:x:0/generic/uevent to extract the DEVNAME=sgX, which doesn't seem like a great idea.
One could otherwise call readlink on /sys/bus/scsi/devices/xx:0:x:0/generic which is a symlink to a path that contains "sgX" in its name, but this is quite a terrible idea in my opinion, since we'd need to parse the path returned.
At that point, I assumed I could use libudev to go through all the devices and add a match for scsi bus, target id, and logical unit, but it appears udev did not have this information. (Checked using udevadm info -a /sys/devices/platform/[...]/scsi_generic/sgX, which is the path returned when adding a udev enum match for the scsi_generic subsystem.)
I resorted to building the path manually and calling udev to return the sgX path. Perhaps there is a better way to do this, but I was not successful in finding it.