This fix "touch" a file above gvfs sftp and enable to use rsync (though with perms=0).
The fact that rsync needs a perms hacks I leave for another patch (if I manage to fix it). As the chmod works this is likely a problem with getattr opcode ... This is my first attempt to send an inline patch from this station (the setting are likely not correct) so I also send it as attachment . [PATCH] Add support for utimens in gvfs sftp backend. This fixes "touch" a file and help with rsync (one still needs the perms=0 hack). Signed-off-by: Alban Browaeys <pra...@yahoo.com> --- daemon/gvfsbackendsftp.c | 29 ++++++++++++++++++++++++++--- 1 files changed, 26 insertions(+), 3 deletions(-) diff --git a/daemon/gvfsbackendsftp.c b/daemon/gvfsbackendsftp.c index 3b510a7..4e78961 100644 --- a/daemon/gvfsbackendsftp.c +++ b/daemon/gvfsbackendsftp.c @@ -4511,7 +4511,12 @@ try_set_attribute (GVfsBackend *backend, GVfsBackendSftp *op_backend = G_VFS_BACKEND_SFTP (backend); GDataOutputStream *command; - if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_MODE) != 0) + + if (strcmp (attribute, G_FILE_ATTRIBUTE_TIME_MODIFIED) != 0 + && strcmp (attribute, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC) != 0 + && strcmp (attribute, G_FILE_ATTRIBUTE_TIME_ACCESS) != 0 + && strcmp (attribute, G_FILE_ATTRIBUTE_TIME_ACCESS_USEC) != 0 + && strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_MODE) != 0) { g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, @@ -4522,8 +4527,26 @@ try_set_attribute (GVfsBackend *backend, command = new_command_stream (op_backend, SSH_FXP_SETSTAT); put_string (command, filename); - g_data_output_stream_put_uint32 (command, SSH_FILEXFER_ATTR_PERMISSIONS, NULL, NULL); - g_data_output_stream_put_uint32 (command, (*(guint32 *)value_p) & 0777, NULL, NULL); + + if (strcmp (attribute, G_FILE_ATTRIBUTE_TIME_MODIFIED) == 0 + || strcmp (attribute, G_FILE_ATTRIBUTE_TIME_ACCESS) == 0) { + guint32 atime = *(guint32 *)value_p; + g_data_output_stream_put_uint32 (command, SSH_FILEXFER_ATTR_ACMODTIME, NULL, NULL); + g_data_output_stream_put_uint32 (command, atime, NULL, NULL); /* atime */ + g_data_output_stream_put_uint32 (command, atime, NULL, NULL); /* mtime */ + } else + if ( strcmp (attribute, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC) == 0 + || strcmp (attribute, G_FILE_ATTRIBUTE_TIME_ACCESS_USEC) == 0 ) { + g_data_output_stream_put_uint32 (command, SSH_FILEXFER_ATTR_ACMODTIME, NULL, NULL); + g_data_output_stream_put_uint32 (command, (*(guint64 *)value_p)/1000000, NULL, NULL); /* atime */ + g_data_output_stream_put_uint32 (command, (*(guint64 *)value_p)/1000000, NULL, NULL); /* mtime */ + } else { + if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_MODE) == 0 ) { + g_data_output_stream_put_uint32 (command, SSH_FILEXFER_ATTR_PERMISSIONS, NULL, NULL); + g_data_output_stream_put_uint32 (command, (*(guint32 *)value_p) & 0777, NULL, NULL); + } + } + queue_command_stream_and_free (op_backend, command, set_attribute_reply, G_VFS_JOB (job), NULL); return TRUE; -- 1.6.3.1
From 621286b74d59882a81d0d35a3cfd93b024b4d44a Mon Sep 17 00:00:00 2001 From: Alban Browaeys <pra...@yahoo.com> Date: Tue, 9 Jun 2009 13:27:15 +0200 Subject: [PATCH] Add support for utimens in gvfs sftp backend. This fixes "touch" a file and help with rsync (one still needs the perms=0 hack). Signed-off-by: Alban Browaeys <pra...@yahoo.com> --- daemon/gvfsbackendsftp.c | 29 ++++++++++++++++++++++++++--- 1 files changed, 26 insertions(+), 3 deletions(-) diff --git a/daemon/gvfsbackendsftp.c b/daemon/gvfsbackendsftp.c index 3b510a7..4e78961 100644 --- a/daemon/gvfsbackendsftp.c +++ b/daemon/gvfsbackendsftp.c @@ -4511,7 +4511,12 @@ try_set_attribute (GVfsBackend *backend, GVfsBackendSftp *op_backend = G_VFS_BACKEND_SFTP (backend); GDataOutputStream *command; - if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_MODE) != 0) + + if (strcmp (attribute, G_FILE_ATTRIBUTE_TIME_MODIFIED) != 0 + && strcmp (attribute, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC) != 0 + && strcmp (attribute, G_FILE_ATTRIBUTE_TIME_ACCESS) != 0 + && strcmp (attribute, G_FILE_ATTRIBUTE_TIME_ACCESS_USEC) != 0 + && strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_MODE) != 0) { g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, @@ -4522,8 +4527,26 @@ try_set_attribute (GVfsBackend *backend, command = new_command_stream (op_backend, SSH_FXP_SETSTAT); put_string (command, filename); - g_data_output_stream_put_uint32 (command, SSH_FILEXFER_ATTR_PERMISSIONS, NULL, NULL); - g_data_output_stream_put_uint32 (command, (*(guint32 *)value_p) & 0777, NULL, NULL); + + if (strcmp (attribute, G_FILE_ATTRIBUTE_TIME_MODIFIED) == 0 + || strcmp (attribute, G_FILE_ATTRIBUTE_TIME_ACCESS) == 0) { + guint32 atime = *(guint32 *)value_p; + g_data_output_stream_put_uint32 (command, SSH_FILEXFER_ATTR_ACMODTIME, NULL, NULL); + g_data_output_stream_put_uint32 (command, atime, NULL, NULL); /* atime */ + g_data_output_stream_put_uint32 (command, atime, NULL, NULL); /* mtime */ + } else + if ( strcmp (attribute, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC) == 0 + || strcmp (attribute, G_FILE_ATTRIBUTE_TIME_ACCESS_USEC) == 0 ) { + g_data_output_stream_put_uint32 (command, SSH_FILEXFER_ATTR_ACMODTIME, NULL, NULL); + g_data_output_stream_put_uint32 (command, (*(guint64 *)value_p)/1000000, NULL, NULL); /* atime */ + g_data_output_stream_put_uint32 (command, (*(guint64 *)value_p)/1000000, NULL, NULL); /* mtime */ + } else { + if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_MODE) == 0 ) { + g_data_output_stream_put_uint32 (command, SSH_FILEXFER_ATTR_PERMISSIONS, NULL, NULL); + g_data_output_stream_put_uint32 (command, (*(guint32 *)value_p) & 0777, NULL, NULL); + } + } + queue_command_stream_and_free (op_backend, command, set_attribute_reply, G_VFS_JOB (job), NULL); return TRUE; -- 1.6.3.1
-- nautilus-list mailing list nautilus-list@gnome.org http://mail.gnome.org/mailman/listinfo/nautilus-list