>From 6962ac880e5c06b9c6b9708ffd156b85ac93af95 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 11 Jan 2012 02:01:45 +0100 Subject: [PATCH 4/5] copy-file: Refactor. * lib/copy-file.c: Include quote.h. (copy_file_preserving): Call qcopy_acl instead of copy_acl. Emit error message here. * modules/copy-file (Depends-on): Add quote. --- ChangeLog | 6 ++++++ lib/copy-file.c | 11 +++++++++-- modules/copy-file | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 61d4103..4494496 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2012-01-10 Bruno Haible + copy-file: Refactor. + * lib/copy-file.c: Include quote.h. + (copy_file_preserving): Call qcopy_acl instead of copy_acl. Emit error + message here. + * modules/copy-file (Depends-on): Add quote. + acl: Export qcopy_acl. * lib/acl.h (qcopy_acl): New declaration. * lib/copy-acl.c (qcopy_acl): Make non-static. diff --git a/lib/copy-file.c b/lib/copy-file.c index 8e79091..5bd6fa8 100644 --- a/lib/copy-file.c +++ b/lib/copy-file.c @@ -41,6 +41,7 @@ #include "full-write.h" #include "acl.h" #include "binary-io.h" +#include "quote.h" #include "gettext.h" #include "xalloc.h" @@ -122,8 +123,14 @@ copy_file_preserving (const char *src_filename, const char *dest_filename) /* Preserve the access permissions. */ #if USE_ACL - if (copy_acl (src_filename, src_fd, dest_filename, dest_fd, mode)) - exit (EXIT_FAILURE); + switch (qcopy_acl (src_filename, src_fd, dest_filename, dest_fd, mode)) + { + case -2: + error (EXIT_FAILURE, errno, "%s", quote (src_filename)); + case -1: + error (EXIT_FAILURE, errno, _("preserving permissions for %s"), + quote (dest_filename)); + } #else chmod (dest_filename, mode); #endif diff --git a/modules/copy-file b/modules/copy-file index 6a35db2..1c50d55 100644 --- a/modules/copy-file +++ b/modules/copy-file @@ -14,6 +14,7 @@ fstat full-write gettext-h open +quote safe-read stdlib unistd -- 1.6.3.2