[gvfs] smb: Implement truncate support for output streams
- From: Ross Lagerwall <rossl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] smb: Implement truncate support for output streams
- Date: Thu, 5 Dec 2013 23:59:30 +0000 (UTC)
commit 6e5786f4368e7124ce316dafd607d3306c05ea11
Author: Ross Lagerwall <rosslagerwall gmail com>
Date: Thu Oct 17 09:26:38 2013 +0200
smb: Implement truncate support for output streams
https://bugzilla.gnome.org/show_bug.cgi?id=573837
daemon/gvfsbackendsmb.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/daemon/gvfsbackendsmb.c b/daemon/gvfsbackendsmb.c
index 8a3fa8d..6065912 100644
--- a/daemon/gvfsbackendsmb.c
+++ b/daemon/gvfsbackendsmb.c
@@ -42,6 +42,7 @@
#include "gvfsjobwrite.h"
#include "gvfsjobclosewrite.h"
#include "gvfsjobseekwrite.h"
+#include "gvfsjobtruncate.h"
#include "gvfsjobsetdisplayname.h"
#include "gvfsjobqueryinfo.h"
#include "gvfsjobqueryfsinfo.h"
@@ -981,6 +982,7 @@ do_create (GVfsBackend *backend,
handle->file = file;
g_vfs_job_open_for_write_set_can_seek (job, TRUE);
+ g_vfs_job_open_for_write_set_can_truncate (job, TRUE);
g_vfs_job_open_for_write_set_handle (job, handle);
g_vfs_job_succeeded (G_VFS_JOB (job));
}
@@ -1023,6 +1025,7 @@ do_append_to (GVfsBackend *backend,
{
g_vfs_job_open_for_write_set_initial_offset (job, initial_offset);
g_vfs_job_open_for_write_set_can_seek (job, TRUE);
+ g_vfs_job_open_for_write_set_can_truncate (job, TRUE);
}
g_vfs_job_open_for_write_set_handle (job, handle);
g_vfs_job_succeeded (G_VFS_JOB (job));
@@ -1299,6 +1302,7 @@ do_replace (GVfsBackend *backend,
handle->backup_uri = backup_uri;
g_vfs_job_open_for_write_set_can_seek (job, TRUE);
+ g_vfs_job_open_for_write_set_can_truncate (job, TRUE);
g_vfs_job_open_for_write_set_handle (job, handle);
g_vfs_job_succeeded (G_VFS_JOB (job));
@@ -1383,6 +1387,23 @@ do_seek_on_write (GVfsBackend *backend,
}
static void
+do_truncate (GVfsBackend *backend,
+ GVfsJobTruncate *job,
+ GVfsBackendHandle _handle,
+ goffset size)
+{
+ GVfsBackendSmb *op_backend = G_VFS_BACKEND_SMB (backend);
+ SmbWriteHandle *handle = _handle;
+ smbc_ftruncate_fn smbc_ftruncate;
+
+ smbc_ftruncate = smbc_getFunctionFtruncate (op_backend->smb_context);
+ if (smbc_ftruncate (op_backend->smb_context, handle->file, size) == -1)
+ g_vfs_job_failed_from_errno (G_VFS_JOB (job), errno);
+ else
+ g_vfs_job_succeeded (G_VFS_JOB (job));
+}
+
+static void
do_query_info_on_write (GVfsBackend *backend,
GVfsJobQueryInfoWrite *job,
GVfsBackendHandle _handle,
@@ -2276,6 +2297,7 @@ g_vfs_backend_smb_class_init (GVfsBackendSmbClass *klass)
backend_class->replace = do_replace;
backend_class->write = do_write;
backend_class->seek_on_write = do_seek_on_write;
+ backend_class->truncate = do_truncate;
backend_class->query_info_on_write = do_query_info_on_write;
backend_class->close_write = do_close_write;
backend_class->query_info = do_query_info;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]