#!/usr/bin/perl -w
#
-## Copyright (C) 1996-2018 The Squid Software Foundation and contributors
+## Copyright (C) 1996-2021 The Squid Software Foundation and contributors
##
## Squid software is distributed under GPLv2+ license and includes
## contributions from numerous individuals and organizations.
## Please see the COPYING and CONTRIBUTORS files for details.
##
-# Convert hexadecimal cache file numbers (from swap log) into full pathnames.
+# Convert hexadecimal cache file numbers (from swap log) into full pathnames.
# Duane Wessels 6/30/97
# 2001-12-18 Adapted for squid-2.x Alain Thivillon <at@rominet.net>
my $ncache_dirs = 0;
while (<CF>) {
- # Squid 2.3 ===>
- # cache_dir ufs path size L1 L2
- if (/^cache_dir\s+(\S+)\s+(\S+)\s+\d+\s+(\S+)\s+(\S+)/i) {
- $CD[$ncache_dirs] = $2;
- $L1[$ncache_dirs] = $3;
- $L2[$ncache_dirs++] = $4;
- }
+ # Squid 2.3 ===>
+ # cache_dir ufs path size L1 L2
+ if (/^cache_dir\s+(\S+)\s+(\S+)\s+\d+\s+(\S+)\s+(\S+)/i) {
+ $CD[$ncache_dirs] = $2;
+ $L1[$ncache_dirs] = $3;
+ $L2[$ncache_dirs++] = $4;
+ }
}
close(CF);
if ($ncache_dirs == 0) {
- print STDERR "No proper cache_dir line found\n";
- exit 2;
+ print STDERR "No proper cache_dir line found\n";
+ exit 2;
}
while (<>) {
- chop;
- print &storeSwapFullPath(hex($_)), "\n";
+ chop;
+ print &storeSwapFullPath(hex($_)), "\n";
}
sub storeSwapFullPath {
- my($fn) = @_;
+ my($fn) = @_;
- my $dirn = ($fn >> $SWAP_DIR_SHIFT) % $ncache_dirs;
- my $filn = $fn & $SWAP_FILE_MASK;
+ my $dirn = ($fn >> $SWAP_DIR_SHIFT) % $ncache_dirs;
+ my $filn = $fn & $SWAP_FILE_MASK;
- sprintf "%s/%02X/%02X/%08X",
- $CD[$dirn],
- (($fn / $L2[$dirn]) / $L2[$dirn]) % $L1[$dirn],
- ($fn / $L2[$dirn]) % $L2[$dirn],
- $fn;
+ sprintf "%s/%02X/%02X/%08X",
+ $CD[$dirn],
+ (($fn / $L2[$dirn]) / $L2[$dirn]) % $L1[$dirn],
+ ($fn / $L2[$dirn]) % $L2[$dirn],
+ $fn;
}
sub usage {
- print STDERR "usage: $0 -c config\n";
- print STDERR "hexadecimal file numbers are read from stdin\n";
- exit 1;
+ print STDERR "usage: $0 -c config\n";
+ print STDERR "hexadecimal file numbers are read from stdin\n";
+ exit 1;
}