X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fcopy-file.c;h=198a01417f648e7f09b8ea94411a9416bcbfb71c;hb=39e82e46dde285e3ed536bf9b089904cd2b04c3c;hp=a03047b58ead3e87c2f9a9d023678771e04468e3;hpb=c845cbfc0d3b726794f95723a7a1105d98e8725d;p=gnulib.git diff --git a/lib/copy-file.c b/lib/copy-file.c index a03047b58..198a01417 100644 --- a/lib/copy-file.c +++ b/lib/copy-file.c @@ -26,6 +26,7 @@ #include #include +#include #include #ifdef HAVE_UNISTD_H @@ -57,7 +58,7 @@ copy_file_preserving (const char *src_filename, const char *dest_filename) int mode; int dest_fd; char buf[4096]; - const int buf_size = sizeof (buf); + const size_t buf_size = sizeof (buf); src_fd = open (src_filename, O_RDONLY | O_BINARY); if (src_fd < 0 || fstat (src_fd, &statbuf) < 0) @@ -108,8 +109,10 @@ copy_file_preserving (const char *src_filename, const char *dest_filename) } #endif +#if HAVE_CHOWN /* Preserve the owner and group. */ chown (dest_filename, statbuf.st_uid, statbuf.st_gid); +#endif /* Preserve the access permissions. */ chmod (dest_filename, mode);