Detecting a USB device which is write protected
Hi,
I would like to display a message to the user if he plugs in a write protected flash drive. Is there any linux command that I can use to detect a write protected USB device. I do not want to use "dmesg" and poll for the device. Please help. |
I believe that if you remove the operator from plugdev in /etc/group it stops access.
|
I don't have any write protect-able USB sticks so I couldn't test to see how they'd appear.
What I can say is that a USB thumb stick on my system appears in the /sys/block hierarchy and in viewing the "ro" file, it shows zero. Since my stick is read-write, then my assumption is that this file would show a one if the stick were read-only; a.k.a. write-protected. Code:
cd /sys/block/sdf |
All times are GMT -5. The time now is 04:40 PM. |