Hi,
I'd like to know how an application program running as root can detect if a USB flash drive is write protected. I am using kernel 2.6.8. When I plug in a write protected USB flash drive I see messages on the console indicating that it is write protected, but I am able to successfully mount the flash drive as rw and open a file for writing without getting an error for either of these. If the file is small I don't see an error message on the console until I close the file. For larger files the error messages appear on the console when the buffer is flushed.
What I'd like to be able to do is use a system call or ioctl to determine if the USB flash drive is write protected and then display an error dialog on the screen, but I haven't been able to find anything related to this on the internet.
I'd also like to be able to detect when the USB flash drive is removed without it having been unmounted so that I can warn the user of what was done.
If it matters the embedded system I am programming is running an ARM
920T processor with a Phillips ISP1362BD USB contoller chip.Any help will be greatly appreciated.