From e8e1dc35955c7fcaf7e5b77bf2d803e35772b8eb Mon Sep 17 00:00:00 2001 From: benrubson Date: Mon, 26 Mar 2018 22:26:44 +0200 Subject: [PATCH] Cygwin, use correct mount point --- encfs/FileUtils.h | 1 + encfs/main.cpp | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/encfs/FileUtils.h b/encfs/FileUtils.h index 1406915..7e6aa1f 100644 --- a/encfs/FileUtils.h +++ b/encfs/FileUtils.h @@ -72,6 +72,7 @@ enum ConfigMode { Config_Prompt, Config_Standard, Config_Paranoia }; struct EncFS_Opts { std::string rootDir; std::string mountPoint; // where to make filesystem visible + std::string cygDrive; // Cygwin mount drive bool createIfNotFound; // create filesystem if not found bool idleTracking; // turn on idle monitoring of filesystem bool mountOnDemand; // mounting on-demand diff --git a/encfs/main.cpp b/encfs/main.cpp index c79cada..c624341 100644 --- a/encfs/main.cpp +++ b/encfs/main.cpp @@ -542,18 +542,38 @@ static bool processArgs(int argc, char *argv[], if (!isDirectory(out->opts->rootDir.c_str()) && !userAllowMkdir(out->opts->annotate ? 1 : 0, out->opts->rootDir.c_str(), 0700)) { - cerr << _("Unable to locate root directory, aborting."); + cerr << _("Unable to locate root directory, aborting.") << endl; return false; } +#ifdef __CYGWIN__ + if (isDirectory(out->opts->mountPoint.c_str())) { + cerr << _("Mount point must not exist before mouting, aborting.") << endl; + return false; + } + if ((strncmp(out->opts->mountPoint.c_str(), "/cygdrive/", 10) != 0) || + (out->opts->mountPoint.length() != 12)) { + cerr << _("A drive is prefered for mouting, ") + << _("so a path like /cygdrive/x should rather be used. ") + << _("Mounting anyway.") << endl; + } +#else if (!isDirectory(out->opts->mountPoint.c_str()) && !userAllowMkdir(out->opts->annotate ? 2 : 0, out->opts->mountPoint.c_str(), 0700)) { - cerr << _("Unable to locate mount point, aborting."); + cerr << _("Unable to locate mount point, aborting.") << endl; return false; } +#endif // fill in mount path for fuse out->fuseArgv[1] = out->opts->mountPoint.c_str(); +#ifdef __CYGWIN__ + if ((strncmp(out->opts->mountPoint.c_str(), "/cygdrive/", 10) == 0) && + (out->opts->mountPoint.length() == 12)) { + out->opts->cygDrive = out->opts->mountPoint.substr(10,1).append(":"); + out->fuseArgv[1] = out->opts->cygDrive.c_str(); + } +#endif return true; }