summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@src.gnome.org>2008-05-28 15:59:08 +0000
committerTomas Bzatek <tbzatek@src.gnome.org>2008-05-28 15:59:08 +0000
commit02df9d40e2a1e7bee9793cf18eef352747dec937 (patch)
treef30b66b40753f7b980cfa059c5b08c55cf1693d8
parentf7aa022b697b69db9b7341d2545fffbb6f762e31 (diff)
downloadgvfs-02df9d40e2a1e7bee9793cf18eef352747dec937.tar.gz
Return G_IO_ERROR_IS_DIRECTORY when attempting to read a directory (fixes #522933 for SMB)
svn path=/trunk/; revision=1790
-rw-r--r--ChangeLog6
-rw-r--r--daemon/gvfsbackendsmb.c20
2 files changed, 24 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 0da98e1b..b908f8c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-05-28 Tomas Bzatek <tbzatek@redhat.com>
+
+ * daemon/gvfsbackendsmb.c: (do_open_for_read):
+ Return G_IO_ERROR_IS_DIRECTORY when attempting
+ to read a directory (fixes #522933 for SMB)
+
2008-05-27 Tomas Bzatek <tbzatek@redhat.com>
* daemon/gvfsbackendsmb.c: (do_mount):
diff --git a/daemon/gvfsbackendsmb.c b/daemon/gvfsbackendsmb.c
index 8a4a6aed..5d1bfd28 100644
--- a/daemon/gvfsbackendsmb.c
+++ b/daemon/gvfsbackendsmb.c
@@ -625,17 +625,33 @@ do_open_for_read (GVfsBackend *backend,
GVfsBackendSmb *op_backend = G_VFS_BACKEND_SMB (backend);
char *uri;
SMBCFILE *file;
+ struct stat st;
smbc_open_fn smbc_open;
+ smbc_stat_fn smbc_stat;
+ int res;
+ int olderr;
+
uri = create_smb_uri (op_backend->server, op_backend->share, filename);
smbc_open = smbc_getFunctionOpen (op_backend->smb_context);
file = smbc_open (op_backend->smb_context, uri, O_RDONLY, 0);
- g_free (uri);
if (file == NULL)
- g_vfs_job_failed_from_errno (G_VFS_JOB (job), errno);
+ {
+ olderr = errno;
+ smbc_stat = smbc_getFunctionStat (op_backend->smb_context);
+ res = smbc_stat (op_backend->smb_context, uri, &st);
+ g_free (uri);
+ if ((res == 0) && (S_ISDIR (st.st_mode)))
+ g_vfs_job_failed (G_VFS_JOB (job),
+ G_IO_ERROR, G_IO_ERROR_IS_DIRECTORY,
+ _("Can't open directory"));
+ else
+ g_vfs_job_failed_from_errno (G_VFS_JOB (job), olderr);
+ }
else
{
+
g_vfs_job_open_for_read_set_can_seek (job, TRUE);
g_vfs_job_open_for_read_set_handle (job, file);
g_vfs_job_succeeded (G_VFS_JOB (job));