[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Popcon-developers] Bug#457441: popularity-contest: [PATCH] Please count currently mapped files as being accessed *now*



Package: popularity-contest
Version: 1.42
Severity: wishlist
Tags: patch


Please count currently mapped files as having an atime of *now*.

This makes lots of libraries get proper time stamps, as well as long running daemons (bug 327693).

The attached patch stores all files listed in /proc/1234/maps and treats them as having an atime of
now.

  Regards //Johan

-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (990, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.22-3-686 (SMP w/2 CPU cores)
Locale: LANG=sv_SE.UTF-8, LC_CTYPE=sv_SE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages popularity-contest depends on:
ii  debconf [debconf-2.0]         1.5.17     Debian configuration management sy
ii  dpkg                          1.14.7     package maintenance system for Deb

Versions of packages popularity-contest recommends:
ii  cron                          3.0pl1-100 management of regular background p
pn  mime-construct                <none>     (no description available)
ii  postfix [mail-transport-agent 2.4.6-2    High-performance mail transport ag

-- debconf information:
  popularity-contest/submiturls:
* popularity-contest/participate: true
* popularity-contest/intro:
  popularity-contest/hostid-failed:
  popularity-contest/use-http: false
-------------- next part --------------
--- popularity-contest-1.42/popularity-contest	2006-10-08 18:30:36.000000000 +0200
+++ popularity-contest-1.42-johan/popularity-contest	2007-12-22 13:41:41.000000000 +0100
@@ -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";
+    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|^/boot/System\.map-} or next;
+    m{/bin/|/sbin/|^/usr/games/|\.[ah]$|\.pm|^/boot/System\.map-}
+    || defined $mapped{$_}
+    || next;
     -f $_ or 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)
     {


Reply to: