From owner-freebsd-questions@FreeBSD.ORG Sat Dec 27 03:28:58 2008 Return-Path: Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 444A6106564A for ; Sat, 27 Dec 2008 03:28:58 +0000 (UTC) (envelope-from freebsd-questions-local@be-well.ilk.org) Received: from mail1.sea5.speakeasy.net (mail1.sea5.speakeasy.net [69.17.117.3]) by mx1.freebsd.org (Postfix) with ESMTP id 1E0FF8FC1A for ; Sat, 27 Dec 2008 03:28:58 +0000 (UTC) (envelope-from freebsd-questions-local@be-well.ilk.org) Received: (qmail 24835 invoked from network); 27 Dec 2008 03:28:57 -0000 Received: from dsl092-078-145.bos1.dsl.speakeasy.net (HELO be-well.ilk.org) ([66.92.78.145]) (envelope-sender ) by mail1.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 27 Dec 2008 03:28:57 -0000 Received: from lowell-desk.lan (lowell-desk.lan [172.30.250.6]) by be-well.ilk.org (Postfix) with ESMTP id E5B6E50820; Fri, 26 Dec 2008 22:28:53 -0500 (EST) Received: by lowell-desk.lan (Postfix, from userid 1147) id 5187A1CCFA; Fri, 26 Dec 2008 22:28:53 -0500 (EST) To: Gary Kline References: <20081227011335.GA29354@thought.org> <44bpuyh076.fsf@lowell-desk.lan> <20081227021022.GD29639@thought.org> From: Lowell Gilbert Date: Fri, 26 Dec 2008 22:28:53 -0500 In-Reply-To: <20081227021022.GD29639@thought.org> (Gary Kline's message of "Fri\, 26 Dec 2008 18\:10\:23 -0800") Message-ID: <44wsdmpa8a.fsf@lowell-desk.lan> User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: FreeBSD Mailing List Subject: Re: how can i be certain that a file has copied exactly? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Dec 2008 03:28:58 -0000 Gary Kline writes: > On Fri, Dec 26, 2008 at 08:32:45PM -0500, Lowell Gilbert wrote: >> Gary Kline writes: >> >> > is there a way i can be sure that my little C program has copied a >> > dos/win file named, say, foo.htm\;7 to simply foo.htm? >> > >> > my program uses fopen/fgets/fputs to copy the markup files. of >> > the several i have copied, no problem. unless i hack cmp or diff, >> > i have to avoid the shell. >> > >> > any ideas? in other words, does anybody have a prefab cmp(oldfile, newfile) >> > fn? >> >> mtree(1) handles whole ranges of files. >> >> For a single file, you could use some kind of checksum in your program >> or externally, but in general it will be comparing against the cache of >> the file's buffers, not against what is really on disk, so if you >> suspect an operating system or hardware-write bug, you won't spot it >> immediately. >> >> What, precisely, would you like to protect against? > > > again bad copies! mtree might work, but given the number of > files, i'd be better off hacking usr.bin/cmp !! Bad copies caused by bugs in your software, or bad copies caused by bugs in FreeBSD? Or problems with your hardware? Once you know what you're after, you can start figuring out how to get it. If you don't know that yet, don't waste your time chasing it. -- Lowell Gilbert, embedded/networking software engineer, Boston area http://be-well.ilk.org/~lowell/