From ffbd9561f05835e34fef57720730a0bad8311010 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Thu, 27 Oct 2011 14:22:14 +0300 Subject: [PATCH] Ticket #2652: SMB is broken After #2361, smb vfs module doesn't work at all. The error message "Cannot chdir to ..." raises after hostname enter. Signed-off-by: Slava Zanko --- lib/vfs/utilvfs.c | 2 ++ src/vfs/smbfs/smbfs.c | 33 +++++++++++++++------------------ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/vfs/utilvfs.c b/lib/vfs/utilvfs.c index 75682cd4c..5f9385565 100644 --- a/lib/vfs/utilvfs.c +++ b/lib/vfs/utilvfs.c @@ -44,6 +44,7 @@ #include "lib/unixcompat.h" #include "lib/util.h" /* mc_mkstemps() */ #include "lib/widget.h" /* message() */ +#include "lib/strutil.h" /* INVALID_CONV */ #include "vfs.h" #include "utilvfs.h" @@ -325,6 +326,7 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags) } path_element->host = g_strdup (rest); + path_element->dir.converter = INVALID_CONV; return path_element; } diff --git a/src/vfs/smbfs/smbfs.c b/src/vfs/smbfs/smbfs.c index ddba0c7b8..9d2979601 100644 --- a/src/vfs/smbfs/smbfs.c +++ b/src/vfs/smbfs/smbfs.c @@ -1327,14 +1327,14 @@ smbfs_get_path (smbfs_connection ** sc, const vfs_path_t * vpath) char *remote_path = NULL; vfs_path_element_t *url; vfs_path_element_t *path_element = vfs_path_get_by_index (vpath, -1); - char *path = path_element->path; + const char *path = path_element->path; DEBUG (3, ("smbfs_get_path(%s)\n", path)); - if (strncmp (path, URL_HEADER, HEADER_LEN) != 0) - return NULL; - path += HEADER_LEN; - if (*path == '/') /* '/' leading server name */ + if (path_element->class != &vfs_smbfs_ops) + return NULL; + + while (*path == '/') /* '/' leading server name */ path++; /* probably came from server browsing */ url = vfs_url_split (path, SMB_PORT, URL_FLAGS_NONE); @@ -1725,15 +1725,11 @@ smbfs_stat (const vfs_path_t * vpath, struct stat *buf) /* check if stating server */ p = path_element->path; - if (strncmp (p, URL_HEADER, HEADER_LEN)) - { - DEBUG (1, ("'%s' doesnt start with '%s' (length %d)\n", p, URL_HEADER, HEADER_LEN)); + if (path_element->class != &vfs_smbfs_ops) return -1; - } - p += HEADER_LEN; - if (*p == '/') - p++; + while (*p == '/') /* '/' leading server name */ + p++; /* probably came from server browsing */ pp = strchr (p, '/'); /* advance past next '/' */ at = strchr (p, '@'); @@ -1951,18 +1947,19 @@ smbfs_free (vfsid id) */ static void -smbfs_forget (const char *path) +smbfs_forget (const vfs_path_t * vpath) { + vfs_path_element_t *path_element = vfs_path_get_by_index (vpath, -1); vfs_path_element_t *p; + const char *path = path_element->path; - if (strncmp (path, URL_HEADER, HEADER_LEN) != 0) + if (path_element->class != &vfs_smbfs_ops) return; DEBUG (3, ("smbfs_forget(path:%s)\n", path)); - path += 6; - if (path[0] == '/' && path[1] == '/') - path += 2; + while (*path == '/') /* '/' leading server name */ + path++; /* probably came from server browsing */ p = vfs_url_split (path, SMB_PORT, URL_FLAGS_NONE); if (p != NULL) @@ -2001,7 +1998,7 @@ smbfs_setctl (const vfs_path_t * vpath, int ctlop, void *arg) switch (ctlop) { case VFS_SETCTL_FORGET: - smbfs_forget (path_element->path); + smbfs_forget (vpath); break; case VFS_SETCTL_LOGFILE: smbfs_set_debugf ((const char *) arg);