From 0a2a08739e5ee13a20ba5d874beca4958a42cb49 Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Mon, 22 Jun 2015 11:50:04 +0000 Subject: [PATCH] libfsdriver: clear VM cache only if used 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 --- minix/lib/libfsdriver/call.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/minix/lib/libfsdriver/call.c b/minix/lib/libfsdriver/call.c index 6b0e78ddb..f7bb9e50a 100644 --- a/minix/lib/libfsdriver/call.c +++ b/minix/lib/libfsdriver/call.c @@ -3,6 +3,8 @@ #include #include +static int fsdriver_vmcache; /* have we used the VM cache? */ + /* * Process a READSUPER request from VFS. */ @@ -59,6 +61,7 @@ fsdriver_readsuper(const struct fsdriver * __restrict fdp, fsdriver_mounted = TRUE; fsdriver_device = dev; fsdriver_root = root_node.fn_ino_nr; + fsdriver_vmcache = FALSE; } return r; @@ -77,7 +80,7 @@ fsdriver_unmount(const struct fsdriver * __restrict fdp, 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. */ @@ -256,6 +259,8 @@ builtin_peek(const struct fsdriver * __restrict fdp, ino_t ino_nr, pos, &flags, nbytes, VMSF_ONCE); if (r == OK) { + fsdriver_vmcache = TRUE; + dev_off += nbytes; r = nbytes;