summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2013-10-29 09:26:45 +0100
committerColin Walters <walters@verbum.org>2013-11-03 20:15:38 -0500
commitf861ba48955b6c3a3a05cdadae510695db3b5a99 (patch)
tree2393e41d41a4d17ea369327db612f10af80886ff
parent7c204267a38449de9d98c2c387961563c18ba550 (diff)
downloadlibgsystem-f861ba48955b6c3a3a05cdadae510695db3b5a99.tar.gz
shutil: Make gs_shutil_cp_a copy ownership as well
Like cp -a gs_shutil_cp_a should really copy all directory metadata. This adds support for at least copying the ownership metadata (user/group). https://bugzilla.gnome.org/show_bug.cgi?id=711057
-rw-r--r--gsystem-shutil.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/gsystem-shutil.c b/gsystem-shutil.c
index a8dbc18..8416033 100644
--- a/gsystem-shutil.c
+++ b/gsystem-shutil.c
@@ -81,6 +81,16 @@ cp_internal_one_item (GFile *src,
goto out;
}
+ if (chown (gs_file_get_path_cached (dest_child),
+ g_file_info_get_attribute_uint32 (file_info, "unix::uid"),
+ g_file_info_get_attribute_uint32 (file_info, "unix::gid")) == -1)
+ {
+ int errsv = errno;
+ g_set_error_literal (error, G_IO_ERROR, g_io_error_from_errno (errsv),
+ g_strerror (errsv));
+ goto out;
+ }
+
if (!cp_internal (src_child, dest_child, use_hardlinks, cancellable, error))
goto out;
}
@@ -132,7 +142,7 @@ cp_internal (GFile *src,
GFileInfo *file_info = NULL;
GError *temp_error = NULL;
- enumerator = g_file_enumerate_children (src, "standard::type,standard::name,unix::mode",
+ enumerator = g_file_enumerate_children (src, "standard::type,standard::name,unix::uid,unix::gid,unix::mode",
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
cancellable, error);
if (!enumerator)