]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - scripts/fileno-to-pathname.pl
Source Format Enforcement (#763)
[thirdparty/squid.git] / scripts / fileno-to-pathname.pl
index 3b779097791598675dab905ba53c3ce5e46a41a0..c51718017bad68768628c9468a173c75f67cafa8 100755 (executable)
@@ -1,13 +1,13 @@
 #!/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>
@@ -33,41 +33,41 @@ my $CF = $opt_c || '/usr/local/squid/etc/squid.conf';
 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;
 }