bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] install: add -C option to install file only when necessary


From: Pádraig Brady
Subject: Re: [PATCH] install: add -C option to install file only when necessary
Date: Mon, 16 Feb 2009 10:07:56 +0000
User-agent: Thunderbird 2.0.0.6 (X11/20071008)

Kamil Dudka wrote:
> On Thursday 12 February 2009 14:27:09 Jim Meyering wrote:
>> While rewriting that,
>>
>>   install accepts a new option, --compare (-C): compare each pair of source
>>   and destination files, and if the destination has identical content and
>>   any specified owner, group, permissions, and possibly SELinux context,
>> then do not modify the destination at all.

Why is this an option?
I.E. should we just accept -C for compat, but do this all the time?
I haven't thought about it really. Just wondering.
I suppose one might want timestamps updated/preserved to
know when the file was installed/built?

> +static bool
> +have_same_content (int a_fd, int b_fd)
> +{
> +#define CMP_BLOCK_SIZE 65536
> +  char a_buff[CMP_BLOCK_SIZE];
> +  char b_buff[CMP_BLOCK_SIZE];
> +
> +  size_t size;
> +  while (0 < (size = full_read (a_fd, a_buff, CMP_BLOCK_SIZE))) {
> +    if (size != full_read (b_fd, b_buff, CMP_BLOCK_SIZE))
> +      return false;
> +
> +    if (memcmp (a_buff, b_buff, size) != 0)
> +      return false;
> +  }
> +
> +  return size == 0;
> +#undef CMP_BLOCK_SIZE
> +}

Is 128KiB of stack OK?
I noticed this related email from Eric:
http://lists.gnu.org/archive/html/m4-patches/2008-08/msg00001.html

cheers,
Pádraig.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]