On 11/05/2013 07:34 PM, Nico Kadel-Garcia wrote:
On Tue, Nov 5, 2013 at 7:35 PM, Yasha Karant<[email protected]>  wrote:
I have not tried this yet, but the statement is that "The cmp utility
compares two files of any type and writes the results to the standard
output."

Will this work for mount points or device special files that are mounted on
mount points, allowing one to compare two full directory tree hierarchies?

Yup! The idea that "a file is a file, even when it's a mountpoint or a
symlink or a pipe or a socket" is fundamental to the concept of what a
"file" is in libc and in the kernel. itself.

That is, using the situation elaborated below (that is, earlier in this
thread), will

  cmp /dev/loop0 /dev/sr0

Should work, if those are the valid device names. If you can 'md5sum'
it, you can 'cmp' it.


I use the following 'rawread' script to compare my ISO to burned media. It is then run through a hash algorithm (md5, sha, etc) to compare. the RAW_DEV should be the device node associated with the optical drive.


#!/bin/sh
if [ -n "$1" ] ; then
  RAW_DEV=$1
fi

blocksize=`isoinfo -d -i $RAW_DEV | grep "^Logical block size is:" | cut -d " " -f 5`
if test "$blocksize" = ""; then
        echo "FATAL ERROR: Blank blocksize" >&2
        exit
fi

blockcount=`isoinfo -d -i $RAW_DEV | grep "^Volume size is:" | cut -d " " -f 4`
if test "$blockcount" = ""; then
        echo "FATAL ERROR: Blank blockcount" >&2
        exit
fi

dd if=$RAW_DEV bs=$blocksize count=$blockcount conv=notrunc,noerror

Here is the portion comparison script, that calls 'rawread':
# Get the iso MD5
echo "Generating MD5 for $TARGET_FILE..."
ISO_MD5=`md5sum $TARGET_FILE | cut -d " " -f 1`

# Get the disc MD5
echo "Generating MD5 for CD/DVD..."
DISC_MD5=`${CDREC_DIR}/rawread $RAW_DEV | md5sum | cut -d " " -f 1`

echo ""
echo "ISO  MD5: $ISO_MD5"
echo "DISC MD5: $DISC_MD5"
echo ""

echo -n "Verification: "

if [ "$ISO_MD5" = "$DISC_MD5" ] ; then
  echo "PASSED"
  exit 0
else
  echo "FAILED"
  exit 1
fi


I have been using this long before I used any gui burning utilities. It has a good track record for me. Extracting the ISO information and using the above dd options should catch any media errors occurring.

-Mark

--
Mr. Mark V. Stodola
Senior Control Systems Engineer

National Electrostatics Corp.
P.O. Box 620310
Middleton, WI 53562-0310 USA
Phone: (608) 831-7600
Fax: (608) 831-9591

Reply via email to