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] Added xsls utility, which recursively lists the contents

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Added xsls utility, which recursively lists the contents of the store.
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 11 Oct 2005 09:32:10 +0000
Delivery-date: Tue, 11 Oct 2005 09:29:42 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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 emellor@ewan
# Node ID dfadbb90d09266f63da7c4d65bc5d10abecc8165
# Parent  4b93736d64f78a0c6ce6e8b659a6756d5de58cdd
Added xsls utility, which recursively lists the contents of the store.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

diff -r 4b93736d64f7 -r dfadbb90d092 .hgignore
--- a/.hgignore Tue Oct 11 09:03:54 2005
+++ b/.hgignore Tue Oct 11 09:29:29 2005
@@ -161,6 +161,7 @@
 ^tools/xenstore/xs_tdb_dump$
 ^tools/xenstore/xs_test$
 ^tools/xenstore/xs_watch_stress$
+^tools/xenstore/xsls$
 ^tools/xentrace/xenctx$
 ^tools/xentrace/xentrace$
 ^xen/BLOG$
diff -r 4b93736d64f7 -r dfadbb90d092 tools/xenstore/Makefile
--- a/tools/xenstore/Makefile   Tue Oct 11 09:03:54 2005
+++ b/tools/xenstore/Makefile   Tue Oct 11 09:29:29 2005
@@ -27,7 +27,7 @@
 CLIENTS += xenstore-write
 CLIENTS_OBJS := $(patsubst xenstore-%,xenstore_%.o,$(CLIENTS))
 
-all: libxenstore.so xenstored $(CLIENTS) xs_tdb_dump
+all: libxenstore.so xenstored $(CLIENTS) xs_tdb_dump xsls
 
 testcode: xs_test xenstored_test xs_random
 
@@ -39,6 +39,9 @@
 
 $(CLIENTS_OBJS): xenstore_%.o: xenstore_client.c
        $(COMPILE.c) -DCLIENT_$(*F) -o $@ $<
+
+xsls: xsls.o
+       $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -lxenctrl -L. -lxenstore -o $@
 
 xenstored_test: xenstored_core_test.o xenstored_watch_test.o 
xenstored_domain_test.o xenstored_transaction_test.o xs_lib.o talloc_test.o 
fake_libxc.o utils.o tdb.o
        $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
@@ -134,6 +137,7 @@
        $(INSTALL_DIR) -p $(DESTDIR)/usr/include
        $(INSTALL_PROG) xenstored $(DESTDIR)/usr/sbin
        $(INSTALL_PROG) $(CLIENTS) $(DESTDIR)/usr/bin
+       $(INSTALL_PROG) xsls $(DESTDIR)/usr/bin
        $(INSTALL_DIR) -p $(DESTDIR)/usr/$(LIBDIR)
        $(INSTALL_DATA) libxenstore.so $(DESTDIR)/usr/$(LIBDIR)
        $(INSTALL_DATA) xs.h $(DESTDIR)/usr/include
diff -r 4b93736d64f7 -r dfadbb90d092 tools/xenstore/xsls.c
--- /dev/null   Tue Oct 11 09:03:54 2005
+++ b/tools/xenstore/xsls.c     Tue Oct 11 09:29:29 2005
@@ -0,0 +1,47 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <err.h>
+#include <xs.h>
+
+void print_dir(struct xs_handle *h, char *path, int cur_depth)
+{
+    char **e;
+    char newpath[512], *val;
+    int num, i, len;
+
+    e = xs_directory(h, NULL, path, &num);
+    if (e == NULL)
+        err(1, "xs_directory (%s)", path);
+
+    for (i = 0; i<num; i++) {
+        int j;
+        for (j=0; j<cur_depth; j++) printf(" ");
+        printf("%s", e[i]);
+        sprintf(newpath, "%s%s%s", path, 
+                path[strlen(path)-1] == '/' ? "" : "/", 
+                e[i]);
+        val = xs_read(h, NULL, newpath, &len);
+        if (val == NULL)
+            printf(":\n");
+        else if ((unsigned)len > (151 - strlen(e[i])))
+            printf(" = \"%.*s...\"\n", 148 - strlen(e[i]), val);
+        else
+            printf(" = \"%s\"\n", val);
+        free(val);
+        print_dir(h, newpath, cur_depth+1); 
+    }
+    free(e);
+}
+
+int main(int argc, char *argv[])
+{
+    struct xs_handle *xsh = xs_daemon_open();
+
+    if (xsh == NULL)
+        err(1, "xs_daemon_open");
+
+    print_dir(xsh, argc == 1 ? "/" : argv[1], 0);
+
+    return 0;
+}

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Added xsls utility, which recursively lists the contents of the store., Xen patchbot -unstable <=