freebsd-update's install_verify routine excessive stating

Oliver Fromme olli at lurza.secnetix.de
Mon Jan 26 05:08:36 PST 2009


Doug Barton wrote:
 > Oliver Fromme wrote:
 > > However, I think cmp wouldn't work here, because cmp only
 > > detects whether there is a difference between two files.
 > > 
 > > In this case we need to know if one file is a subset of
 > > the other:  For every hash there must be a .gz file, but
 > > it doesn't hurt if there are more files.  So the list of
 > > hashes can be a subset of the list of .gz files, they
 > > don't have to be equal.
 > 
 > Hrrmmm, that doesn't sound like a good thing to me. I would think that
 > the hash list is pretty useless if it doesn't cover all the files.

Right, that's why there should be a file for every entry in
the hash list -- but not necessarily the other way around.
I.e. I think freebsd-update should not abort if there are
superfluous files.

 > > While I were at it, I skimmed through the cmp source and
 > > found a bug (or inefficiency):  When the -s option is
 > > specified (i.e. silent, exit code only), it would be
 > > sufficient to terminate when the first difference is
 > > encountered.  But it always compares the whole files.
 > > I'll try to make a patch to improve this.
 > 
 > That would definitely be appreciated, I use cmp -s in several places
 > in portmaster where that speed-up would make a non-trivial difference.
 > If there is anything I can do to help please let me know.

I was wrong, the -s option behaves correctly.  Sorry for
the confusion.  I ended up in the wrong code path in the
source (I was confused by the fact that the diffmsg()
function never returns).  Indeed, cmp(1) stops comparing
the files as son as it finds the first differing byte,
unless you use the -l or -x option.

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

One Unix to rule them all, One Resolver to find them,
One IP to bring them all and in the zone to bind them.


More information about the freebsd-hackers mailing list