[vhffs-dev] [1638] improved slave check stuff

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


Revision: 1638
Author:   gradator
Date:     2010-11-16 23:07:35 +0100 (Tue, 16 Nov 2010)
Log Message:
-----------
improved slave check stuff

Modified Paths:
--------------
    trunk/vhffs-fssync/HOWTOCOMPILEANDRUN
    trunk/vhffs-fssync/vhffsfssync_slave.c

Modified: trunk/vhffs-fssync/HOWTOCOMPILEANDRUN
===================================================================
--- trunk/vhffs-fssync/HOWTOCOMPILEANDRUN	2010-10-29 22:54:03 UTC (rev 1637)
+++ trunk/vhffs-fssync/HOWTOCOMPILEANDRUN	2010-11-16 22:07:35 UTC (rev 1638)
@@ -1,7 +1,7 @@
 Compile
 -------
 
-You'll need Glib 2 development packages (libglib2.0-dev on Debian) and inotify support.
+You'll need Glib2 development packages (libglib2.0-dev on Debian) and inotify support.
 
 gcc [-ggdb] -Wall -Werror -o vhffsfssync_master `pkg-config --cflags --libs glib-2.0` vhffsfssync_master.c
 gcc [-ggdb] -Wall -Werror -o vhffsfssync_slave `pkg-config --cflags --libs glib-2.0` vhffsfssync_slave.c
@@ -10,7 +10,7 @@
 Run
 ---
 
-You'll need Glib 2 packages (libglib2.0-0 on lenny).
+You'll need Glib2 packages (libglib2.0-0 on lenny).
 Your two boxes should be time synced using NTP.
 
 On master (as root): ./vhffsfssync_master [--foreground] [--bind=IP] [--port=PORT] DIRTOSYNC

Modified: trunk/vhffs-fssync/vhffsfssync_slave.c
===================================================================
--- trunk/vhffs-fssync/vhffsfssync_slave.c	2010-10-29 22:54:03 UTC (rev 1637)
+++ trunk/vhffs-fssync/vhffsfssync_slave.c	2010-11-16 22:07:35 UTC (rev 1638)
@@ -51,6 +51,11 @@
 #include <sys/time.h>
 
 
+#ifdef CHECK
+int vhffsfssync_progress=0;
+char vhffsfssync_progresschar[] = { '/', '-', '\\', '|', '\0' };
+#endif
+
 /* -- network stuff -- */
 // huge buffer size reduce syscalls
 #define VHFFSFSSYNC_NET_RECV_CHUNK 65536
@@ -344,14 +349,22 @@
 		if(strcmp(type, type_)) {
 #ifndef CHECK
 			vhffsfssync_remove(path);
+#else
+			printf("\033[2K\033[0Gtype mismatch - ");
 #endif
 			fetch = TRUE;
 		}
 		else if(!S_ISDIR(st.st_mode) && st.st_size != size) {
 			fetch = TRUE;
+#ifdef CHECK
+			printf("\033[2K\033[0Gsize mismatch - ");
+#endif
 		}
 		else if(st.st_mtime != mtime) {
 			fetch = TRUE;
+#ifdef CHECK
+			printf("\033[2K\033[0Gmtime mismatch - ");
+#endif
 		}
 
 		if(!fetch && vhffsfssync_preserve) {
@@ -361,7 +374,7 @@
 					fprintf(stderr, "chmod() failed on %s: %s\n", path, strerror(errno));
 				}
 #else
-				printf("%s mode is not synched\n", path );
+				printf("\033[2K\033[0Gmode mismatch - %s\n", path);
 #endif
 			}
 			if(st.st_uid != uid || st.st_gid != gid) {
@@ -370,7 +383,7 @@
 					fprintf(stderr, "lchown() failed on %s: %s\n", path, strerror(errno));
 				}
 #else
-				printf("%s uid or gid are not synched\n", path );
+				printf("\033[2K\033[0Guid or gid mismatch - %s\n", path);
 #endif
 			}
 		}
@@ -378,22 +391,24 @@
 	else {
 		if(errno == ENOENT) {
 			fetch = TRUE;
+#ifdef CHECK
+			printf("\033[2K\033[0Gfile not found - ");
+#endif
 		}
 		else {
 			fprintf(stderr, "cannot lstat() '%s': %s\n", path, strerror(errno));
 			return -1;
 		}
 	}
+	if(fetch) {
 #ifndef CHECK
-	if(fetch) {
 		vhffsfssync_net_send_event(conn, g_strdup_printf("get%c%s%c", '\0', path, '\0') );
-	}
 #else
-	if(fetch) {
-		printf("%s is not synched\n", path );
+		printf("%s\n", path);
+#endif
 	}
-#endif
 
+
 	return 0;
 }
 
@@ -786,7 +801,9 @@
 		root = args[1];
 		root_ = strdup(root);
 
-		printf("\033[2K\033[0G%s - ", root);
+		if( !vhffsfssync_progresschar[ ++vhffsfssync_progress ] ) vhffsfssync_progress=0;
+		//printf("\033[2K\033[0G%s - ", root);
+		printf("\033[2K\033[0G%c", vhffsfssync_progresschar[ vhffsfssync_progress ] );
 		fflush(stdout);
 
 		if( lstat(root, &st) ) {
@@ -1094,7 +1111,9 @@
 	if( chroot(".") < 0 ) {
 		fprintf(stderr, "cannot chroot() to %s: %s\n", root, strerror(errno));
 		// disable permissions, owners and groups preservation if we are not root
+#ifndef CHECK
 		vhffsfssync_preserve = 0;
+#endif
 		//return -1;
 	}
 	root = ".";


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