aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Zissimopoulos <billziss@navimatics.com>2018-07-31 10:55:23 -0700
committerNikolaus Rath <Nikolaus@rath.org>2018-08-01 14:39:23 +0100
commiteac420791c667b038817aaa481c67646e9654e15 (patch)
tree099fd0d8d6e0c5a9490895795b3749822d660928
parent6480b66bd64a2d2f58db6fc0a3320f4464f4669e (diff)
downloadsshfs-eac420791c667b038817aaa481c67646e9654e15.tar
sshfs-eac420791c667b038817aaa481c67646e9654e15.tar.gz
sshfs-eac420791c667b038817aaa481c67646e9654e15.tar.bz2
sshfs-eac420791c667b038817aaa481c67646e9654e15.zip
Port SSHFS to Cygwin
-rw-r--r--ChangeLog.rst1
-rw-r--r--sshfs.c36
2 files changed, 36 insertions, 1 deletions
diff --git a/ChangeLog.rst b/ChangeLog.rst
index 368d2cd..65952ba 100644
--- a/ChangeLog.rst
+++ b/ChangeLog.rst
@@ -2,6 +2,7 @@ Unreleased Changes
------------------
* Fixed error code returned by rename(), allowing proper fallback.
+* Port to Cygwin.
Release 3.4.0 (2018-06-29)
--------------------------
diff --git a/sshfs.c b/sshfs.c
index a6e7bf2..4423e07 100644
--- a/sshfs.c
+++ b/sshfs.c
@@ -12,7 +12,7 @@
#include <fuse.h>
#include <fuse_opt.h>
#if !defined(__CYGWIN__)
-#include <fuse_lowlevel.h>
+# include <fuse_lowlevel.h>
#endif
#ifdef __APPLE__
# include <fuse_darwin.h>
@@ -3452,7 +3452,39 @@ static int sshfs_opt_proc(void *data, const char *arg, int key,
return 0;
}
else if (!sshfs.mountpoint) {
+#if defined(__CYGWIN__)
+ /*
+ * On FUSE for Cygwin the mountpoint may be a drive or directory.
+ * Furthermore the mountpoint must NOT exist prior to mounting.
+ * So we cannot use realpath(3).
+ */
+ if ((('A' <= arg[0] && arg[0] <= 'Z') || ('a' <= arg[0] && arg[0] <= 'z'))
+ && ':' == arg[1] && '\0' == arg[2]) {
+ /* drive: make a copy */
+ sshfs.mountpoint = strdup(arg);
+ } else {
+ /* path: split into dirname, basename and check dirname */
+ char *dir;
+ const char *base;
+ const char *slash = strrchr(arg, '/');
+ if (slash) {
+ char *tmp = strndup(arg, slash == arg ? 1 : slash - arg);
+ dir = tmp ? realpath(tmp, NULL) : 0;
+ base = slash + 1;
+ free(tmp);
+ } else {
+ dir = realpath(".", NULL);
+ base = arg;
+ }
+ if (dir) {
+ slash = '/' == dir[0] && '\0' == dir[1] ? "" : "/";
+ asprintf(&sshfs.mountpoint, "%s%s%s", dir, slash, base);
+ free(dir);
+ }
+ }
+#else
sshfs.mountpoint = realpath(arg, NULL);
+#endif
if (!sshfs.mountpoint) {
fprintf(stderr, "sshfs: bad mount point `%s': %s\n",
arg, strerror(errno));
@@ -3912,7 +3944,9 @@ int main(int argc, char *argv[])
if (sshfs.show_version) {
printf("SSHFS version %s\n", PACKAGE_VERSION);
printf("FUSE library version %s\n", fuse_pkgversion());
+#if !defined(__CYGWIN__)
fuse_lowlevel_version();
+#endif
exit(0);
}