From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([69.77.167.62] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1JTF7Q-0002gJ-LK for garchives@archives.gentoo.org; Sun, 24 Feb 2008 11:34:08 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id BB089E0391; Sun, 24 Feb 2008 11:34:06 +0000 (UTC) Received: from dcnode-02.unlimitedmail.net (unknown [212.85.44.112]) by pigeon.gentoo.org (Postfix) with ESMTP id 6AA72E0391 for ; Sun, 24 Feb 2008 11:34:06 +0000 (UTC) Received: from ppp.zz ([137.204.208.98]) (authenticated bits=0) by dcnode-02.unlimitedmail.net (8.14.2/8.14.0) with ESMTP id m1OBXt0L024682 for ; Sun, 24 Feb 2008 12:33:56 +0100 From: Etaoin Shrdlu To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] md5sum for directories? Date: Sun, 24 Feb 2008 12:46:35 +0100 User-Agent: KMail/1.9.7 References: <7B4F9B31-ABDE-47C7-B841-2D3902E7B3DD@stellar.eclipse.co.uk> In-Reply-To: <7B4F9B31-ABDE-47C7-B841-2D3902E7B3DD@stellar.eclipse.co.uk> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200802241246.35965.shrdlu@unlimitedmail.org> X-UnlimitedMail-MailScanner-From: shrdlu@unlimitedmail.org X-Spam-Status: No X-Archives-Salt: ce42bdaf-06f3-43ac-9ca3-a68207fa37b4 X-Archives-Hash: 8a127ed9eb4493b1e3b5b2424e086e11 On Sunday 24 February 2008, Stroller wrote: > I've done this loads in the past, and never been aware of any file > corruption, but I guess I'm just paranoid today. Perhaps I shouldn't > use the -v flags during my copy - it's reassuring to see the files > being copied, but what if I overlooked a bunch of errors in the > middle of all those thousands of "copied successfully" confirmations? > What if something has gone wrong during one of the two copies? Well, in that case cp will have a nnonzero exit status. Look: $ ls -l total 12 -rw-r--r-- 1 kermit users 4 2008-02-24 12:30 a -rw-r--r-- 1 kermit users 12 2008-02-24 12:30 b drwxr-xr-x 2 kermit users 4096 2008-02-24 12:30 destdir $ ls -l destdir total 0 $ chmod 000 b $ ls -l total 12 -rw-r--r-- 1 kermit users 4 2008-02-24 12:30 a ---------- 1 kermit users 12 2008-02-24 12:30 b drwxr-xr-x 2 kermit users 4096 2008-02-24 12:30 destdir $ cp a b destdir cp: cannot open `b' for reading: Permission denied $ echo $? 1 $ ls -l destdir total 4 -rw-r--r-- 1 kermit users 4 2008-02-24 12:31 a I think this should hold for the majority of cases/errors cp might encounter during the copy. Of course, this does not detect a succesful, but somehow corrupted, copy (which should be exceptionally rare, anyway). > So my question is: > > Is there any way to check the integrity of copied directories, to be > sure that none of the files or sub-directories in them have become > damaged during transfer? I'm thinking of something like md5sum for > directories. I'm not aware of any such tool (which might exist nonetheless, of course). However, on the filesystem, the objects that we call "directories" are just index files holding filenames and pointers to inodes. Running a checksum on the directories themselves would not guarantee against corruption of any of the contained files, since file data is not contained in the directory. Thus, to be accurate, such a tool would have to scan the directory, find each file, and perform a checksum on it, which would result in something not much different from the find command you suggested, in terms of resource usage. -- gentoo-user@lists.gentoo.org mailing list