Directory csum / cksum | Unix Linux Forums | AIX

  Go Back    


AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

Directory csum / cksum

AIX


Tags
aix, unix

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-05-2013
Devyn Devyn is offline
Registered User
 
Join Date: Feb 2005
Last Activity: 27 May 2014, 2:04 PM EDT
Posts: 34
Thanks: 0
Thanked 1 Time in 1 Post
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
Sponsored Links
    #2  
Old 02-05-2013
Citroen Citroen is offline
Registered User
 
Join Date: Jul 2012
Last Activity: 13 March 2013, 9:10 AM EDT
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Hi,

Code:
man csum

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

Code:
man cksum

Displays the checksum and byte count of a file.

Doesn't work on directories.

Regards
Sponsored Links
    #3  
Old 02-11-2013
MichaelFelt MichaelFelt is offline
Registered User
 
Join Date: Nov 2012
Last Activity: 11 December 2013, 7:33 AM EST
Location: on the road for work; home is private time
Posts: 311
Thanks: 6
Thanked 76 Times in 71 Posts
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.

Code:
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:

Code:
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.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
command to find cksum of all files inside a directory? ezee UNIX for Dummies Questions & Answers 3 11-10-2011 11:11 PM
cksum for all files in home directory moe458 UNIX for Advanced & Expert Users 4 09-29-2010 05:15 PM
Cksum dependencies vibhor_agarwali UNIX for Advanced & Expert Users 3 09-05-2007 02:38 AM
using cksum leeRoberts2007 Shell Programming and Scripting 4 05-31-2007 09:30 PM
cksum question rjsha1 Shell Programming and Scripting 4 01-17-2006 10:44 AM



All times are GMT -4. The time now is 11:41 AM.