----------------------- AmigaOS 3.2 project --------------------------

MD5Sum 47.1 (10.4.2020)

- Backport of MD5Sum 52.2.


MD5Sum 47.2 (24.12.2020)

- The CHECK option did not compare the checksums correctly,
  invariably reporting all the files as not matching the
  recorded checksums. Fixed. Thanks go to Ignacio Gully for
  reporting the problem!

- Just to be on the safe side, now clears the allocated
  AnchorPath buffer after each MatchEnd() call so that a
  subsequent MatchFirst() call will no longer easily trigger
  a Kickstart 2.x/3.0 dos.library bug.


MD5Sum 47.3 (26.12.2020)

- Clearing the AnchorPath buffer was unnecessary. Hash collision
  with my memory of how ReadArgs() has to have its RDArg parameter
  reset before calling ReadArgs() again for Kickstart 2.x/3.0 :-/

- Now handles files with wildcard pattern characters in their names
  like the "Type" command does. First we try to get a lock on what
  could be a directory entry, and then we proceed to check if it its
  indeed a file. If any of that should fail, MatchFirst() will be
  called instead.


MD5Sum 47.4 (6.1.2021)

- Files with wildcard characters in their names are really hard to
  support if you try to stick with the MatchFirst/MatchNext API.
  You can clear the AnchorPath->ap_Flags APF_ITSWILD flag if you
  want to, but in practice the MatchFirst() call will first try
  to match the pattern and end up scanning the entire given
  directory before giving up. So that's not a viable option here.
  So, back to square one: don't try to support path or file names
  with wildcard characters :-(

- Reworked how the AnchorPath passed to MatchFirst() is initialized.
  It must be cleared before MatchFirst() is used, and all the options
  need to be set again to be on the safe side. MatchFirst() is not
  safe to be used after MatchEnd() has been called since the flags
  and reserved fields will remain unchanged.


MD5Sum 47.5 (21.2.2021)

- When using the sort option, all the entries stored in the tree list
  would be allocated from memory pools if running under Kickstart 3.0
  or higher. But if only Kickstart 2.04 was available, that memory was
  never even freed. Fixed.

- Found another issue with the memory allocated for the sorted output:
  memory could be left unfreed if an error occured between allocating
  the memory and storing data in it. Fixed.

- When reading the raw disk data from a partition or drive, the read
  buffer size now defaults to the double the size of a complete track,
  memory permitting. No more than 65536 bytes will be used for the read
  buffer in total, and any such size is limited by the MaxTransfer value
  of the partition. Previously, the default buffer size was limited to
  4096 bytes. Note that the BUFFERSIZE command line parameter will
  always override the default read buffer size.

  What's the point of dynamically adjusting the read buffer size? Raw
  disk read performance can improve tenfold because of it. That can
  make the difference between waiting 30 minutes for it to finish or
  three minutes...

- Added the DISKREADCOMMAND option (not yet documented) which allows
  you to override the device command which is used when reading data
  from a partition/disk larger than 4 GiBytes. Options are AUTO (the
  default), NSD64 and TD64. AUTO will figure out if the driver prefers
  NSD64 over TD64, unless it crashes... In that case, you might want to
  use the DISKREADCOMMAND option and pick the command variant which
  works for you.

- Specific testing for the reported crashes on 68000 system still
  needs to be done, e.g. testing which different stack sizes,
  replacing the MD5, SHA1 or SHA256 algorithms, etc.


MD5Sum 47.6 (22.2.2021)

- Changed the option DISKREADCOMMAND option to DISKACCESS and documented
  it. It now matches what Disk Doctor uses, both in name and semantics.

- The CHECK option failed to treat missing devices consistently. These
  should have been ignored with an optional warning, but this feature
  only worked for missing files. Fixed.

- The read_line() function no longer makes an attempt to reallocate the
  read buffer. This is only necessary when the buffer has not been
  allocated yet.

- If there's a device node corresponding to the async file's underlying
  file handle, we now read the sector size from its DOS environment
  vector, too, for good measure. Just in case the previous ExamineFH()
  may have failed (such as for CDFileSystem).

- General cleanup of function, variable and parameter names to better
  reflect their respective purposes.


MD5Sum 47.7 (3.3.2021)

- Let's make this program less complex for Kickstart 2.04 by linking
  against amiga.lib/pools.lib, which allows us to do away with all the
  separate memory cleanup operations and stick with pools. The drawback
  here is, however, that the program will become larger by about 500
  bytes...


MD5Sum 47.8 (5.3.2021)

- Now uses SysBase for making exec.library function calls instead of
  refetching the address of the exec.library base from chip memory.

- Switched over to use memory pools for all memory allocations which
  have no peculiar other requirements. This simplifies memory allocation
  cleanup and saves a bit of space.


MD5Sum 47.9 (6.9.2021)

- When adapting the "asyncio.c" source code for reading the file data
  I should have paid more attention to how the data is processed. While the
  data itself was processed properly by the cryptographic hash function
  (e.g. MD5) the function itself could return the wrong number of
  bytes. This would have consequences for calculating the final checksum
  which involves appending the size of the file.

  The code is now much simplified because by the time the processing is
  performed one packet has just returned and the next packet needs to be
  queued while the one which just arrived has to be processed. And
  that's basically it, with error checking, of course.

- Dropped code which is not needed because the MD5Sum command uses pools
  for memory management which require no separate memory deallocation
  functions. The pool is just deleted before the command exits.

- Verified that attempting to read from a read-protected file (with a file
  system which pays attention to this protection state) will reliably produce
  an error which MD5Sum will print and then stop further processing.

- Made sure that MatchEnd() is only ever called if MatchFirst() had been
  used first. This used to be far too complicated.

- Finally found the source of the memory leak trouble: code reuse which
  didn't take into account that the memory pool had already been created
  and did not need to be created again...


MD5Sum 47.10 (8.9.2021)

- Refactored for size and (hopefully) clarity (structure, names of
  functions and variables). Not done with that yet, though...


MD5Sum 47.11 (8.9.2021)

- More refactoring for size and clarity. Added further validation
  test to the processing of the CHECK file.


MD5Sum 47.12 (11.9.2021)

- Even more refactoring for size and clarity. Also updated the
  code documentation.

- The code which updates the progress on the file/device being
  processed and prints the current state is now shared between
  the file/device processing functions. It used to be that the
  file/device processing functions had their separate but
  identical implementations of it.

- Added error checking to the progress information output
  function so that a single failed write attempt will shut
  it down. Processing will continue without showing further
  updates. Since the very attempt to trying to show an
  error message for being unable to show the progress
  information is likely to fail, too, we won't even try
  to do that...

- Much better handling of read errors when processing files.
  Previously, an error could be treated like "end of file".
  Ouch :-(


MD5Sum 47.13 (11.9.2021)

- Ouch, the directory hierarchy level is part of the
  sorting function's metric and I broke it during
  the refactoring. Now the level is set up prior to
  sorting and things are back to normal again.


MD5Sum 47.14 (12.9.2021)

- Replaced part of the old 64 bit integer arithmetic functions with
  more modern and less complex variants. Also added new functions which
  perform arithmetic overflow testing for addition and multiplication.

- Added boundary checking for the parameters which define the position
  and size of a partition on a storage medium. These checks make sure
  that the number of sectors and cylinders involved never reaches or
  exceeds 2^32. Arithmetic overflow when calculating position or
  size information based upon the number of cylinders, number of
  surfaces and number of sectors per track is now detected and flagged
  as an error.


MD5Sum 47.15 (28.9.2021)

- When evaluating the address mask of a file system device, the most
  significant 8 bits of the mask are now checked: if they are all zero
  then the memory allocated for the device read buffers will be
  augmented to use MEMF_24BITDMA. The same is true when setting up the
  buffer used for reading from a file.

- Corrected the code documentation for the multiply_64_by_32_to_64()
  function which had been in need of correction for at least 10 years.

- Simplified how the file system device read commands are set up
  for partitions which require 64 bit I/O operations and those which
  squeak by with the simple CMD_READ command. The code now does this
  without making separate, different setups for CMD_READ and for
  everything else.

- When given a volume name rather than a file system device name the
  process of figuring out which file system device the volume is associated
  with is now much simplified and no longer unlocks and relocks the
  DOS list.

- Reworked and simplified the calculations which are used in preparing
  for reading the file system partition data. This also included subtle
  bug fixes for overflow detection and enabling a file system device
  to have 2^32 cylinders. A new limitation is introduced for the number
  of sectors that may be used for a file system device partition: for
  now these must not exceed 2^32.

- Updated the code which figures out the actual buffer size for reading
  from a file system partition. The idea is to avoid numeric overflows
  and to keep the buffer size reasonably sane without spending to much
  memory.

- Added to the code documentation.


MD5Sum 47.16 (11.10.2021)

- Added a workaround for a bug in the dos.library/ErrorReport function
  which made read-protected files appear to be no different from
  empty files. This bug has been around since at least 1990 and the
  asynchronous file I/O functions in MD5Sum are particularly easily
  tripped up by it :-(

  Thanks go to Gerben van Kesteren for reporting this cleverly
  hidden obscure problem!

- Rewrote the MatchFirst/MatchNext scanning code again to be slightly
  more in line with how the "List" shell command approaches it.


MD5Sum 47.17 (11.10.2021)

- Fix for funny NUL-terminated BCPL strings which may cause
  further headaches down the line. Just spotted this in the
  area of a bug fix I had just added.


MD5Sum 47.18 (16.10.2021)

- Added another sanity check for the partition parameters to detect if
  the last sector is inaccessible because its logical block address is
  a number >= 2^32. This is making assumptions about the underlying
  mass storage device driver which might not apply, but better safe
  than sorry. Note that MD5Sum will complain with "object wrong type"
  for partitions which fail any sanity check performed, which is more
  than a little obscure. The documentation now mentions this in the
  "NOTES" section.

----------------------- AmigaOS 3.3 project --------------------------

MD5Sum 47.19 (6.11.2021)

- Added a workaround for a bug in the V37 dos.library FGets() function
  which has a side-effect in writing an additional NUL byte beyond the
  last character read. This can overflow the line buffer. The workaround
  is necessary because MD5Sum is by design compatible with Kickstart 2.04.


MD5Sum 47.20 (10.12.2022)

- MD5Sum should not have used AnchorPath->ap_Current->an_Info during
  MatchFirst()..MatchNext() processing. While it is not harmful to have
  done so (it's actually an arp.library legacy feature, if you will),
  the proper way is to use AnchorPath->ap_Info instead.


MD5Sum 47.21 (16.3.2024)

- Now makes use of the SAS/C 6.58 built-in rol() and ror() functions which
  save both code size and still produce the same results as the macros
  which were used in their place before.
