Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Dec 2008 22:28:53 -0500
From:      Lowell Gilbert <freebsd-questions-local@be-well.ilk.org>
To:        Gary Kline <kline@thought.org>
Cc:        FreeBSD Mailing List <freebsd-questions@FreeBSD.ORG>
Subject:   Re: how can i be certain that a file has copied exactly?
Message-ID:  <44wsdmpa8a.fsf@lowell-desk.lan>
In-Reply-To: <20081227021022.GD29639@thought.org> (Gary Kline's message of "Fri\, 26 Dec 2008 18\:10\:23 -0800")
References:  <20081227011335.GA29354@thought.org> <44bpuyh076.fsf@lowell-desk.lan> <20081227021022.GD29639@thought.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Gary Kline <kline@thought.org> writes:

> On Fri, Dec 26, 2008 at 08:32:45PM -0500, Lowell Gilbert wrote:
>> Gary Kline <kline@thought.org> 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/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?44wsdmpa8a.fsf>