Gentoo Archives: gentoo-user

From: Stroller <stroller@××××××××××××××××××.uk>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] md5sum for directories?
Date: Wed, 27 Feb 2008 00:38:14
Message-Id: 4D6E8244-D1D1-4F30-8BEE-83433B1389F9@stellar.eclipse.co.uk
In Reply to: Re: [gentoo-user] md5sum for directories? by Etaoin Shrdlu
1 On 24 Feb 2008, at 11:46, Etaoin Shrdlu wrote:
2
3 > On Sunday 24 February 2008, Stroller wrote:
4 >
5 >> I've done this loads in the past, and never been aware of any file
6 >> corruption, but I guess I'm just paranoid today. Perhaps I shouldn't
7 >> use the -v flags during my copy - it's reassuring to see the files
8 >> being copied, but what if I overlooked a bunch of errors in the
9 >> middle of all those thousands of "copied successfully" confirmations?
10 >> What if something has gone wrong during one of the two copies?
11 >
12 > Well, in that case cp will have a nnonzero exit status. Look:
13 >
14 > ...
15 > $ cp a b destdir
16 > cp: cannot open `b' for reading: Permission denied
17 > $ echo $?
18 > 1
19 > ...
20 > I think this should hold for the majority of cases/errors cp might
21 > encounter during the copy.
22
23 Good point. I should have checked this when I first made the copy
24 using cp, and will do so in the future.
25
26 > Of course, this does not detect a succesful, but somehow corrupted,
27 > copy
28 > (which should be exceptionally rare, anyway).
29
30 Well perhaps I'm just being paranoid today.
31 But how do I know that a successful, but somehow corrupted, copy has
32 not occurred?
33
34 What makes you confident that these are rare? I don't ask this to be
35 antagonistic, just to increase my own confidence in the `cp` command.
36
37 >> Is there any way to check the integrity of copied directories, to be
38 >> sure that none of the files or sub-directories in them have become
39 >> damaged during transfer? I'm thinking of something like md5sum for
40 >> directories.
41 >
42 > I'm not aware of any such tool (which might exist nonetheless, of
43 > course). However, on the filesystem, the objects that we
44 > call "directories" are just index files holding filenames and pointers
45 > to inodes. Running a checksum on the directories themselves would not
46 > guarantee against corruption of any of the contained files, since file
47 > data is not contained in the directory.
48
49 Naturally.
50
51 Perhaps I should have phrased my question differently: "Is there any
52 way to recursively check the integrity of copied directories of
53 files?" However the words "to be sure that none of the files or sub-
54 directories in them have become damaged during transfer"
55
56 > Thus, to be accurate, such a
57 > tool would have to scan the directory, find each file, and perform a
58 > checksum on it, which would result in something not much different
59 > from
60 > the find command you suggested, in terms of resource usage.
61
62
63 I have to admit that I haven't run this command and I don't have any
64 idea what its actual resource usage would be. I guess I'd be happy
65 with a lower-grade of checksumming, if it would reduce the runtime to
66 acceptable levels. With md5sum one can be - barring certain malicious
67 external attacks - quite certain that a copied file is identical to
68 the original. I would be happy with a "the file's there and it looks
69 ok" level of confidence.
70
71 Stroller.
72
73 --
74 gentoo-user@l.g.o mailing list

Replies

Subject Author
Re: [gentoo-user] md5sum for directories? Etaoin Shrdlu <shrdlu@×××××××××××××.org>