[squid-users] swap.state and perl unpack question

From: OTR Comm <otrcomm@dont-contact.us>
Date: Sat, 06 Mar 2004 18:39:23 -0700

Hello,

Does anyone know how I can access the fields in the swap.state file
using the perl unpack function?

I have read that records in swap.state are 48 byte fixed-size, but I
don't know what the binary layout of each record is, so I can't
determine a particular field size.

I want to get to the 'timestamp' field, which I have read is a four byte
field at an offset of 5 bytes into the record, but I am having
problems. More than likely it is my ignorance of how unpack works.

I have tried:

if (read SWAP_STATE, $typeandlength, 4, 5) {

  ($metavalue,$metalength) = unpack "CI", $typeandlength;
        
  print "\ntypeandlength: $typeandlength\n";
  print "metavalue: $metavalue\n";
}

and I have tried various combinations of the template (i.e., "CI" in my
example), but $metavalue always resolves to 1.

I would also like to get to the 'lastref', 'expires', 'last-modified',
and 'refcount' fields in the swap.state records, but I will be happy
with the 'timestamp.'

Any help here would be greatly appreciated.

Thank you,

Murrah Boswell
Received on Sat Mar 06 2004 - 18:39:31 MST

This archive was generated by hypermail pre-2.1.9 : Thu Apr 01 2004 - 12:00:01 MST