simon@foobar.net writes:
>Someone posted a small script to convert the numbers in the cache/log
>file into a directory and filename but I've looked through the
>mailing list archives and can't spot the message. Does anyone have a
>copy of the script they can mail me please or even the subject of the
>original message would do as I can then find it in the archives..
>
>I want to convert:
>0000164b 33b774e1 fffffffe 33b77475 2091 <long url snipped>
>into it's filename within the cache.
#!/usr/local/bin/perl
# $Id: fileno-to-pathname.pl,v 1.1.2.1 1997/06/30 19:05:58 wessels Exp $
# Convert hexadecimal cache file numbers (from swap log) into full pathnames.
# Duane Wessels 6/30/97
require 'getopts.pl';
&Getopts('c:');
$L1 = 16;
$L2 = 256;
$CF = $opt_c || '/usr/local/squid/etc/squid.conf';
&usage unless (open (CF));
$ncache_dirs = 0;
while (<CF>) {
$CD[$ncache_dirs++] = $1 if (/^cache_dir\s+(\S+)/);
$L1 = $1 if (/^swap_level1_dirs\s+(\d+)/);
$L2 = $1 if (/^swap_level2_dirs\s+(\d+)/);
}
close(CF);
unless ($ncache_dirs) {
$CD[$ncache_dirs++] = '/usr/local/squid/cache';
}
while (<>) {
chop;
print &storeSwapFullPath(hex($_)), "\n";
}
sub storeSwapFullPath {
local($fn) = @_;
sprintf "%s/%02X/%02X/%08X",
$CD[$fn % $ncache_dirs],
($fn / $ncache_dirs) % $L1,
($fn / $ncache_dirs) / $L1 % $L2,
$fn;
}
sub usage {
print STDERR "usage: $0 -c config\n";
print STDERR "hexadecimal file numbers are read from stdin\n";
exit 1;
}
Received on Mon Jun 30 1997 - 12:12:39 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:35:35 MST