home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 1 / GoldFishApril1994_CD1.img / d1xx / d133 / crc / information < prev    next >
Text File  |  1988-03-13  |  8KB  |  265 lines

  1.  
  2.  
  3.                   Information On CRC & RLS
  4.  
  5. INTRODUCTION 
  6.  
  7.    This file describes two programs, CRC and RLS. CRC
  8.    calculates a 16 bit crc (cyclic redundancy check) using
  9.    the CCITT polynomial. RLS is used to recursively list the
  10.    paths of all files contained within a given directory. 
  11.  
  12.    CRC was written mainly to verify files on a recoverable
  13.    RAM disk, after a system crash. CRC's usefulness is not
  14.    limited to RAM disks. CRC is useful whenever it is
  15.    neccessary or desireable to verify the contents of a file
  16.    without the inconvenience of actually having direct
  17.    access to both the file in question, and a duplicate. It
  18.    performs essentially the same function as a program
  19.    written for CP/M systems called "CRC.COM" 
  20.  
  21.    RLS was written to make it easy to generate CRC's for all
  22.    files contained in a given directory system. RLS might
  23.    also be used in conjunction with a disk cataloging
  24.    system. 
  25.  
  26.  
  27. RLS 
  28.  
  29.    Many times I've wanted to generate a listing of all the
  30.    files on a disk (with complete pathnames), but never had
  31.    a simple tool that would do it. After a bit of
  32.    frustration of using the AmigaDOS command "DIR" with OPT
  33.    A, into a file, and then editing the file, I decided
  34.    enough was enough. I broke down and wrote RLS. All I have
  35.    to do now is enter "rls >tmp df2:" and all the pathnames
  36.    to all the files on drive df2: are stored in file "tmp". 
  37.  
  38.  
  39. CRC 
  40.  
  41.    CRC provides a means of verifying two files that are
  42.    expected to be exact duplicates, are indeed exact
  43.    duplicates. The two files do not have to be in the same
  44.    place at the same time either. A person could transfer a
  45.    file from his machine to anyone else's. The person at
  46.    each end of the transfer can generate a CRC for his copy
  47.    of the file. If the CRC's match, they can be relatively
  48.    certain (>99%) that the two files are exact duplicates. 
  49.  
  50.    CRC provides an external means of verifying the validity
  51.    of file contents. External in the sense that the user has
  52.    control of when and which files are checked. For example,
  53.    using X-MODEM protocol, a file could be transfered over a
  54.    serial port. The file's contents are only verified as
  55.    each packet is received. After the file has been
  56.    received, the user is on his own in the matter of whether
  57.    the files are correct. 
  58.  
  59.    Another instance would be copying data from a flakey
  60.    disk. The operating system stores some type of crc with
  61.    each sector, but the user doesn't really have access to
  62.    them. Suppose this disk kept having read errors while
  63.  
  64. (11/14/87)                                            Page 1
  65.  
  66.  
  67.  
  68.  
  69.                   Information On CRC & RLS
  70.  
  71.    copying a file off of it. After many tries, a user
  72.    finally was able to make a copy of a file without
  73.    receiving an error message. Further, when the data was
  74.    finally read off the disk, the user doesn't have any
  75.    guarantee that the data was indeed read correctly. If
  76.    things happened just right, the crc might have been read
  77.    erroneously and happened to match erroneous data. This
  78.    isn't likely, but when dealing with a disk that has a
  79.    problem in the first place, the liklihood increases.
  80.    Using CRC, the user has an extra method of verifying the
  81.    file contents. 
  82.  
  83.    CRC parses off file names from the command-line and
  84.    generates a crc for each file. Every time a file is
  85.    changed, the crc generated by "crc" will change. Since
  86.    the crc may only have one of 65,536 different values,
  87.    some files may have the same crc. 
  88.  
  89.    A crc is better than a check-sum for most applications.
  90.    There are a number of reason's for this but one of the
  91.    simplest examples is that inserting a 00 byte into a file
  92.    will never change a simple checksum; it may on the other
  93.    hand change a crc. 
  94.  
  95. Areas of Use 
  96.  
  97.    This program has potential in three areas. The first is
  98.    in disk-to-disk software distribution. A file could be
  99.    generated with crc's for all files on the disk. The disk
  100.    could then be copied and distributed. Each end user could
  101.    then run the "crc" program on all the files on the disk.
  102.    If the crc's generated match the stored crc's, then the
  103.    user can rest assured that the files are likely to be
  104.    exact duplicates. This provides the user a simple means
  105.    of verifying his disk without having to distribute a
  106.    second disk. An excellent application would be the Fred
  107.    Fish disks. Each disk could contain one file containing
  108.    the names and crc's for all files on the disk. Each end
  109.    user/owner of a disk could verify he had an error-free
  110.    copy by simply running "crc". More often than I like, I
  111.    have had to make a copy of a Fred Fish disk that had
  112.    errors. 
  113.  
  114.    The second area of use is in telecomputing. If a BBS made
  115.    a list of crc's available for all their download files,
  116.    users would be able to verify they had a good copy. This
  117.    would also help users identify terminal programs that
  118.    "chop" (binary) files. 
  119.  
  120.    The third area is the real reason I wrote this program in
  121.    the first place, recoverable RAM disks/devices. When a
  122.    program goes hay-wire and causes the system (and that 1
  123.    Tera-Byte RAM disk, you know, the one it took 6 days to
  124.    load from 437 floppies) to go from 7.144 MHz to 0 in 3
  125.    seconds, giving a blasted Guru Meditation message, it's
  126.    real nice to have a recoverable type RAM disk. But, if
  127.    the program went haywire, what kept it from doing a
  128.    scatter shot mess in your RAM disk? Nothing, unless you
  129.  
  130. (11/14/87)                                            Page 2
  131.  
  132.  
  133.  
  134.  
  135.                   Information On CRC & RLS
  136.  
  137.    have some type of hardware protection. And how would you
  138.    notice if one of those scatter shots happened to hit
  139.    maybe one byte of your 100K byte compiler or that neat
  140.    300K CAD program? You probably wouldn't notice right away
  141.    without CRC. According to Murphy's Law, the program would
  142.    work 99.9% of the time you use it; only when you try to
  143.    save what you're working on will it crash the system
  144.    again. Well, if you run all the files on the recoverable
  145.    RAM disk through "crc" at each re-boot and compare the
  146.    crc's to the originals, you can be 99% certain. 
  147.  
  148. Examples 
  149.  
  150.    I regularly use a large recoverable ram disk and use crc
  151.    to verify it's contents after every system crash. A
  152.    simple way to set things up would be this: 
  153.  
  154.    1. generate crc's for all files/commands you intend to
  155.       keep on the RRAM disk. Save the list into a file. Edit
  156.       the listing file; change all the file names to
  157.       reference the RRAM disk. Save this list to the boot
  158.       disk. 
  159.  
  160.       This might be as simple as this: 
  161.  
  162.       crc >listfile df0:c/*
  163.       ; now edit the listfile and change all df0:'s to RRAM: or whatever
  164.       ;  your RRAM disk's device name is
  165.       copy listfile df0:listfile
  166.  
  167.    2. change the startup-sequence on the boot-disk to do the
  168.       following 
  169.  
  170.       failat 11
  171.       crc <df0:lisfile -v
  172.       if ERROR
  173.          echo "errors were detected on RRAM disk"
  174.          makedir RRAM:c
  175.          copy df0:c RRAM:c
  176.       else
  177.          echo "All RRAM files check out, using them"
  178.       endif
  179.  
  180.    To generate crc's for a particular Fish disk, you could
  181.    do this: 
  182.  
  183.    1. Insert the desired Fish disk into drive df1: 
  184.  
  185.    2. Type this into the CLI: 
  186.          rls >ram:tmp 
  187.  
  188.    3. Type this into the CLI: 
  189.          crc >ram:crclist -g ram:tmp 
  190.  
  191.    Now all the crc's should be stored in the file "crclist"
  192.    in RAM:. 
  193.  
  194.    The benefits you gain from using this program may never
  195.  
  196. (11/14/87)                                            Page 3
  197.  
  198.  
  199.  
  200.  
  201.                   Information On CRC & RLS
  202.  
  203.    be noticed. Only pains from not using this program will
  204.    make you appreciate it. 
  205.  
  206.    I hope you never notice, 
  207.        Don Kindred 
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262. (11/14/87)                                            Page 4
  263.  
  264.  
  265.