#!/usr/local/bin/perl # $Id: upgrade-1.0-store.pl,v 1.3 2003/01/23 00:37:06 robertc Exp $ select(STDERR); $|=1; select(STDOUT); $|=1; $USAGE="Usage: $0 swaplog cachedir1 cachedir2 ...\n"; $dry_run = 0; $swaplog = shift || die $USAGE; (@cachedirs = @ARGV) || die $USAGE; $ncache_dirs = $#cachedirs + 1; $OLD_SWAP_DIRECTORIES = 100; $NEW_SWAP_DIRECTORIES_L1 = 16; $NEW_SWAP_DIRECTORIES_L2 = 256; $EEXIST = 17; # check your /usr/include/errno.h print <; exit(1) unless ($ans =~ /^y$/ || $ans =~ /^yes$/); # make new directories foreach $c (@cachedirs) { $cn = "$c.new"; &my_mkdir ($cn); foreach $d1 (0..($NEW_SWAP_DIRECTORIES_L1-1)) { $p1 = sprintf ("$cn/%02X", $d1); &my_mkdir ($p1); foreach $d2 (0..($NEW_SWAP_DIRECTORIES_L2-1)) { $p2 = sprintf ("$p1/%02X", $d2); &my_mkdir ($p2); } } } $newlog = "$swaplog.1.1"; open (newlog, ">$newlog") || die "$newlog: $!\n"; select(newlog); $|=1; select(STDOUT); open (swaplog) || die "$swaplog: $!\n"; $count = 0; while () { chop; ($file,$url,$expires,$timestamp,$size) = split; @F = split('/', $file); $oldfileno = pop @F; $oldpath = &old_fileno_to_path($oldfileno); unless (@S = stat($oldpath)) { print "$oldpath: $!\n"; next; } unless ($S[7] == $size) { print "$oldpath: Wrong Size.\n"; next; } $newpath = &new_fileno_to_path($oldfileno); next unless &my_link($oldpath,$newpath); printf newlog "%08x %08x %08x %08x %9d %s\n", $oldfileno, $timestamp, $expires, $timestamp, # lastmod $size, $url; $count++; } print < $t\n"; return 1 if ($dry_run); unlink($t); $rc = link ($f,$t); warn "$t: $!\n" unless ($rc); $rc; }