[pve-devel] r6431 - in pve-cluster/trunk: . data data/src debian

svn-commits at proxmox.com svn-commits at proxmox.com
Mon Aug 8 08:54:28 CEST 2011


Author: dietmar
Date: 2011-08-08 08:54:28 +0200 (Mon, 08 Aug 2011)
New Revision: 6431

Modified:
   pve-cluster/trunk/Makefile
   pve-cluster/trunk/data/ChangeLog
   pve-cluster/trunk/data/Makefile.in
   pve-cluster/trunk/data/README
   pve-cluster/trunk/data/src/cfs-plug-func.c
   pve-cluster/trunk/data/src/cfs-plug.h
   pve-cluster/trunk/data/src/pmxcfs.c
   pve-cluster/trunk/debian/changelog
Log:
  * new virtual file to enabe/disable debugging



Modified: pve-cluster/trunk/Makefile
===================================================================
--- pve-cluster/trunk/Makefile	2011-08-08 04:37:11 UTC (rev 6430)
+++ pve-cluster/trunk/Makefile	2011-08-08 06:54:28 UTC (rev 6431)
@@ -2,7 +2,7 @@
 
 PACKAGE=pve-cluster
 PKGVER=1.0
-PKGREL=2
+PKGREL=3
 
 ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
 

Modified: pve-cluster/trunk/data/ChangeLog
===================================================================
--- pve-cluster/trunk/data/ChangeLog	2011-08-08 04:37:11 UTC (rev 6430)
+++ pve-cluster/trunk/data/ChangeLog	2011-08-08 06:54:28 UTC (rev 6431)
@@ -1,3 +1,11 @@
+2011-08-08  Proxmox Support Team  <support at proxmox.com>
+
+	* src/cfs-plug-func.c (cfs_plug_func_new): add write callback (to
+	trigger actions).
+
+	* src/pmxcfs.c (write_debug_setting_cb): implement callback to
+	enable/disable debug mode (.debug file)
+
 2011-08-05  Proxmox Support Team  <support at proxmox.com>
 
 	* PVE/pvecm (create): call keygen with parameter hash

Modified: pve-cluster/trunk/data/Makefile.in
===================================================================
--- pve-cluster/trunk/data/Makefile.in	2011-08-08 04:37:11 UTC (rev 6430)
+++ pve-cluster/trunk/data/Makefile.in	2011-08-08 06:54:28 UTC (rev 6431)
@@ -34,7 +34,7 @@
 subdir = .
 DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in $(srcdir)/config.h.in \
-	$(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
+	$(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL \
 	compile depcomp install-sh missing
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/configure.in

Modified: pve-cluster/trunk/data/README
===================================================================
--- pve-cluster/trunk/data/README	2011-08-08 04:37:11 UTC (rev 6430)
+++ pve-cluster/trunk/data/README	2011-08-08 06:54:28 UTC (rev 6431)
@@ -1,3 +1,9 @@
+Enable/Disable debugging
+========================
+
+# echo "1" >/etc/pve/.debug 
+# echo "0" >/etc/pve/.debug 
+
 Memory leak debugging (valgrind)
 ================================
 

Modified: pve-cluster/trunk/data/src/cfs-plug-func.c
===================================================================
--- pve-cluster/trunk/data/src/cfs-plug-func.c	2011-08-08 04:37:11 UTC (rev 6430)
+++ pve-cluster/trunk/data/src/cfs-plug-func.c	2011-08-08 06:54:28 UTC (rev 6431)
@@ -81,6 +81,9 @@
 
 	memset(stbuf, 0, sizeof(struct stat));
 
+	if (fplug->data)
+		g_free(fplug->data);
+
 	fplug->data = fplug->update_callback(plug);
 
 	stbuf->st_mode = fplug->mode;
@@ -129,6 +132,50 @@
 }
 
 static int 
+cfs_plug_func_write(
+	cfs_plug_t *plug, 
+	const char *path, 
+	const char *buf, 
+	size_t size,
+	off_t offset, 
+	struct fuse_file_info *fi)
+{
+	(void) fi;
+
+	g_return_val_if_fail(plug != NULL, PARAM_CHECK_ERRNO);
+	g_return_val_if_fail(plug->ops == &cfs_ops, PARAM_CHECK_ERRNO);
+	g_return_val_if_fail(path != NULL, PARAM_CHECK_ERRNO);
+	g_return_val_if_fail(buf != NULL, PARAM_CHECK_ERRNO);
+
+	cfs_debug("enter cfs_plug_func_write");
+
+	cfs_plug_func_t *fplug = (cfs_plug_func_t *)plug;
+
+	if (offset != 0 || !fplug->write_callback)
+		return -EIO;
+
+	return fplug->write_callback(plug, buf, size);
+}
+
+static int 
+cfs_plug_func_truncate(
+	cfs_plug_t *plug, 
+	const char *path, 
+	off_t size)
+{
+	g_return_val_if_fail(plug != NULL, PARAM_CHECK_ERRNO);
+	g_return_val_if_fail(plug->ops == &cfs_ops, PARAM_CHECK_ERRNO);
+	g_return_val_if_fail(path != NULL, PARAM_CHECK_ERRNO);
+
+	cfs_plug_func_t *fplug = (cfs_plug_func_t *)plug;
+
+	if (fplug->write_callback)
+		return 0;
+
+	return -EIO;
+}
+
+static int 
 cfs_plug_func_open(
 	cfs_plug_t *plug, 
 	const char *path, 
@@ -147,6 +194,8 @@
 static struct cfs_operations cfs_ops = {
 	.getattr = cfs_plug_func_getattr,
 	.read = cfs_plug_func_read,
+	.write = cfs_plug_func_write,
+	.truncate = cfs_plug_func_truncate,
 	.open = cfs_plug_func_open,
 };
 
@@ -155,7 +204,8 @@
 cfs_plug_func_new(
 	const char *name, 
 	mode_t mode,
-	cfs_plug_func_udpate_data_fn_t update_callback)
+	cfs_plug_func_udpate_data_fn_t update_callback,
+	cfs_plug_func_write_data_fn_t write_callback)
 {
 	g_return_val_if_fail(name != NULL, NULL);
 	g_return_val_if_fail(update_callback != NULL, NULL);
@@ -170,6 +220,10 @@
 	fplug->plug.name = g_strdup(name);
 
 	fplug->update_callback = update_callback;
+	fplug->write_callback = write_callback;
+	if (!write_callback)
+		mode = mode & ~0222;
+
 	fplug->mode = S_IFREG | mode;
 
 	return fplug;

Modified: pve-cluster/trunk/data/src/cfs-plug.h
===================================================================
--- pve-cluster/trunk/data/src/cfs-plug.h	2011-08-08 04:37:11 UTC (rev 6430)
+++ pve-cluster/trunk/data/src/cfs-plug.h	2011-08-08 06:54:28 UTC (rev 6431)
@@ -77,11 +77,17 @@
 } cfs_plug_link_t;
 
 typedef char *(*cfs_plug_func_udpate_data_fn_t)(cfs_plug_t *plug);
+typedef int (*cfs_plug_func_write_data_fn_t)(
+	cfs_plug_t *plug, 
+	const char *buf,
+	size_t size);
+
 typedef struct {
 	cfs_plug_t plug;
 	char *data;
 	mode_t mode;
 	cfs_plug_func_udpate_data_fn_t update_callback;
+	cfs_plug_func_write_data_fn_t write_callback;
 } cfs_plug_func_t;
 
 cfs_plug_base_t *cfs_plug_base_new(const char *name, cfs_plug_t *base);
@@ -91,7 +97,8 @@
 cfs_plug_func_t *cfs_plug_func_new(
 	const char *name, 
 	mode_t mode,
-	cfs_plug_func_udpate_data_fn_t update_callback);
+	cfs_plug_func_udpate_data_fn_t update_callback,
+	cfs_plug_func_write_data_fn_t write_callback);
 
 
 #endif /* _PVE_CFS_PLUG_H_ */

Modified: pve-cluster/trunk/data/src/pmxcfs.c
===================================================================
--- pve-cluster/trunk/data/src/pmxcfs.c	2011-08-08 04:37:11 UTC (rev 6430)
+++ pve-cluster/trunk/data/src/pmxcfs.c	2011-08-08 06:54:28 UTC (rev 6431)
@@ -320,13 +320,12 @@
 	char *subpath = NULL;
 	cfs_plug_t *plug = find_plug(path, &subpath);
 	
-	if (!plug)
-		goto ret;
-
-	if (subpath && plug->ops && plug->ops->write)
-		ret = plug->ops->write(plug, subpath, buf, size, offset, fi);
+	if (plug && plug->ops) { 
+		if ((subpath || !plug->ops->readdir) && plug->ops->write)
+		ret = plug->ops->write(plug, subpath ? subpath : "", 
+				       buf, size, offset, fi);
+	}
 	
-ret:
 	cfs_debug("leave cfs_fuse_write %s (%d)", path, ret);
 
 	if (subpath)
@@ -344,13 +343,11 @@
 	char *subpath = NULL;
 	cfs_plug_t *plug = find_plug(path, &subpath);
 	
-	if (!plug)
-		goto ret;
+	if (plug && plug->ops) { 
+		if ((subpath || !plug->ops->readdir) && plug->ops->truncate)
+			ret = plug->ops->truncate(plug, subpath ? subpath : "", size);
+	}
 
-	if (subpath && plug->ops && plug->ops->truncate)
-		ret = plug->ops->truncate(plug, subpath, size);
-
-ret:
 	cfs_debug("leave cfs_fuse_truncate %s (%d)", path, ret);
 
 	if (subpath)
@@ -559,6 +556,40 @@
 	return data;
 }
 
+static char *
+read_debug_setting_cb(cfs_plug_t *plug)
+{
+	return g_strdup_printf("%d\n", !!cfs.debug); 
+}
+
+static int write_debug_setting_cb(
+	cfs_plug_t *plug, 
+	const char *buf,
+	size_t size)
+{
+	int res = -EIO;
+
+	if (size < 2)
+		return res;
+
+	if (strncmp(buf, "0\n", 2) == 0) {
+		if (cfs.debug) {
+			cfs_message("disable debug mode");
+			cfs.debug = 0;
+		}
+		return 2;
+	} else if (strncmp(buf, "1\n", 2) == 0) {
+		if (!cfs.debug) {
+			cfs_message("enable debug mode");
+			cfs.debug = 1;
+		}
+		return 2;
+	}
+
+	return res;
+}
+
+
 static void 
 create_symlinks(cfs_plug_base_t *bplug, const char *nodename)
 {
@@ -580,20 +611,25 @@
 	g_free(lnktarget);
 	cfs_plug_base_insert(bplug, (cfs_plug_t*)lnk);
 
-	cfs_plug_func_t *fplug = cfs_plug_func_new(".version", 0440, create_dot_version_cb);
+	cfs_plug_func_t *fplug = cfs_plug_func_new(".version", 0440, create_dot_version_cb, NULL);
 	cfs_plug_base_insert(bplug, (cfs_plug_t*)fplug);
 	
-	fplug = cfs_plug_func_new(".members", 0440, create_dot_members_cb);
+	fplug = cfs_plug_func_new(".members", 0440, create_dot_members_cb, NULL);
 	cfs_plug_base_insert(bplug, (cfs_plug_t*)fplug);
 
-	fplug = cfs_plug_func_new(".vmlist", 0440, create_dot_vmlist_cb);
+	fplug = cfs_plug_func_new(".vmlist", 0440, create_dot_vmlist_cb, NULL);
 	cfs_plug_base_insert(bplug, (cfs_plug_t*)fplug);
 
-	fplug = cfs_plug_func_new(".rrd", 0440, create_dot_rrd_cb);
+	fplug = cfs_plug_func_new(".rrd", 0440, create_dot_rrd_cb, NULL);
 	cfs_plug_base_insert(bplug, (cfs_plug_t*)fplug);
 
-	fplug = cfs_plug_func_new(".clusterlog", 0440, create_dot_clusterlog_cb);
+	fplug = cfs_plug_func_new(".clusterlog", 0440, create_dot_clusterlog_cb, NULL);
 	cfs_plug_base_insert(bplug, (cfs_plug_t*)fplug);
+
+	fplug = cfs_plug_func_new(".debug", 0640, read_debug_setting_cb, write_debug_setting_cb);
+	cfs_plug_base_insert(bplug, (cfs_plug_t*)fplug);
+
+
 }
 
 static char *

Modified: pve-cluster/trunk/debian/changelog
===================================================================
--- pve-cluster/trunk/debian/changelog	2011-08-08 04:37:11 UTC (rev 6430)
+++ pve-cluster/trunk/debian/changelog	2011-08-08 06:54:28 UTC (rev 6431)
@@ -1,3 +1,9 @@
+pve-cluster (1.0-3) unstable; urgency=low
+
+  * new virtual file to enabe/disable debugging
+
+ -- Proxmox Support Team <support at proxmox.com>  Mon, 08 Aug 2011 08:54:06 +0200
+
 pve-cluster (1.0-2) unstable; urgency=low
 
   * fix 'pvecm create'




More information about the pve-devel mailing list