Re: [PATCH] Extend corosync-cmapctl -p option by allowing keys to be deleted.

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

 



Vladislav,
thanks for patch. Ack and commited.

Regards,
  Honza

Vladislav Bogdanov napsal(a):
Signed-off-by: Vladislav Bogdanov <bubble@xxxxxxxxxxxxx>
---
  man/corosync-cmapctl.8   |   10 +++++++++-
  tools/corosync-cmapctl.c |   29 ++++++++++++++++++++++++-----
  2 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/man/corosync-cmapctl.8 b/man/corosync-cmapctl.8
index 02fbdc4..661137c 100644
--- a/man/corosync-cmapctl.8
+++ b/man/corosync-cmapctl.8
@@ -49,7 +49,15 @@ for bin, value is file name (or \- for stdin)
  corosync\-cmapctl \fB\-p\fR filename
  .IP
  the format of the file is:
-<key_name> <type> <value>
+[^[^]]<key_name>[ <type> <value>]
+.IP
+Keys prefixed with single caret ('^') are deleted (see \fB\-d\fR).
+.IP
+Keys (actually prefixes) prefixed with double caret ('^^') are deleted by prefix (see \fB\-D\fR).
+.IP
+<type> and <value> are optional (not checked) in above cases.
+.IP
+Other keys are set (see \fB\-s\fR) so both <type> and <value> are required.
  .SS "Delete key:"
  .IP
  corosync\-cmapctl \fB\-d\fR key_name...
diff --git a/tools/corosync-cmapctl.c b/tools/corosync-cmapctl.c
index 7e23ab0..a8da499 100644
--- a/tools/corosync-cmapctl.c
+++ b/tools/corosync-cmapctl.c
@@ -110,7 +110,11 @@ static int print_help(void)
  	printf("    corosync-cmapctl -p filename\n");
  	printf("\n");
  	printf("    the format of the file is:\n");
-	printf("    <key_name> <type> <value>\n");
+	printf("    [^[^]]<key_name>[ <type> <value>]\n");
+	printf("    Keys prefixed with single caret ('^') are deleted (see -d).\n");
+	printf("    Keys (actually prefixes) prefixed with double caret ('^^') are deleted by prefix (see -D).\n");
+	printf("    <type> and <value> are optional (not checked) in above cases.\n");
+	printf("    Other keys are set (see -s) so both <type> and <value> are required.\n");
  	printf("\n");
  	printf("Delete key:\n");
  	printf("    corosync-cmapctl -d key_name...\n");
@@ -705,12 +709,27 @@ static void read_in_config_file(cmap_handle_t handle, char * filename)

  		/*
  		 * should be:
-		 * <key> <type> <value>
+		 * [^[^]]<key>[ <type> <value>]
  		 */
  		key_name = strtok(line, " \n");
-		key_type_s = strtok(NULL, " \n");
-		key_value_s = strtok(NULL, " \n");
-		set_key(handle, key_name, key_type_s, key_value_s);
+		if (key_name && *key_name == '^') {
+			key_name++;
+			if (*key_name == '^') {
+				key_name++;
+				delete_with_prefix(handle, key_name);
+			} else {
+				cs_error_t err;
+
+				err = cmap_delete(handle, key_name);
+				if (err != CS_OK) {
+					fprintf(stderr, "Can't delete key %s. Error %s\n", key_name, cs_strerror(err));
+				}
+			}
+		} else {
+			key_type_s = strtok(NULL, " \n");
+			key_value_s = strtok(NULL, " \n");
+			set_key(handle, key_name, key_type_s, key_value_s);
+		}
  	}

  	fclose (fh);


_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss




[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux