Hey #Linux #hardware folks out there! I need help with something really, really low-level.
Here my problem: most of Qnap's NAS feature a "copy" button on the front, next to a USB-A port. That button will copy the content of any hard-drive plugged to the USB port next to it.
I want to develop that feature for Linux. But I'm having troubles finding a way to reliably associate that port and the storage that's plugged on it and I wonder how the Qnap OS does that.
Any idea?
@gregkh Hi! I'm really sorry to mention you out of the wild like that. I saw that you were active here. I just out of option about the problem in the previous post. I need to find someone how knows the kernel enough to help me. Do you know a piece of documentation that would help me understand how to associate a particular USB port with the storage that's plugged on it?
gregkh@social.kernel.org Hi! I'm really sorry to mention you out of the wild like that. I saw that you were active here. I just out of option about the problem in the previous post. I need to find someone how knows the kernel enough to help me. Do you know a piece of documentation that would help me understand how to associate a particular USB port with the storage that's plugged on it?
@AugierLe42e Pardon my ignorance but are there other USB ports or rather other disks that may be plugged to a USB port on the QNAP ?
@AugierLe42e
Analyse dmesg/lsblk/lsusb to identify the last connected device?
@llutz Not reliable. The port under /sys/device changes based on whether the peripheral is USB2 or 3 so what else could it make that vary?
@gregkh Hi! Thank you for responsping me. I investigated that solution 2 days ago (see the stackoverflow question). What I found is that the disk will appear under différent hubs between USB2 and 3, but except for that, the result seems pretty consistent. If I write a udev rule based on those findings, do I have the guarantee that it will always work for all the machines of the same model?
@gregkh FYI, here is the udev rule I wrote based on these findings:
SUBSYSTEM=="block", KERNELS=="1-4|2-4", SUBSYSTEMS=="usb", ENV{DEVTYPE}=="disk", SYMLINK+="qnap-one-touch-copy"
@gregkh Alright, thank you very much for answering me.