http://qs1969.pair.com?node_id=97098


in reply to Re: Checksumming dynamically created media (code)
in thread Checksumming dynamically created media (code)

This is a great idea.

Can I use seek on a raw device? The problem we run into if we're going to read the whole device, of course, is that the system (burly as it may be) does not have 4.5gb of ram, and 3.5gb of swap is unweildy. So we can't just slurp the whole disk in and checksum it... I was thinking that if we can read in the first gig and the last gig and provide two checksums, we can be reasonably assured that the middle 2.5 gig are okay.

dep.

--
Laziness, Impatience, Hubris, and Generosity.

  • Comment on Re (2): Checksumming dynamically created media (code)

Replies are listed 'Best First'.
Re: Re (2): Checksumming dynamically created media (code)
by bikeNomad (Priest) on Jul 16, 2001 at 21:30 UTC
    Compress::Zlib's crc32 function can update a CRC in pieces; you can call it with an existing CRC to update it. So you read a buffer full at a time and update your CRC:

    use Compress::Zlib my $crc = 0; while ($fh->read($buffer)) { $crc = Compress::Zlib::crc32($buffer, $crc); }