WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xenstore-ls -f for find(1)-like output

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xenstore-ls -f for find(1)-like output
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 05 Dec 2007 16:20:15 -0800
Delivery-date: Wed, 05 Dec 2007 16:20:56 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1196852832 0
# Node ID b6fb8b4dc261d3392e9aa319ac0ec553b506a0f1
# Parent  b47849b774f148633ca9d5679a8732d0f38135e0
xenstore-ls -f for find(1)-like output

The current output of xenstore-ls can be quite hard to read and it is
not very intractable for postprocessing with sort|diff and the like.

The patch below provides a -f option which produces output with the
full key pathname on each line, and which disables the value
truncation and the `.'-padding when used with -p (since these latter
two aren't likely to be very useful when values are preceded by long
pathnames).

While I was at it I added the `-s' option to the usage message, where
it was previously missing.

The results looks like this:

...
/local/domain/1 = ""
/local/domain/1/vm = "/vm/8b5fd34a-e268-fab5-9cde-c06eda21df16"
/local/domain/1/device = ""
/local/domain/1/device/vbd = ""
/local/domain/1/device/vbd/2049 = ""
/local/domain/1/device/vbd/2049/virtual-device = "2049"
/local/domain/1/device/vbd/2049/device-type = "disk"
/local/domain/1/device/vbd/2049/protocol = "x86_32-abi"
...

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/xenstore/xsls.c |   34 ++++++++++++++++++++++++----------
 1 files changed, 24 insertions(+), 10 deletions(-)

diff -r b47849b774f1 -r b6fb8b4dc261 tools/xenstore/xsls.c
--- a/tools/xenstore/xsls.c     Wed Dec 05 11:05:47 2007 +0000
+++ b/tools/xenstore/xsls.c     Wed Dec 05 11:07:12 2007 +0000
@@ -11,6 +11,7 @@
 #define STRING_MAX PATH_MAX
 static int max_width = 80;
 static int desired_width = 60;
+static int show_whole_path = 0;
 
 #define TAG " = \"...\""
 #define TAG_LEN strlen(TAG)
@@ -36,23 +37,31 @@ void print_dir(struct xs_handle *h, char
         unsigned int nperms;
         int linewid;
 
-        /* Print indent and path basename */
-        for (linewid=0; linewid<cur_depth; linewid++) {
-            putchar(' ');
-        }
-        linewid += printf("%.*s",
-                          (int) (max_width - TAG_LEN - linewid), e[i]);
-
-        /* Compose fullpath and fetch value */
+        /* Compose fullpath */
         newpath_len = snprintf(newpath, sizeof(newpath), "%s%s%s", path, 
                 path[strlen(path)-1] == '/' ? "" : "/", 
                 e[i]);
+
+        /* Print indent and path basename */
+        linewid = 0;
+        if (show_whole_path) {
+            fputs(newpath, stdout);
+        } else {
+            for (; linewid<cur_depth; linewid++) {
+                putchar(' ');
+            }
+            linewid += printf("%.*s",
+                              (int) (max_width - TAG_LEN - linewid), e[i]);
+        }
+
+       /* Fetch value */
         if ( newpath_len < sizeof(newpath) ) {
             val = xs_read(h, XBT_NULL, newpath, &len);
         }
         else {
             /* Path was truncated and thus invalid */
             val = NULL;
+            len = 0;
         }
 
         /* Print value */
@@ -106,7 +115,7 @@ void print_dir(struct xs_handle *h, char
 
 void usage(int argc, char *argv[])
 {
-    fprintf(stderr, "Usage: %s [-w] [-p] [path]\n", argv[0]);
+    fprintf(stderr, "Usage: %s [-w] [-p] [-f] [-s] [path]\n", argv[0]);
 }
 
 int main(int argc, char *argv[])
@@ -122,7 +131,7 @@ int main(int argc, char *argv[])
     if (!ret)
         max_width = ws.ws_col - PAD;
 
-    while (0 < (c = getopt(argc, argv, "psw"))) {
+    while (0 < (c = getopt(argc, argv, "pswf"))) {
         switch (c) {
         case 'w':
             max_width= STRING_MAX - PAD;
@@ -133,6 +142,11 @@ int main(int argc, char *argv[])
             break;
         case 's':
             socket = 1;
+            break;
+        case 'f':
+            max_width = INT_MAX/2;
+            desired_width = 0;
+            show_whole_path = 1;
             break;
         case ':':
         case '?':

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xenstore-ls -f for find(1)-like output, Xen patchbot-unstable <=