|
12 | 12 | #include <fuse.h> |
13 | 13 | #include <fuse_opt.h> |
14 | 14 | #if !defined(__CYGWIN__) |
15 | | -#include <fuse_lowlevel.h> |
| 15 | +# include <fuse_lowlevel.h> |
16 | 16 | #endif |
17 | 17 | #ifdef __APPLE__ |
18 | 18 | # include <fuse_darwin.h> |
@@ -3452,7 +3452,39 @@ static int sshfs_opt_proc(void *data, const char *arg, int key, |
3452 | 3452 | return 0; |
3453 | 3453 | } |
3454 | 3454 | else if (!sshfs.mountpoint) { |
| 3455 | +#if defined(__CYGWIN__) |
| 3456 | + /* |
| 3457 | + * On FUSE for Cygwin the mountpoint may be a drive or directory. |
| 3458 | + * Furthermore the mountpoint must NOT exist prior to mounting. |
| 3459 | + * So we cannot use realpath(3). |
| 3460 | + */ |
| 3461 | + if ((('A' <= arg[0] && arg[0] <= 'Z') || ('a' <= arg[0] && arg[0] <= 'z')) |
| 3462 | + && ':' == arg[1] && '\0' == arg[2]) { |
| 3463 | + /* drive: make a copy */ |
| 3464 | + sshfs.mountpoint = strdup(arg); |
| 3465 | + } else { |
| 3466 | + /* path: split into dirname, basename and check dirname */ |
| 3467 | + char *dir; |
| 3468 | + const char *base; |
| 3469 | + const char *slash = strrchr(arg, '/'); |
| 3470 | + if (slash) { |
| 3471 | + char *tmp = strndup(arg, slash == arg ? 1 : slash - arg); |
| 3472 | + dir = tmp ? realpath(tmp, NULL) : 0; |
| 3473 | + base = slash + 1; |
| 3474 | + free(tmp); |
| 3475 | + } else { |
| 3476 | + dir = realpath(".", NULL); |
| 3477 | + base = arg; |
| 3478 | + } |
| 3479 | + if (dir) { |
| 3480 | + slash = '/' == dir[0] && '\0' == dir[1] ? "" : "/"; |
| 3481 | + asprintf(&sshfs.mountpoint, "%s%s%s", dir, slash, base); |
| 3482 | + free(dir); |
| 3483 | + } |
| 3484 | + } |
| 3485 | +#else |
3455 | 3486 | sshfs.mountpoint = realpath(arg, NULL); |
| 3487 | +#endif |
3456 | 3488 | if (!sshfs.mountpoint) { |
3457 | 3489 | fprintf(stderr, "sshfs: bad mount point `%s': %s\n", |
3458 | 3490 | arg, strerror(errno)); |
@@ -3912,7 +3944,9 @@ int main(int argc, char *argv[]) |
3912 | 3944 | if (sshfs.show_version) { |
3913 | 3945 | printf("SSHFS version %s\n", PACKAGE_VERSION); |
3914 | 3946 | printf("FUSE library version %s\n", fuse_pkgversion()); |
| 3947 | +#if !defined(__CYGWIN__) |
3915 | 3948 | fuse_lowlevel_version(); |
| 3949 | +#endif |
3916 | 3950 | exit(0); |
3917 | 3951 | } |
3918 | 3952 |
|
|
0 commit comments