> Currently, the "hal" daemon that is responsible for automatically mounting > media is unable to mount read-only SDcard (write protect tab enabled) media, > because it has no way to detect this media needs to be mounted read only. > (hal is implemented with run-time checks for floppy media, and with a hard > coded rule for CDROM media.)
It's been a while since I wrote that HAL code, but just by looking at sd now, it appears that the way to detect write protected media is to attempt to open(2) it for writing. Sd would send the MODE SENSE command and check the WP bit - if set, open would fail with EROFS. I'm not sure why I didn't use that in hald-probe-storage. There might have been undesirable side-effects of opening sd for writing. DKIOCREADONLY has the advantage of being usable even when device is opened read-only, so +1 on the proposal. > Note that sd(7D) does not currently implement this, and will return > an errno (ENOTTY, I believe). sd`sr_check_wp() ? -Artem