I wonder why there are so few usb flash drives that have a physical "read only" lock.
That was so useful to defend against viruses.
A cheap flash drive will cost say 15 dollars and one with a physical button/lock to make it read only will be 150?
The cost of materials should be maybe 5 more dollars...
On a side note, if you go into one of those "print shops" that can print things for you and use an USB stick, then how can you sanitize your stick from the multiple viruses / worms that you will get?
Only thing that comes to my mind is to use a computer where the hard drives are physically disconnected and some live CD linux. But even then it is unclear if you can really format the usb flash memory to make it safe.
If you're on top of an OS, I can't say (depends on the OS)... but reading the switch is the responsibility of the reader, not the card. The card has no idea if it's write-protected (by the switch mechanism) or not. [1]
Just using the same SPI operations you always use for write should work fine. There's not even a lock-status register or anything to check/clear first for the switch mechanism.
Perhaps it's not within the capabilities provided by the OS or the driver, because they're "well behaved", but the position of the switch is in essence a boolean sent to the host device and not a barrier to electrical signals that would write data.
If you zero the USB drive out using `dd` or other equivalent tool that literally writes zeroes to each LBA, its safe. To avoid excessive wear and tear you can really just get away with zeroing the first couple MBs - without a valid partition table or recognized file system, no OS will do anything when it's plugged in other than ask you to format it.
That was so useful to defend against viruses.
A cheap flash drive will cost say 15 dollars and one with a physical button/lock to make it read only will be 150?
The cost of materials should be maybe 5 more dollars...
On a side note, if you go into one of those "print shops" that can print things for you and use an USB stick, then how can you sanitize your stick from the multiple viruses / worms that you will get? Only thing that comes to my mind is to use a computer where the hard drives are physically disconnected and some live CD linux. But even then it is unclear if you can really format the usb flash memory to make it safe.