]>
git.ipfire.org Git - thirdparty/squid.git/blob - scripts/fileno-to-pathname.pl
4 # Convert hexadecimal cache file numbers (from swap log) into full pathnames.
5 # Duane Wessels 6/30/97
7 # 2001-12-18 Adapted for squid-2.x Alain Thivillon <at@rominet.net>
21 my $SWAP_DIR_SHIFT=24;
22 my $SWAP_FILE_MASK=0x00FFFFFF;
24 my $CF = $opt_c || '/usr/local/squid/etc/squid.conf';
25 &usage unless (open (CF,"<$CF"));
31 # cache_dir ufs path size L1 L2
32 if (/^cache_dir\s+(\S+)\s+(\S+)\s+\d+\s+(\S+)\s+(\S+)/i) {
33 $CD[$ncache_dirs] = $2;
34 $L1[$ncache_dirs] = $3;
35 $L2[$ncache_dirs++] = $4;
40 if ($ncache_dirs == 0) {
41 print STDERR "No proper cache_dir line found\n";
47 print &storeSwapFullPath(hex($_)), "\n";
50 sub storeSwapFullPath {
53 my $dirn = ($fn >> $SWAP_DIR_SHIFT) % $ncache_dirs;
54 my $filn = $fn & $SWAP_FILE_MASK;
56 sprintf "%s/%02X/%02X/%08X",
58 (($fn / $L2[$dirn]) / $L2[$dirn]) % $L1[$dirn],
59 ($fn / $L2[$dirn]) % $L2[$dirn],
64 print STDERR "usage: $0 -c config\n";
65 print STDERR "hexadecimal file numbers are read from stdin\n";