Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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