From 84dae17d4e01967bf7bb58c23b18c6c7b2f9a728 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Mon, 17 Nov 2014 00:03:38 +0100 Subject: [PATCH] Disable unsafe kernel caching for --reverse By default, the kernel caches file metadata for one second. This is fine for EncFS' normal mode, but for --reverse, this means that the encrypted view will be up to one second out of date. This causes the reverse grow tests to fail because stale stat() data is returned. --- encfs/main.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/encfs/main.cpp b/encfs/main.cpp index bd500ac..1851c68 100644 --- a/encfs/main.cpp +++ b/encfs/main.cpp @@ -274,6 +274,22 @@ static bool processArgs(int argc, char *argv[], break; case 'r': out->opts->reverseEncryption = true; + /* By default, the kernel caches file metadata for one second. + * This is fine for EncFS' normal mode, but for --reverse, this + * means that the encrypted view will be up to one second out of + * date. + * Quoting Goswin von Brederlow: + * "Caching only works correctly if you implement a disk based + * filesystem, one where only the fuse process can alter + * metadata and all access goes only through fuse. Any overlay + * filesystem where something can change the underlying + * filesystem without going through fuse can run into + * inconsistencies." + * Disable caching so the encrypted view stays consistent with + * the backing files. */ + PUSHARG("-oattr_timeout=0"); // Causes reverse grow tests to fail + // because stale stat() data is returned + PUSHARG("-oentry_timeout=0"); // Fallout unknown, disabling for safety break; case 'm': out->opts->mountOnDemand = true;