Directory csum / cksum

I've created a directory in /tmp/csum-test on AIX 6.1. Then another under AIX 7.1 host called /tmp/csum-test. There is no files in the directories.

When I run csum -h SHA1 /tmp/csum-test on AIX 6.1 host it gives me a different value then if I run csum -h SHA1 /tmp/csum-test under the AIX 7.1 host. Granted the csum binaries are different however should csum have reported a different value and what is it including in it's comparisons for directories and files?

In simpler terms, what is this command comparing? I've searched around but couldn't find an answer that explicitly outlines the logic.

Cheers,
Tom

Hi,

man csum

The csum command calculates a message digest for the specified files using the specified hash algorithm.

man cksum

Displays the checksum and byte count of a file.

Doesn't work on directories.

Regards

The reason it does not work on directories is because a very vital part of a directory entry is the first two bytes which is the inode number of an entry.

The first two entries of a directory are named . and ..
So, if either inode numbers are different csum and/or cksum will report generally report different values.

od -dc /some/directory

read: octalDump -decimalCharacter /some/directory
This will output two lines for each entry in the directory /some/directory
The first line: first number is the inode number; second line (ignore first two values (are inode number in character notation) - remaining bytes are the file/directory name)
Example:

michael@x054:[/]ls -lid /x /y
17424 drwxr-xr-x 2 pconsole pconsole 256 May 15  2012 /x
20576 drwxr-x--- 2 root     system   256 Feb 11 16:00 /y
michael@x054:[/]od -dc /x    
0000000   17424   11776       0       0       0       0       0       0
          D 020   .  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
0000020       2   11822       0       0       0       0       0       0
         \0 002   .   .  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
0000040
michael@x054:[/]od -dc /y    
0000000   20576   11776       0       0       0       0       0       0
          P   `   .  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
0000020       2   11822       0       0       0       0       0       0
         \0 002   .   .  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
0000040

Hope this helps/explains WHY cksum/csum does not work on directories.