Results 1 to 2 of 2
In my programe, I need mount hotplug device,for example,U Disk, SD card.
In the case of don't know the device can write, I use like "mount -w" command to mount ...
- 10-08-2011 #1Just Joined!
- Join Date
- Sep 2011
- Posts
- 2
In the case of don't know the device can write, how to mount device
In my programe, I need mount hotplug device,for example,U Disk, SD card.
In the case of don't know the device can write, I use like "mount -w" command to mount the device, the mount will be failed,
error message:block device /dev/sda1 is write-protected but explicit `-w' flag given.
I don't know how to know whether the device is readalbe or writable before I mount the device.
- 10-10-2011 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Usually, mounting the device without options will figure out if it is readable/writable or whatever and do the right thing. Example, assuming that an sd card is registered as /dev/sdn and it has a partition as /dev/sdn1, and the sd card has its write-protect switch enabled, then then command "mount /dev/sdn1 mountpoint" should 1) detect what file system it uses (probably fat or fat32), 2) determine that it is read-only, and 3) mount it on the mountpoint as a read-only file system that you can read from, but not write to.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote