]>
git.ipfire.org Git - thirdparty/squid.git/blob - scripts/fileno-to-pathname.pl
3 ## Copyright (C) 1996-2015 The Squid Software Foundation and contributors
5 ## Squid software is distributed under GPLv2+ license and includes
6 ## contributions from numerous individuals and organizations.
7 ## Please see the COPYING and CONTRIBUTORS files for details.
10 # Convert hexadecimal cache file numbers (from swap log) into full pathnames.
11 # Duane Wessels 6/30/97
13 # 2001-12-18 Adapted for squid-2.x Alain Thivillon <at@rominet.net>
27 my $SWAP_DIR_SHIFT=24;
28 my $SWAP_FILE_MASK=0x00FFFFFF;
30 my $CF = $opt_c || '/usr/local/squid/etc/squid.conf';
31 &usage unless (open (CF,"<$CF"));
37 # cache_dir ufs path size L1 L2
38 if (/^cache_dir\s+(\S+)\s+(\S+)\s+\d+\s+(\S+)\s+(\S+)/i) {
39 $CD[$ncache_dirs] = $2;
40 $L1[$ncache_dirs] = $3;
41 $L2[$ncache_dirs++] = $4;
46 if ($ncache_dirs == 0) {
47 print STDERR "No proper cache_dir line found\n";
53 print &storeSwapFullPath(hex($_)), "\n";
56 sub storeSwapFullPath {
59 my $dirn = ($fn >> $SWAP_DIR_SHIFT) % $ncache_dirs;
60 my $filn = $fn & $SWAP_FILE_MASK;
62 sprintf "%s/%02X/%02X/%08X",
64 (($fn / $L2[$dirn]) / $L2[$dirn]) % $L1[$dirn],
65 ($fn / $L2[$dirn]) % $L2[$dirn],
70 print STDERR "usage: $0 -c config\n";
71 print STDERR "hexadecimal file numbers are read from stdin\n";