From owner-freebsd-hackers@FreeBSD.ORG Mon Jan 26 13:08:35 2009 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BD0231065674; Mon, 26 Jan 2009 13:08:35 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (unknown [IPv6:2a01:170:102f::2]) by mx1.freebsd.org (Postfix) with ESMTP id 26B0B8FC14; Mon, 26 Jan 2009 13:08:34 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (localhost [127.0.0.1]) by lurza.secnetix.de (8.14.3/8.14.3) with ESMTP id n0QD8X38058157; Mon, 26 Jan 2009 14:08:33 +0100 (CET) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.3/8.14.3/Submit) id n0QD8WwD058156; Mon, 26 Jan 2009 14:08:32 +0100 (CET) (envelope-from olli) From: Oliver Fromme Message-Id: <200901261308.n0QD8WwD058156@lurza.secnetix.de> To: dougb@FreeBSD.org (Doug Barton) Date: Mon, 26 Jan 2009 14:08:32 +0100 (CET) In-Reply-To: <497B9743.6080109@FreeBSD.org> X-Mailer: ELM [version 2.5 PL8] MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Mon, 26 Jan 2009 14:08:33 +0100 (CET) Cc: freebsd-hackers@FreeBSD.org Subject: Re: freebsd-update's install_verify routine excessive stating X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jan 2009 13:08:36 -0000 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.