[vhffs-dev] [1536] now using IN_ATTRIB to spread mtime only updates (by using touch, cp -a, rsync -a, and such)

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1536
Author:   gradator
Date:     2010-01-10 03:53:04 +0100 (Sun, 10 Jan 2010)
Log Message:
-----------
now using IN_ATTRIB to spread mtime only updates (by using touch, cp -a, rsync -a, and such)

Modified Paths:
--------------
    trunk/vhffs-fssync/vhffsfssync_master.c

Modified: trunk/vhffs-fssync/vhffsfssync_master.c
===================================================================
--- trunk/vhffs-fssync/vhffsfssync_master.c	2010-01-10 00:59:02 UTC (rev 1535)
+++ trunk/vhffs-fssync/vhffsfssync_master.c	2010-01-10 02:53:04 UTC (rev 1536)
@@ -53,8 +53,8 @@
 /* -- inotify stuff -- */
 
 #define VHFFSFSSYNC_BUF_LEN 4096
-#define VHFFSFSSYNC_WATCH_MASK IN_CREATE|IN_DELETE|IN_CLOSE_WRITE|IN_MOVED_FROM|IN_MOVED_TO|IN_DONT_FOLLOW|IN_ONLYDIR
-// Not used yet: IN_ATTRIB, IN_DELETE_SELF, IN_MODIFY, IN_MOVE_SELF
+#define VHFFSFSSYNC_WATCH_MASK IN_ATTRIB|IN_CREATE|IN_DELETE|IN_CLOSE_WRITE|IN_MOVED_FROM|IN_MOVED_TO|IN_DONT_FOLLOW|IN_ONLYDIR
+// Not used yet: IN_DELETE_SELF, IN_MODIFY, IN_MOVE_SELF
 // Will never be used: IN_ACCESS, IN_OPEN, IN_CLOSE_NOWRITE
 
 // each monitor entry is associated with a path, we need to keep it to compute the path
@@ -1418,11 +1418,22 @@
 		free(vhffsfssync_cookie.from);
 	}
 
-	// useless at the moment (chmod, chown, touch, ...)
+	// new mtime (and also atime, chmod and chown, but we are not using them)
 	if( event->mask & IN_ATTRIB )  {
+		struct stat st;
 #if DEBUG_INOTIFY
 		printf("IN_ATTRIB\n");
 #endif
+		if(! lstat(pathname, &st) )  {
+			vhffsfssync_net_broadcast_event( g_strdup_printf("mtime%c%s%c%ld%c", '\0', pathname, '\0', st.st_mtime, '\0') , VHFFSFSSYNC_NET_PRIO_MEDIUM);
+		}
+		else {
+			if(errno == ENOENT) {
+				// file already disappeared (common for temporary files)
+			} else {
+				fprintf(stderr, "cannot lstat() '%s': %s\n", pathname, strerror(errno));
+			}
+		}
 
 	// new file, directory, or symlink
 	} else if( event->mask & IN_CREATE )  {


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/