Gentoo Archives: gentoo-user

From: Etaoin Shrdlu <shrdlu@×××××××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] md5sum for directories?
Date: Sun, 24 Feb 2008 11:34:08
Message-Id: 200802241246.35965.shrdlu@unlimitedmail.org
In Reply to: [gentoo-user] md5sum for directories? by Stroller
1 On Sunday 24 February 2008, Stroller wrote:
2
3 > I've done this loads in the past, and never been aware of any file
4 > corruption, but I guess I'm just paranoid today. Perhaps I shouldn't
5 > use the -v flags during my copy - it's reassuring to see the files
6 > being copied, but what if I overlooked a bunch of errors in the
7 > middle of all those thousands of "copied successfully" confirmations?
8 > What if something has gone wrong during one of the two copies?
9
10 Well, in that case cp will have a nnonzero exit status. Look:
11
12 $ ls -l
13 total 12
14 -rw-r--r-- 1 kermit users 4 2008-02-24 12:30 a
15 -rw-r--r-- 1 kermit users 12 2008-02-24 12:30 b
16 drwxr-xr-x 2 kermit users 4096 2008-02-24 12:30 destdir
17 $ ls -l destdir
18 total 0
19 $ chmod 000 b
20 $ ls -l
21 total 12
22 -rw-r--r-- 1 kermit users 4 2008-02-24 12:30 a
23 ---------- 1 kermit users 12 2008-02-24 12:30 b
24 drwxr-xr-x 2 kermit users 4096 2008-02-24 12:30 destdir
25 $ cp a b destdir
26 cp: cannot open `b' for reading: Permission denied
27 $ echo $?
28 1
29 $ ls -l destdir
30 total 4
31 -rw-r--r-- 1 kermit users 4 2008-02-24 12:31 a
32
33 I think this should hold for the majority of cases/errors cp might
34 encounter during the copy.
35 Of course, this does not detect a succesful, but somehow corrupted, copy
36 (which should be exceptionally rare, anyway).
37
38 > So my question is:
39 >
40 > Is there any way to check the integrity of copied directories, to be
41 > sure that none of the files or sub-directories in them have become
42 > damaged during transfer? I'm thinking of something like md5sum for
43 > directories.
44
45 I'm not aware of any such tool (which might exist nonetheless, of
46 course). However, on the filesystem, the objects that we
47 call "directories" are just index files holding filenames and pointers
48 to inodes. Running a checksum on the directories themselves would not
49 guarantee against corruption of any of the contained files, since file
50 data is not contained in the directory. Thus, to be accurate, such a
51 tool would have to scan the directory, find each file, and perform a
52 checksum on it, which would result in something not much different from
53 the find command you suggested, in terms of resource usage.
54 --
55 gentoo-user@l.g.o mailing list

Replies

Subject Author
Re: [gentoo-user] md5sum for directories? Stroller <stroller@××××××××××××××××××.uk>