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: Kamil Dudka
Subject: Re: [PATCH] install: add -C option to install file only when necessary
Date: Mon, 16 Feb 2009 11:32:48 +0100
User-agent: KMail/1.9.6 (enterprise 0.20071012.724442)

On Monday 16 February 2009 11:07:56 you wrote:
> 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?
Normally install always changes the timestamps, but with -C not. This is 
definitely a change of behavior. The option is necessary I think.

> > +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
The idea of 64KiB on stack allocated buffers was taken from RHEL4 
implementation. But you are right - it can be problem on some platforms.
In this case it should be allocated dynamically. Any other ideas?


Kamil




reply via email to

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