Merge branch '1535_vfs_sftp_fixes'

* 1535_vfs_sftp_fixes:
  Add SFTP to the list of supported VFSes.
  SFTP connections are shown now in 'Active VFS connections' list.
  Fixed reget support in SFTP.
  Ticket #1535: configure: don't fail if 'sftp' support was not requested explicitly
This commit is contained in:
Slava Zanko 2012-07-05 10:35:55 +03:00
commit 04bce06ce4
5 changed files with 46 additions and 5 deletions

View File

@ -172,7 +172,7 @@ VFS options:
Support for FISH vfs
`--enable-vfs-sftp'
(off by default)
(auto)
Support for SFTP vfs
`--enable-vfs-extfs'

View File

@ -2,7 +2,7 @@ dnl Enable SFTP filesystem
AC_DEFUN([AC_MC_VFS_SFTP],
[
AC_ARG_ENABLE([vfs-sftp],
AS_HELP_STRING([--enable-vfs-sftp], [Support for SFTP filesystem [[yes]]]))
AS_HELP_STRING([--enable-vfs-sftp], [Support for SFTP filesystem [auto]]))
if test "$enable_vfs" != "no" -a x"$enable_vfs_sftp" != x"no"; then
PKG_CHECK_MODULES(LIBSSH, [libssh2 >= 1.2.5], [found_libssh=yes], [:])
if test x"$found_libssh" = "xyes"; then
@ -11,8 +11,11 @@ AC_DEFUN([AC_MC_VFS_SFTP],
MCLIBS="$MCLIBS $LIBSSH_LIBS"
enable_vfs_sftp="yes"
else
if test x"$enable_vfs_sftp" = x"yes"; then
dnl user explicitly requested feature
AC_ERROR([libssh2 >= 1.2.5 library not found])
fi
enable_vfs_sftp="no"
AC_ERROR([libssh2 >= 1.2.5 library not found])
fi
fi
AM_CONDITIONAL([ENABLE_VFS_SFTP], [test "$enable_vfs" = "yes" -a x"$enable_vfs_sftp" = x"yes"])

View File

@ -64,6 +64,9 @@ static const char *const vfs_supported[] = {
#ifdef ENABLE_VFS_FTP
"ftpfs",
#endif
#ifdef ENABLE_VFS_SFTP
"sftpfs",
#endif
#ifdef ENABLE_VFS_FISH
"fish",
#endif

View File

@ -86,6 +86,7 @@ sftpfs_open_file (vfs_file_handler_t * file_handler, int flags, mode_t mode, GEr
{
unsigned long sftp_open_flags = 0;
int sftp_open_mode = 0;
gboolean do_append = FALSE;
sftpfs_file_handler_data_t *file_handler_data;
sftpfs_super_data_t *super_data;
char *name;
@ -103,7 +104,11 @@ sftpfs_open_file (vfs_file_handler_t * file_handler, int flags, mode_t mode, GEr
{
sftp_open_flags = (flags & O_WRONLY) != 0 ? LIBSSH2_FXF_WRITE : 0;
sftp_open_flags |= (flags & O_CREAT) != 0 ? LIBSSH2_FXF_CREAT : 0;
sftp_open_flags |= (flags & O_APPEND) != 0 ? LIBSSH2_FXF_APPEND : 0;
if ((flags & O_APPEND) != 0)
{
sftp_open_flags |= LIBSSH2_FXF_APPEND;
do_append = TRUE;
}
sftp_open_flags |= (flags & O_TRUNC) != 0 ? LIBSSH2_FXF_TRUNC : 0;
sftp_open_mode = LIBSSH2_SFTP_S_IRUSR |
@ -138,7 +143,7 @@ sftpfs_open_file (vfs_file_handler_t * file_handler, int flags, mode_t mode, GEr
file_handler_data->mode = mode;
file_handler->data = file_handler_data;
if ((flags & O_APPEND) != 0)
if (do_append)
{
struct stat file_info;

View File

@ -634,6 +634,34 @@ sftpfs_cb_errno (struct vfs_class *me)
return errno;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Callback for fill_names VFS function.
* Add SFTP connections to the 'Active VFS connections' list
*
* @param me unused
* @param func callback function for adding SFTP-connection to list of active connections
*/
static void
sftpfs_cb_fill_names (struct vfs_class *me, fill_names_f func)
{
GList *iter;
(void) me;
for (iter = sftpfs_subclass.supers; iter != NULL; iter = g_list_next (iter))
{
const struct vfs_s_super *super = (const struct vfs_s_super *) iter->data;
char *name;
name = vfs_path_element_build_pretty_path_str (super->path_element);
func (name);
g_free (name);
}
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
@ -663,6 +691,8 @@ sftpfs_init_class_callbacks (void)
sftpfs_class.init = sftpfs_cb_init;
sftpfs_class.done = sftpfs_cb_done;
sftpfs_class.fill_names = sftpfs_cb_fill_names;
sftpfs_class.opendir = sftpfs_cb_opendir;
sftpfs_class.readdir = sftpfs_cb_readdir;
sftpfs_class.closedir = sftpfs_cb_closedir;