As part of its built-in mmap emulation support for "none" file system
services, libfsdriver clears the VM cache upon exit. However, for
trivial file systems which do not even support reading from files, the
the VM cache need to be cleared either. With this patch, the VM cache
is cleared only when modified, so that such trivial file systems need
not be given CLEARCACHE permission.
Change-Id: I518c092443455302b9b9728f10a3f894d2c8036b
#include <minix/ds.h>
#include <sys/mman.h>
+static int fsdriver_vmcache; /* have we used the VM cache? */
+
/*
* Process a READSUPER request from VFS.
*/
fsdriver_mounted = TRUE;
fsdriver_device = dev;
fsdriver_root = root_node.fn_ino_nr;
+ fsdriver_vmcache = FALSE;
}
return r;
fdp->fdr_unmount();
/* If we used mmap emulation, clear any cached blocks from VM. */
- if (fdp->fdr_peek == NULL && major(fsdriver_device) == NONE_MAJOR)
+ if (fsdriver_vmcache)
vm_clear_cache(fsdriver_device);
/* Update library-local state. */
pos, &flags, nbytes, VMSF_ONCE);
if (r == OK) {
+ fsdriver_vmcache = TRUE;
+
dev_off += nbytes;
r = nbytes;