[Popcon-commits] cvs commit to popularity-contest by ballombe

ballombe at cvs.alioth.debian.org ballombe at cvs.alioth.debian.org
Tue Jan 8 18:48:38 UTC 2008


Update of /cvsroot/popcon/popularity-contest
In directory alioth:/tmp/cvs-serv17198

Modified Files:
	popularity-contest 
Log Message:
Apply patch from Johan Walles to treat all mapped files as recently used.


Index: popularity-contest
===================================================================
RCS file: /cvsroot/popcon/popularity-contest/popularity-contest,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- popularity-contest	15 Aug 2007 15:20:58 -0000	1.19
+++ popularity-contest	8 Jan 2008 18:48:35 -0000	1.20
@@ -70,8 +70,29 @@
 
 my %popcon=();
 
-#Read dpkg database of installed packages
+# List all mapped files
+my %mapped;
+if (opendir(PROC, "/proc"))
+{
+  my @procfiles = readdir(PROC);
+  closedir(PROC);
+  
+  foreach (@procfiles)
+  {
+    -d "/proc/$_" or next;
+    m{^[0-9]+$} or next;
+    
+    open MAPS, "/proc/$_/maps" or next;
+    while (<MAPS>)
+    {
+      m{(/.*)} or next;
+      $mapped{$1} = 1;
+    }
+    close MAPS;
+  }
+}
 
+# Read dpkg database of installed packages
 open PACKAGES, "dpkg-query --show --showformat='\${status} \${package}\\n'|";
 while (<PACKAGES>)
 {
@@ -83,11 +104,17 @@
   while (<FILES>)
   {
     chop;
-    m{/bin/|/sbin/|^/usr/games/|\.[ah]$|\.pm$|\.php$|^/boot/System\.map-} or next;
-    -f $_ or next;
+    m{/bin/|/sbin/|^/usr/games/|\.[ah]$|\.pm$|\.php$|^/boot/System\.map-}
+      || -f $_ 
+      || defined $mapped{$_}
+      || next;
     my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
                       $atime,$mtime,$ctime,$blksize,$blocks)
                           = stat;
+    if (defined $mapped{$_}) {
+      # It's currently being accessed by a process
+      $atime = time();
+    }
     print STDERR if (!defined($atime));
     if (!defined($bestatime) || $atime >= $bestatime)
     {




More information about the Popcon-commits mailing list