Skip to contentSkip to conversation

tools/xs-clients: add some man pages and fixes

PATCH In review Juergen Gross 2 participants 15 messages Mar 12

lore
Share & tools
lore
#0 lore raw

v2 cover tools/xs-clients: add some man pages and fixes

For some of the Xenstore client programs the man pages are missing entirely, the existing man pages don't mention the "-h" parameter.

Additionally fix some other minor bugs in the code. Those bugs seem to exist since roughly 20 years now, so I didn't do a thorough archaeological examination for finding the exact commits introducing them, as any potential backport candidate will need to go to all still supported Xen versions anyway.

Changes in V2:
- new patches 1 and 6-8
- some small fixes in the other patches

Juergen Gross (8):
docs: add -h parameter description to xenstore-* man pages
docs: add man page for xenstore-exists
docs: add man page for xenstore-list
docs: add man page for xenstore-rm
docs: add man page for xenstore-watch tools/xs-clients: don't exit with error when using -h parameter tools/xs-clients: fix usage information of xenstore-exists tools/xs-clients: fix output of "xenstore-list -p /"

 docs/man/xenstore-chmod.1.pod      |  4 +++
 docs/man/xenstore-exists.1.pod     | 25 ++++++++++++++++
 docs/man/xenstore-list.1.pod       | 28 +++++++++++++++++
 docs/man/xenstore-ls.1.pod         |  4 +++
 docs/man/xenstore-read.1.pod       |  4 +++
 docs/man/xenstore-rm.1.pod         | 28 +++++++++++++++++
 docs/man/xenstore-watch.1.pod      | 29 ++++++++++++++++++
 docs/man/xenstore-write.1.pod      |  4 +++
 tools/xs-clients/xenstore_client.c | 48 ++++++++++++++++--------------
 9 files changed, 152 insertions(+), 22 deletions(-)
 create mode 100644 docs/man/xenstore-exists.1.pod
 create mode 100644 docs/man/xenstore-list.1.pod
 create mode 100644 docs/man/xenstore-rm.1.pod
 create mode 100644 docs/man/xenstore-watch.1.pod
Signature · 1 line
2.53.0
#1 lore raw

PATCH v2 1/8 docs: add -h parameter description to xenstore-* man pages

The "-h" parameter is missing in the man pages of the xenstore-* programs.

---
V2:
- new patch

---
 docs/man/xenstore-chmod.1.pod | 4 ++++
 docs/man/xenstore-ls.1.pod    | 4 ++++
 docs/man/xenstore-read.1.pod  | 4 ++++
 docs/man/xenstore-write.1.pod | 4 ++++
 4 files changed, 16 insertions(+)
docs/man/xenstore-chmod.1.pod +4 -0
index d221f5dffc..ca1a2172f9 100644
@@ -42,6 +42,10 @@ write, and set permissions).
 
 =over
 
+=item B<-h>
+
+Show the usage information for xenstore-chmod and exit the program.
+
 =item B<-r>
 
 Apply the permissions to the key and all its I<children>.
docs/man/xenstore-ls.1.pod +4 -0
index a9f8b32653..b070e8368c 100644
@@ -13,6 +13,10 @@ using a nested, tree-like view.
 
 =over
 
+=item B<-h>
+
+Show the usage information for xenstore-ls and exit the program.
+
 =item B<-f>
 
 Show the full path for all keys.
docs/man/xenstore-read.1.pod +4 -0
index c7768cbbe5..7fe63268bd 100644
@@ -12,6 +12,10 @@ Read values of one or more Xenstore I<PATH>s.
 
 =over
 
+=item B<-h>
+
+Show the usage information for xenstore-read and exit the program.
+
 =item B<-p>
 
 Prefix value with key name.
docs/man/xenstore-write.1.pod +4 -0
index 74f80f7b1b..33a8af2db4 100644
@@ -13,6 +13,10 @@ provided to write them at once - in one Xenstore transaction.
 
 =over
 
+=item B<-h>
+
+Show the usage information for xenstore-write and exit the program.
+
 =item B<-R>
 
 Write raw value, skip parsing escaped characters (\x..).
Signature · 1 line
2.53.0
#2 lore raw

PATCH v2 2/8 docs: add man page for xenstore-exists

In reply to Juergen Gross

There is no man page for xenstore-exists, add it.

---
V2:
- fix title grammar (Andrew Coopoer)
- add -h parameter description (Andrew Cooper)

---
 docs/man/xenstore-exists.1.pod | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 docs/man/xenstore-exists.1.pod
docs/man/xenstore-exists.1.pod new file +25 -0
new file mode 100644
index 0000000000..a6eeb7ff96
@@ -0,0 +1,25 @@
+=head1 NAME
+
+xenstore-exists - test whether Xenstore key exists
+
+=head1 SYNOPSIS
+
+B<xenstore-exists> I<PATH>
+
+=head1 DESCRIPTION
+
+Tests whether the specified Xenstore I<PATH> is readable and sets
+the exit value accordingly (B<0> if I<PTAH> is readable, B<1> if not).
+
+=over
+
+=item B<-h>
+
+Show the usage information for xenstore-exists and exit the program.
+
+=back
+
+=head1 BUGS
+
+Send bugs to [email protected], see
+https://wiki.xenproject.org/wiki/Reporting_Bugs_against_Xen_Project on how to send bug reports.
Signature · 1 line
2.53.0
#3 lore raw

PATCH v2 3/8 docs: add man page for xenstore-list

In reply to Juergen Gross

There is no man page for xenstore-list, add it.

---
V2:
- add -h parameter description (Andrew Cooper)

---
 docs/man/xenstore-list.1.pod | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 docs/man/xenstore-list.1.pod
docs/man/xenstore-list.1.pod new file +28 -0
new file mode 100644
index 0000000000..ea2853a1fc
@@ -0,0 +1,28 @@
+=head1 NAME
+
+xenstore-list - list Xenstore key children
+
+=head1 SYNOPSIS
+
+B<xenstore-list> [I<OPTION>]... [I<PATH>]...
+
+=head1 DESCRIPTION
+
+List direct children of one or more Xenstore I<PATH>s, one child per line.
+
+=over
+
+=item B<-h>
+
+Show the usage information for xenstore-list and exit the program.
+
+=item B<-p>
+
+List the full Xenstore path of each listed path.
+
+=back
+
+=head1 BUGS
+
+Send bugs to [email protected], see
+https://wiki.xenproject.org/wiki/Reporting_Bugs_against_Xen_Project on how to send bug reports.
Signature · 1 line
2.53.0
#4 lore raw

PATCH v2 4/8 docs: add man page for xenstore-rm

In reply to Juergen Gross

There is no man page for xenstore-rm, add it.

---
V2:
- add -h parameter description (Andrew Cooper)

---
 docs/man/xenstore-rm.1.pod | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 docs/man/xenstore-rm.1.pod
docs/man/xenstore-rm.1.pod new file +28 -0
new file mode 100644
index 0000000000..40e3e581eb
@@ -0,0 +1,28 @@
+=head1 NAME
+
+xenstore-rm - remove Xenstore keys
+
+=head1 SYNOPSIS
+
+B<xenstore-rm> [I<OPTION>]... [I<PATH>]...
+
+=head1 DESCRIPTION
+
+Remove one or more Xenstore B<PATH>s.
+
+=over
+
+=item B<-h>
+
+Show the usage information for xenstore-rm and exit the program.
+
+=item B<-t>
+
+Tidy up Xenstore keys which got all children removed.
+
+=back
+
+=head1 BUGS
+
+Send bugs to [email protected], see
+https://wiki.xenproject.org/wiki/Reporting_Bugs_against_Xen_Project on how to send bug reports.
Signature · 1 line
2.53.0
#5 lore raw

Re: [PATCH v2 4/8] docs: add man page for xenstore-rm

Quoted 17 lines · Juergen Gross
docs/man/xenstore-rm.1.pod new file +11 -0
new file mode 100644
index 0000000000..40e3e581eb
@@ -0,0 +1,28 @@
+=head1 NAME
+
+xenstore-rm - remove Xenstore keys
+
+=head1 SYNOPSIS
+
+B<xenstore-rm> [I<OPTION>]... [I<PATH>]...
+
+=head1 DESCRIPTION
+
+Remove one or more Xenstore B<PATH>s.

docs/man/xenstore-rm.1.pod line 21

Quoted 10 lines
docs/man/xenstore-rm.1.pod new file +10 -0
+
+=over
+
+=item B<-h>
+
+Show the usage information for xenstore-rm and exit the program.
+
+=item B<-t>
+
+Tidy up Xenstore keys which got all children removed.

Sorry for not spotting this before.  "which had all".

Also it occurs to me that "Tidy up" is not sufficiently close to delete/remove for the behaviour to be apparent to everyone.  Perhaps "Tidy up (i.e. remove) Xenstore ..."  ?

The phrase "Tidy up" does need to stay at the start of the sentence because otherwise there's no hope of knowing what -t stands for.

~Andrew

#6 lore raw

Re: [PATCH v2 4/8] docs: add man page for xenstore-rm

Quoted 31 lines · Andrew Cooper
Quoted 17 lines · Juergen Gross
docs/man/xenstore-rm.1.pod new file +11 -0
new file mode 100644
index 0000000000..40e3e581eb
@@ -0,0 +1,28 @@
+=head1 NAME
+
+xenstore-rm - remove Xenstore keys
+
+=head1 SYNOPSIS
+
+B<xenstore-rm> [I<OPTION>]... [I<PATH>]...
+
+=head1 DESCRIPTION
+
+Remove one or more Xenstore B<PATH>s.

docs/man/xenstore-rm.1.pod line 21

Quoted 10 lines
docs/man/xenstore-rm.1.pod new file +10 -0
+
+=over
+
+=item B<-h>
+
+Show the usage information for xenstore-rm and exit the program.
+
+=item B<-t>
+
+Tidy up Xenstore keys which got all children removed.

Sorry for not spotting this before.  "which had all".

Quoted 6 lines

Also it occurs to me that "Tidy up" is not sufficiently close to delete/remove for the behaviour to be apparent to everyone.  Perhaps "Tidy up (i.e. remove) Xenstore ..."  ?

The phrase "Tidy up" does need to stay at the start of the sentence because otherwise there's no hope of knowing what -t stands for.

I'm fine with all of your enhancements.

Juergen

#7 lore raw

PATCH v2 5/8 docs: add man page for xenstore-watch

In reply to Juergen Gross

There is no man page for xenstore-watch, add it.

---
V2:
- add -h parameter description (Andrew Cooper)

---
 docs/man/xenstore-watch.1.pod | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 docs/man/xenstore-watch.1.pod
docs/man/xenstore-watch.1.pod new file +29 -0
new file mode 100644
index 0000000000..de28d380b7
@@ -0,0 +1,29 @@
+=head1 NAME
+
+xenstore-watch - wait for Xenstore watch events
+
+=head1 SYNOPSIS
+
+B<xenstore-watch> [I<OPTION>]... [I<PATH>]...
+
+=head1 DESCRIPTION
+
+Set Xenstore watches to the specified I<PATH>s and print the path for each
+event happening.
+
+=over
+
+=item B<-h>
+
+Show the usage information for xenstore-watch and exit the program.
+
+=item B<-n> B<NR>
+
+Stop waiting after having received B<NR> watch events.
+
+=back
+
+=head1 BUGS
+
+Send bugs to [email protected], see
+https://wiki.xenproject.org/wiki/Reporting_Bugs_against_Xen_Project on how to send bug reports.
Signature · 1 line
2.53.0
#8 lore raw

PATCH v2 6/8 tools/xs-clients: don't exit with error when using -h parameter

In reply to Juergen Gross

The "-h" parameter of the xenstore-* programs is explicitly meant to show the usage information of the programs. This use case should not result in an error of the program's exit code.

---
V2:
- new patch

---
 tools/xs-clients/xenstore_client.c | 40 +++++++++++++++---------------
 1 file changed, 20 insertions(+), 20 deletions(-)
tools/xs-clients/xenstore_client.c +20 -20
index a104cf6487..1794451d43 100644
@@ -214,37 +214,37 @@ output_raw(const char *data, int len)
 }
 
 static void
-usage(enum mode mode, int incl_mode, const char *progname)
+usage(int eval, enum mode mode, int incl_mode, const char *progname)
 {
     const char *mstr = NULL;
 
     switch (mode) {
     case MODE_unknown:
-	errx(1, "Usage: %s <mode> [-h] [...]", progname);
+	errx(eval, "Usage: %s <mode> [-h] [...]", progname);
     case MODE_read:
 	mstr = incl_mode ? "read " : "";
-	errx(1, "Usage: %s %s[-h] [-p] [-R] key [...]", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-p] [-R] key [...]", progname, mstr);
     case MODE_write:
 	mstr = incl_mode ? "write " : "";
-	errx(1, "Usage: %s %s[-h] [-R] key value [...]", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-R] key value [...]", progname, mstr);
     case MODE_rm:
 	mstr = incl_mode ? "rm " : "";
-	errx(1, "Usage: %s %s[-h] [-t] key [...]", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-t] key [...]", progname, mstr);
     case MODE_exists:
 	mstr = incl_mode ? "exists " : "";
 	/* fallthrough */
     case MODE_list:
 	mstr = mstr ? : incl_mode ? "list " : "";
-	errx(1, "Usage: %s %s[-h] [-p] key [...]", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-p] key [...]", progname, mstr);
     case MODE_ls:
 	mstr = mstr ? : incl_mode ? "ls " : "";
-	errx(1, "Usage: %s %s[-h] [-f] [-p] [path]", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-f] [-p] [path]", progname, mstr);
     case MODE_chmod:
 	mstr = incl_mode ? "chmod " : "";
-	errx(1, "Usage: %s %s[-h] [-u] [-r] key <mode [modes...]>", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-u] [-r] key <mode [modes...]>", progname, mstr);
     case MODE_watch:
 	mstr = incl_mode ? "watch " : "";
-	errx(1, "Usage: %s %s[-h] [-n NR] key", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-n NR] key", progname, mstr);
     }
 }
 
@@ -685,7 +685,7 @@ main(int argc, char **argv)
 	command = command + strlen("xenstore-");
     }
     else if (argc < 2)
-	usage(MODE_unknown, 0, argv[0]);
+	usage(1, MODE_unknown, 0, argv[0]);
     else
     {
 	command = argv[1];
@@ -715,7 +715,7 @@ main(int argc, char **argv)
 
 	switch (c) {
 	case 'h':
-	    usage(mode, switch_argv, argv[0]);
+	    usage(0, mode, switch_argv, argv[0]);
 	    /* NOTREACHED */
         case 'f':
 	    if ( mode == MODE_ls ) {
@@ -723,44 +723,44 @@ main(int argc, char **argv)
 		desired_width = 0;
 		show_whole_path = 1;
 	    } else {
-		usage(mode, switch_argv, argv[0]);
+		usage(1, mode, switch_argv, argv[0]);
 	    }
             break;
 	case 'p':
 	    if ( mode == MODE_read || mode == MODE_list || mode == MODE_ls )
 		prefix = 1;
 	    else
-		usage(mode, switch_argv, argv[0]);
+		usage(1, mode, switch_argv, argv[0]);
 	    break;
 	case 't':
 	    if ( mode == MODE_rm )
 		tidy = 1;
 	    else
-		usage(mode, switch_argv, argv[0]);
+		usage(1, mode, switch_argv, argv[0]);
 	    break;
 	case 'u':
 	    if ( mode == MODE_chmod )
 		upto = 1;
 	    else
-		usage(mode, switch_argv, argv[0]);
+		usage(1, mode, switch_argv, argv[0]);
 	    break;
 	case 'r':
 	    if ( mode == MODE_chmod )
 		recurse = 1;
 	    else
-		usage(mode, switch_argv, argv[0]);
+		usage(1, mode, switch_argv, argv[0]);
 	    break;
 	case 'n':
 	    if ( mode == MODE_watch )
 		nr_watches = atoi(optarg);
 	    else
-		usage(mode, switch_argv, argv[0]);
+		usage(1, mode, switch_argv, argv[0]);
 	    break;
 	case 'R':
 	    if ( mode == MODE_read || mode == MODE_write )
 		raw = 1;
 	    else
-		usage(mode, switch_argv, argv[0]);
+		usage(1, mode, switch_argv, argv[0]);
 	    break;
 	}
     }
@@ -770,13 +770,13 @@ main(int argc, char **argv)
 	break;
     case MODE_write:
 	if ((argc - switch_argv - optind) % 2 == 1) {
-	    usage(mode, switch_argv, argv[0]);
+	    usage(1, mode, switch_argv, argv[0]);
 	    /* NOTREACHED */
 	}
 	/* DROP-THRU */
     default:
 	if (optind == argc - switch_argv) {
-	    usage(mode, switch_argv, argv[0]);
+	    usage(1, mode, switch_argv, argv[0]);
 	    /* NOTREACHED */
 	}
     }
Signature · 1 line
2.53.0
#9 lore raw

Re: [PATCH v2 6/8] tools/xs-clients: don't exit with error when using -h parameter

Quoted 40 lines · Juergen Gross
tools/xs-clients/xenstore_client.c +7 -7
index a104cf6487..1794451d43 100644
@@ -214,37 +214,37 @@ output_raw(const char *data, int len)
 }
 
 static void
-usage(enum mode mode, int incl_mode, const char *progname)
+usage(int eval, enum mode mode, int incl_mode, const char *progname)
 {
     const char *mstr = NULL;
 
     switch (mode) {
     case MODE_unknown:
-	errx(1, "Usage: %s <mode> [-h] [...]", progname);
+	errx(eval, "Usage: %s <mode> [-h] [...]", progname);
     case MODE_read:
 	mstr = incl_mode ? "read " : "";
-	errx(1, "Usage: %s %s[-h] [-p] [-R] key [...]", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-p] [-R] key [...]", progname, mstr);
     case MODE_write:
 	mstr = incl_mode ? "write " : "";
-	errx(1, "Usage: %s %s[-h] [-R] key value [...]", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-R] key value [...]", progname, mstr);
     case MODE_rm:
 	mstr = incl_mode ? "rm " : "";
-	errx(1, "Usage: %s %s[-h] [-t] key [...]", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-t] key [...]", progname, mstr);
     case MODE_exists:
 	mstr = incl_mode ? "exists " : "";
 	/* fallthrough */
     case MODE_list:
 	mstr = mstr ? : incl_mode ? "list " : "";
-	errx(1, "Usage: %s %s[-h] [-p] key [...]", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-p] key [...]", progname, mstr);
     case MODE_ls:
 	mstr = mstr ? : incl_mode ? "ls " : "";
-	errx(1, "Usage: %s %s[-h] [-f] [-p] [path]", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-f] [-p] [path]", progname, mstr);

tools/xs-clients/xenstore_client.c output_raw(const char *data, int len) · line 249

Quoted 10 lines
tools/xs-clients/xenstore_client.c +2 -2
     case MODE_chmod:
 	mstr = incl_mode ? "chmod " : "";
-	errx(1, "Usage: %s %s[-h] [-u] [-r] key <mode [modes...]>", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-u] [-r] key <mode [modes...]>", progname, mstr);
     case MODE_watch:
 	mstr = incl_mode ? "watch " : "";
-	errx(1, "Usage: %s %s[-h] [-n NR] key", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-n NR] key", progname, mstr);
     }
 }

I'd not even spotted this, but I agree it wants fixing.  Could I possibly talk you into naming the parameter err_val, seeing as eval commonly means something very different.

~Andrew

#10 lore raw

Re: [PATCH v2 6/8] tools/xs-clients: don't exit with error when using -h parameter

Quoted 47 lines · Andrew Cooper
Quoted 46 lines · Juergen Gross
tools/xs-clients/xenstore_client.c +8 -8
index a104cf6487..1794451d43 100644
@@ -214,37 +214,37 @@ output_raw(const char *data, int len)
  }
 
  static void
-usage(enum mode mode, int incl_mode, const char *progname)
+usage(int eval, enum mode mode, int incl_mode, const char *progname)
  {
      const char *mstr = NULL;
 
      switch (mode) {
      case MODE_unknown:
-	errx(1, "Usage: %s <mode> [-h] [...]", progname);
+	errx(eval, "Usage: %s <mode> [-h] [...]", progname);
      case MODE_read:
  	mstr = incl_mode ? "read " : "";
-	errx(1, "Usage: %s %s[-h] [-p] [-R] key [...]", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-p] [-R] key [...]", progname, mstr);
      case MODE_write:
  	mstr = incl_mode ? "write " : "";
-	errx(1, "Usage: %s %s[-h] [-R] key value [...]", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-R] key value [...]", progname, mstr);
      case MODE_rm:
  	mstr = incl_mode ? "rm " : "";
-	errx(1, "Usage: %s %s[-h] [-t] key [...]", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-t] key [...]", progname, mstr);
      case MODE_exists:
  	mstr = incl_mode ? "exists " : "";
  	/* fallthrough */
      case MODE_list:
  	mstr = mstr ? : incl_mode ? "list " : "";
-	errx(1, "Usage: %s %s[-h] [-p] key [...]", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-p] key [...]", progname, mstr);
      case MODE_ls:
  	mstr = mstr ? : incl_mode ? "ls " : "";
-	errx(1, "Usage: %s %s[-h] [-f] [-p] [path]", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-f] [-p] [path]", progname, mstr);
      case MODE_chmod:
  	mstr = incl_mode ? "chmod " : "";
-	errx(1, "Usage: %s %s[-h] [-u] [-r] key <mode [modes...]>", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-u] [-r] key <mode [modes...]>", progname, mstr);
      case MODE_watch:
  	mstr = incl_mode ? "watch " : "";
Quoted 8 lines

tools/xs-clients/xenstore_client.c output_raw(const char *data, int len) · line 249

Quoted 4 lines
tools/xs-clients/xenstore_client.c +1 -1
-	errx(1, "Usage: %s %s[-h] [-n NR] key", progname, mstr);
+	errx(eval, "Usage: %s %s[-h] [-n NR] key", progname, mstr);
      }
  }

I'd not even spotted this, but I agree it wants fixing.  Could I possibly talk you into naming the parameter err_val, seeing as eval commonly means something very different.

I took the parameter name from the errx() man page (I believe "eval" is an abbreviation of "exit-value").

I'm fine renaming it, though.

Juergen

#11 lore raw

PATCH v2 7/8 tools/xs-clients: fix usage information of xenstore-exists

In reply to Juergen Gross

The usage information of xenstore-exists is just wrong, as the "-p" option is not supported by xenstore-exists.

---
V2:
- new patch

---
 tools/xs-clients/xenstore_client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/xs-clients/xenstore_client.c +1 -1
index 1794451d43..3b02d3a196 100644
@@ -232,7 +232,7 @@ usage(int eval, enum mode mode, int incl_mode, const char *progname)
 	errx(eval, "Usage: %s %s[-h] [-t] key [...]", progname, mstr);
     case MODE_exists:
 	mstr = incl_mode ? "exists " : "";
-	/* fallthrough */
+	errx(eval, "Usage: %s %s[-h] key", progname, mstr);
     case MODE_list:
 	mstr = mstr ? : incl_mode ? "list " : "";
 	errx(eval, "Usage: %s %s[-h] [-p] key [...]", progname, mstr);
Signature · 1 line
2.53.0
#12 lore raw

PATCH v2 8/8 tools/xs-clients: fix output of "xenstore-list -p /"

In reply to Juergen Gross

When calling "xenstore-list -p /" it will prepend all listed keys with "//" instead of "/".

---
V2:
- new patch

---
 tools/xs-clients/xenstore_client.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/xs-clients/xenstore_client.c +5 -1
index 3b02d3a196..29d840df84 100644
@@ -568,13 +568,17 @@ perform(enum mode mode, int optind, int argc, char **argv, struct xs_handle *xsh
         case MODE_list: {
             unsigned int i, num;
             char **list = xs_directory(xsh, xth, argv[optind], &num);
+            const char *pref = argv[optind];
+
             if (list == NULL) {
                 warnx("could not list path %s", argv[optind]);
                 return 1;
             }
+            if (prefix && !strcmp(pref, "/"))
+                pref = "";
             for (i = 0; i < num; i++) {
                 if (prefix)
-                    output("%s/", argv[optind]);
+                    output("%s/", pref);
                 output("%s\n", list[i]);
             }
             free(list);
Signature · 1 line
2.53.0
Reviewed-by on the v2 series
#13 lore raw
In reply to Juergen Gross
Quoted 9 lines · Juergen Gross

Juergen Gross (8):
docs: add -h parameter description to xenstore-* man pages
docs: add man page for xenstore-exists
docs: add man page for xenstore-list
docs: add man page for xenstore-rm
docs: add man page for xenstore-watch tools/xs-clients: don't exit with error when using -h parameter tools/xs-clients: fix usage information of xenstore-exists tools/xs-clients: fix output of "xenstore-list -p /"

Two minor comments, both of which I can fix on commit if you're happy? (With the patch 6 knock-on to patch 7).

~Andrew

#14 lore raw
Quoted 11 lines · Andrew Cooper
Quoted 9 lines · Juergen Gross

Juergen Gross (8):
docs: add -h parameter description to xenstore-* man pages
docs: add man page for xenstore-exists
docs: add man page for xenstore-list
docs: add man page for xenstore-rm
docs: add man page for xenstore-watch tools/xs-clients: don't exit with error when using -h parameter tools/xs-clients: fix usage information of xenstore-exists tools/xs-clients: fix output of "xenstore-list -p /"

Quoted 1 line

Thanks.

Quoted 3 lines

Two minor comments, both of which I can fix on commit if you're happy? (With the patch 6 knock-on to patch 7).

Yes, sure.

Juergen