Discard file cache

CyberLeo Kitsana cyberleo at cyberleo.net
Wed Sep 15 20:15:23 UTC 2010


I'm helping port a utility [1] to program the EyeFi card [2] and I seem
to be running into problems properly manipulating the configuration.

The card is programmed by writing encoded commands to certain hidden
files on the card, and reading the coded responses back from other
files. Since the card modifies the data in these files independently of
the host operating system, there is a need to avoid all caching (read
and write) whenever interacting with the card's interface. fsync(2)
works for eliminating write caching, so that's no issue.

While the Linux port of the software successfully accomplishes avoiding
read caching by utilizing posix_fadvise and POSIX_FADV_DONTNEED to clear
the caches for a particular file, the same does not appear to function
on FreeBSD. I have also tried using msync with MS_INVALIDATE, but this
doesn't appear to work either.

Is there an official (or at least consistent) API for discarding a
file's cached read data, so that it may be fetched afresh from the
backing store?


[1] http://git.cyberleo.net/eyefi-config.git
[2] http://www.eye.fi/

Fuzzy love,
Technical Administrator
CyberLeo.Net Webhosting
<CyberLeo at CyberLeo.Net>

Furry Peace! - http://wwww.fur.com/peace/

More information about the freebsd-questions mailing list