I have an embedded device with a flash memory running linux. I want to do raw read writes on the flash part but I also want to avoid any file system cache. How can I do this? Any pointers?


If the flash has a filesystem on it and you just want to open a file but bypass the cache for IO to that file, then open it with the O_DIRECT flag. If it has no filesystem on it, then you just open the block device directly.


I think you want the O_DIRECT flag to open(). Be aware that it may not work as expected on the filesystem on your flash device. Also, I am assuming you are using a filesystem, and not reading a device file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.