How can I prevent linux from initializing a USB HID device
you have right, you have to play with the udev rules.
First of all you have to identify your device. Find the idProduct and the idVendor of your device. You can use:
lsusb
Then in the rules.d folder (/etc/udev/rules.d) create a new file with the name:
10-my-usb.rules
In this file add this line
SUBSYSTEM=="usb",ATTRS{idVendor}=="XXXX", ATTRS{idProduct}=="XXXX", MODE="666", GROUP+="plugdev"
Replace the XXXX with the value you get before
Then restart your udev rules:
sudo udevadm trigger
Then unplug and replug normally you can use it
Prevent usbhid from autoloading when USB HID device is plugged in
udev is the best and easiest way doing that, add a new rule in e.g.:
/etc/udev/rules.d/99-disable-usb-hid.rules:
SUBSYSTEMS=="usb", DRIVERS=="usbhid", ACTION=="add", ATTR{authorized}="0"
and restart udev.
I've just tested it in Debian Jessie ARM 4.4.16.
How could be notified once USB device is attached/detached in linux system and read the file from USB
I'd add udev rule first with running your custom script. Something like:
ACTION=="add", KERNEL=="sd?1", SUBSYSTEMS=="usb", RUN+="/path/to/your/script %k"
%k
is kernel parameter that is passed to your script.
From udev man:
$kernel, %k
The kernel name for this device.
In the script I'd use curl
. If you don't need some tricky logic. If so, I'd use python.
Anyway I think udev is perfect for this problem.
Related Topics
Does a Fully Qualified Domain Name Need a Period
Running Shell Script After Boot on Raspberry Pi
List of Synchronous and Asynchronous Linux/Posix Signals
Why Cannot I Directly Compare 2 Thread Ids Instead of Using Pthread_Equal
Boost Asio with Ecdsa Certificate Issue
Jmp Unexpected Behavior in Shellcode When Next(Skipped) Instruction Is a Variable Definition
Jmeter:Difference Between Jmeter.Sh and Jmeter Without Extension File in Jmeter
How Does Linux Handles The I/O Permission Bitmap in The Tss Structure
Gatttool: Limited to 5 Connections
Kernel Module Build Fails: Sys/Types.H: No Such File or Directory
Autostart Javafx Application on Raspberrypi
Mount -T Cifs Works on One Version of Linux But Not Another
In Gitlab Ci The Gitlab Runner Choose Wrong Executor
Data Pointers in Inode Data Structure