HAMMER and file alternation problem

YONETANI Tomokazu qhwt+dfly at les.ath.cx
Thu Oct 16 02:18:43 PDT 2008


On Wed, Oct 15, 2008 at 07:23:17PM +1100, Petr Janda wrote:
> Hi,
> I just installed KDE on a HAMMER file system, and I noticed
> an interesting thing. When I create a file in console on a HAMMER
> file system I need to refresh Konqueror file browser to
> see the newly created file. However if I create the
> file on a UFS file system Konqueror notices it nearly instantenously(no need 
> to manual refresh).
> 
> Is this a feature missing in the HAMMER file system or its because of KDE
> not having a clue about HAMMER? If its a feature missing in HAMMER,
> can we please add it?

Apparently it's in kdelibs (untested yet, but...)

int KDirWatchPrivate::scanEntry(Entry* e)
{
		:

    if ( (e->m_ctime != invalid_ctime) &&
         ((stat_buf.st_ctime != e->m_ctime) ||
          (stat_buf.st_nlink != (nlink_t) e->m_nlink)) ) {
      e->m_ctime = stat_buf.st_ctime;
      e->m_nlink = stat_buf.st_nlink;
      return Changed;
    }
		:

On HAMMER, neither st_ctime nor st_nlink change when a new object
is created in a directory:

$ mkdir test
$ stat -f %c:%l test
1224145054:1		# st_ctime followed by a colon and st_nlink
$ sleep 60
$ touch test/foo
$ stat -f %c:%l test
1224145054:1

whereas on UFS directory's st_ctime changes

$ mkdir test
$ stat -f %c:%l test
1224145192:2
$ sleep 60
$ touch test/foo
$ stat -f %c:%l test
1224145204:2

Can you try replacing kdelibs with patched version?  It makes kdelibs
to use mtime of a directory instead of ctime, but it probably works.

$ sudo mkdir /path/to/localpatches/x11/kdelibs3
$ sudo cp ~/kdelibs.patch /path/to/localpatches/x11/kdelibs3/
$ cd /usr/pkgsrc/x11/kdelibs3
$ bmake clean
$ env LOCALPATCHES=/path/to/localpatches bmake
$ bmake replace

(to use `bmake replace' you need pkg_tarup installed).

Cheers.
--- kio/kio/kdirwatch.cpp.orig	2006-07-22 17:16:37 +0900
+++ kio/kio/kdirwatch.cpp	2008-10-16 17:57:26 +0900
@@ -850,7 +850,7 @@
     else if (!e->isDir && isDir)
       kdWarning() << "KDirWatch: " << path << " is a file. Use addFile!" << endl;
 
-    e->m_ctime = stat_buf.st_ctime;
+    e->m_ctime = stat_buf.st_mtime;
     e->m_status = Normal;
     e->m_nlink = stat_buf.st_nlink;
   }
@@ -1086,7 +1086,7 @@
       KDE_struct_stat stat_buf;
       bool exists = (KDE_stat(QFile::encodeName(e->path), &stat_buf) == 0);
       if (exists) {
-	e->m_ctime = stat_buf.st_ctime;
+	e->m_ctime = stat_buf.st_mtime;
 	e->m_status = Normal;
         e->m_nlink = stat_buf.st_nlink;
       }
@@ -1180,16 +1180,16 @@
   if (exists) {
 
     if (e->m_status == NonExistent) {
-      e->m_ctime = stat_buf.st_ctime;
+      e->m_ctime = stat_buf.st_mtime;
       e->m_status = Normal;
       e->m_nlink = stat_buf.st_nlink;
       return Created;
     }
 
     if ( (e->m_ctime != invalid_ctime) &&
-	 ((stat_buf.st_ctime != e->m_ctime) ||
+	 ((stat_buf.st_mtime != e->m_ctime) ||
 	  (stat_buf.st_nlink != (nlink_t) e->m_nlink)) ) {
-      e->m_ctime = stat_buf.st_ctime;
+      e->m_ctime = stat_buf.st_mtime;
       e->m_nlink = stat_buf.st_nlink;
       return Changed;
     }




More information about the Kernel mailing list