From ae4614e69045c697b7704b72030dca373b9d0f71 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Wed, 15 Jul 2009 14:20:58 +0000 Subject: Add option 'delay_connect': This will always create the sshfs mount, even if the connection to the server can't be established. --- ChangeLog | 5 +++++ configure.ac | 2 +- sshfs.1 | 3 +++ sshfs.c | 39 ++++++++++++++++++--------------------- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5e040d2..d9c45cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-07-15 Sebastian Dransfeld + + * Add option 'delay_connect': This will always create the sshfs mount, + even if the connection to the server can't be established. + 2009-01-27 Miklos Szeredi * Print usage information and version to stdout, not stderr. diff --git a/configure.ac b/configure.ac index 2e165c8..ac69a38 100644 --- a/configure.ac +++ b/configure.ac @@ -37,7 +37,7 @@ fi AM_CONDITIONAL(SSH_NODELAY_SO, test "$enable_sshnodelay" = "yes") export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH -PKG_CHECK_MODULES(SSHFS, [fuse >= 2.2 glib-2.0 gthread-2.0]) +PKG_CHECK_MODULES(SSHFS, [fuse >= 2.3 glib-2.0 gthread-2.0]) have_fuse_opt_parse=no oldlibs="$LIBS" LIBS="$LIBS $SSHFS_LIBS" diff --git a/sshfs.1 b/sshfs.1 index 1035bba..de6be51 100644 --- a/sshfs.1 +++ b/sshfs.1 @@ -46,6 +46,9 @@ equivalent to '\-o ssh_protocol=1' \fB\-o\fR reconnect reconnect to server .TP +\fB\-o\fR delay_connect +delay connection to server +.TP \fB\-o\fR sshfs_sync synchronous writes .TP diff --git a/sshfs.c b/sshfs.c index 85d3967..00fb098 100644 --- a/sshfs.c +++ b/sshfs.c @@ -46,10 +46,6 @@ #endif -#if FUSE_VERSION >= 23 -#define SSHFS_USE_INIT -#endif - #define SSH_FXP_INIT 1 #define SSH_FXP_VERSION 2 #define SSH_FXP_OPEN 3 @@ -194,6 +190,7 @@ struct sshfs { int debug; int foreground; int reconnect; + int delay_connect; char *host; char *base_path; GHashTable *reqtab; @@ -312,6 +309,7 @@ static struct fuse_opt sshfs_opts[] = { SSHFS_OPT("follow_symlinks", follow_symlinks, 1), SSHFS_OPT("no_check_root", no_check_root, 1), SSHFS_OPT("password_stdin", password_stdin, 1), + SSHFS_OPT("delay_connect", delay_connect, 1), FUSE_OPT_KEY("-p ", KEY_PORT), FUSE_OPT_KEY("-C", KEY_COMPRESS), @@ -1580,6 +1578,11 @@ static int start_processing_thread(void) return -EIO; } + if (sshfs.detect_uid) { + sftp_detect_uid(); + sshfs.detect_uid = 0; + } + sigemptyset(&newset); sigaddset(&newset, SIGTERM); sigaddset(&newset, SIGINT); @@ -1597,11 +1600,10 @@ static int start_processing_thread(void) return 0; } -#ifdef SSHFS_USE_INIT #if FUSE_VERSION >= 26 static void *sshfs_init(struct fuse_conn_info *conn) #else - static void *sshfs_init(void) +static void *sshfs_init(void) #endif { #if FUSE_VERSION >= 26 @@ -1610,13 +1612,11 @@ static void *sshfs_init(struct fuse_conn_info *conn) sshfs.sync_read = 1; #endif - if (sshfs.detect_uid) - sftp_detect_uid(); + if (!sshfs.delay_connect) + start_processing_thread(); - start_processing_thread(); return NULL; } -#endif static int sftp_request_wait(struct request *req, uint8_t type, uint8_t expect_type, struct buffer *outbuf) @@ -2794,9 +2794,7 @@ static int processing_init(void) static struct fuse_cache_operations sshfs_oper = { .oper = { -#ifdef SSHFS_USE_INIT .init = sshfs_init, -#endif .getattr = sshfs_getattr, .readlink = sshfs_readlink, .mknod = sshfs_mknod, @@ -2841,6 +2839,7 @@ static void usage(const char *progname) " -F ssh_configfile specifies alternative ssh configuration file\n" " -1 equivalent to '-o ssh_protocol=1'\n" " -o reconnect reconnect to server\n" +" -o delay_connect delay connection to server\n" " -o sshfs_sync synchronous writes\n" " -o no_readahead synchronous reads (no speculative readahead)\n" " -o sshfs_debug print some debugging information\n" @@ -3182,6 +3181,7 @@ int main(int argc, char *argv[]) sshfs.fd = -1; sshfs.ptyfd = -1; sshfs.ptyslavefd = -1; + sshfs.delay_connect = 0; ssh_add_arg("ssh"); ssh_add_arg("-x"); ssh_add_arg("-a"); @@ -3244,16 +3244,13 @@ int main(int argc, char *argv[]) if (res == -1) exit(1); - if (connect_remote() == -1) - exit(1); - -#ifndef SSHFS_USE_INIT - if (sshfs.detect_uid) - sftp_detect_uid(); -#endif + if (!sshfs.delay_connect) { + if (connect_remote() == -1) + exit(1); - if (!sshfs.no_check_root && sftp_check_root(base_path) == -1) - exit(1); + if (!sshfs.no_check_root && sftp_check_root(sshfs.base_path) == -1) + exit(1); + } res = cache_parse_options(&args); if (res == -1) -- cgit v1.2.3