How to determine if USB flash drive is write protected
I have an application running on an embedded computer. The user may plug in a USB flash memory and try to access it. I would like to give an error message immediately if the user tries to write to a write-protected memory, but haven't figured out how. For example, I tried
Code:
i = open(file_name, O_WRONLY | O_CREAT | O_SYNC); It's an older computer, so it has Linux kernel 2.4.26 with libc 2.3.2. |
Hi there,
Quote:
Anyway, I usually check if the result of fopen() is non-zero to proceed normally. [X] Doc CPU |
Quote:
Quote:
It turns out I misremembered my own code. I'm actually writing the files to a temporary ram disk and then upon getting the "finish" command from the user, I do Code:
sprintf(buf, "mv /tmp/tmpmidi.mid %s", file_name); I do it this way because I don't want any flash activity while I'm recording a MIDI file. |
All times are GMT -5. The time now is 06:24 AM. |