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

From: Henrik Nordstrom <[email protected]>
Date: Sun, 7 Mar 2004 09:55:24 +0100 (CET)

On Sat, 6 Mar 2004, OTR Comm wrote:

> 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.

The binary layout is described in the Programmers Guide section on
swap.state:
http://www.squid-cache.org/Doc/Prog-Guide/prog-guide-27.html#ss27.1

please note that field alignment applies as per the requirements your
platform so there may be padding between smaller and larger fields. On x86
this padding is seen between the op and swap_file_number fields.

Detailed layout on x86: offset(length)

 0(1) char op;
 1(3) char padding[3]
 4(4) int swap_file_number;
 8(4) time_t timestamp;
12(4) time_t lastref;
16(4) time_t expires;
20(4) time_t lastmod;
24(4) size_t swap_file_sz;
28(2) u_short refcount;
30(2) u_short flags;
32(16) unsigned char key[MD5_DIGEST_CHARS];

On other architectures (or even compiler flags) the alignment requirements
and size of time_t and size_t may be different, resulting in a slightly
different binary layout.

Most if not all of this information is also logged in swap.log where you
also have access to the URL etc, provided it's known by Squid at the
time.

Regards
Henrik
Received on Sun Mar 07 2004 - 01:55:33 MST

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