Conversation

Hey 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?

4
0
0

@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?

1
0
0

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?

0
0
0

@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 ?

0
0
0

@AugierLe42e
Analyse dmesg/lsblk/lsusb to identify the last connected device?

1
0
0

@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?

0
0
0
@AugierLe42e Look at how the "port" is found when you do something like 'lsusb -t', I think that should help out here. Good luck!
1
0
0

@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?

2
0
0

@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"

0
0
0
@AugierLe42e Hopefully yes, but it depends on the firmware on the hub itself, it's not under control of the operating system at all.
1
0
1

@gregkh Alright, thank you very much for answering me.

0
0
0