# HG changeset patch # User Ian Campbell # Date 1207658430 -3600 # Node ID af555f1dfa4763a9731b05ccb73c61976234c96b # Parent f9122c15f2148abf8d8a7738738298102877060f xenstore: merge xenstore-ls into the multicall binary. This is done separately from moving the other utilities into the mutlicall since ls is slightly different and was already separate. Signed-off-by: Ian Campbell diff -r f9122c15f214 -r af555f1dfa47 tools/xenstore/Makefile --- a/tools/xenstore/Makefile Tue Apr 08 13:40:30 2008 +0100 +++ b/tools/xenstore/Makefile Tue Apr 08 13:40:30 2008 +0100 @@ -13,7 +13,7 @@ DEP = .*.d DEP = .*.d CLIENTS := xenstore-exists xenstore-list xenstore-read xenstore-rm xenstore-chmod -CLIENTS += xenstore-write +CLIENTS += xenstore-write xenstore-ls XENSTORED_OBJS = xenstored_core.o xenstored_watch.o xenstored_domain.o xenstored_transaction.o xs_lib.o talloc.o utils.o tdb.o hashtable.o @@ -27,14 +27,14 @@ LIBXENSTORE := libxenstore.so LIBXENSTORE := libxenstore.so else LIBXENSTORE := libxenstore.a -xenstore xenstore-control xenstore-ls: CFLAGS += -static +xenstore xenstore-control: CFLAGS += -static endif .PHONY: all all: libxenstore.so libxenstore.a xenstored clients xs_tdb_dump .PHONY: clients -clients: xenstore $(CLIENTS) xenstore-control xenstore-ls +clients: xenstore $(CLIENTS) xenstore-control ifeq ($(CONFIG_SunOS),y) xenstored_probes.h: xenstored_probes.d @@ -60,9 +60,6 @@ xenstore-control: xenstore_control.o $(L xenstore-control: xenstore_control.o $(LIBXENSTORE) $(CC) $(CFLAGS) $(LDFLAGS) $< -L. -lxenstore $(SOCKET_LIBS) -o $@ -xenstore-ls: xsls.o $(LIBXENSTORE) - $(CC) $(CFLAGS) $(LDFLAGS) $< -L. -lxenstore $(SOCKET_LIBS) -o $@ - xs_tdb_dump: xs_tdb_dump.o utils.o tdb.o talloc.o $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ @@ -83,7 +80,7 @@ clean: clean: rm -f *.a *.o *.opic *.so* xenstored_probes.h rm -f xenstored xs_random xs_stress xs_crashme - rm -f xs_tdb_dump xenstore-control xenstore-ls + rm -f xs_tdb_dump xenstore-control rm -f xenstore $(CLIENTS) $(RM) $(DEP) @@ -108,7 +105,6 @@ install: all set -e ; for c in $(CLIENTS) ; do \ ln -f $(DESTDIR)/usr/bin/xenstore $(DESTDIR)/usr/bin/$${c} ; \ done - $(INSTALL_PROG) xenstore-ls $(DESTDIR)$(BINDIR) $(INSTALL_DIR) $(DESTDIR)$(LIBDIR) $(INSTALL_PROG) libxenstore.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR) ln -sf libxenstore.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)/libxenstore.so.$(MAJOR) diff -r f9122c15f214 -r af555f1dfa47 tools/xenstore/xenstore_client.c --- a/tools/xenstore/xenstore_client.c Tue Apr 08 13:40:30 2008 +0100 +++ b/tools/xenstore/xenstore_client.c Tue Apr 08 13:40:30 2008 +0100 @@ -16,7 +16,11 @@ #include #include #include +#include +#include #include + +#include #define PATH_SEP '/' #define MAX_PATH_LEN 256 @@ -28,6 +32,7 @@ enum mode { MODE_chmod, MODE_exists, MODE_list, + MODE_ls, MODE_read, MODE_rm, MODE_write, @@ -84,6 +89,9 @@ usage(enum mode mode, int incl_mode, con case MODE_list: mstr = mstr ? : incl_mode ? "list " : ""; errx(1, "Usage: %s %s[-h] [-s] key [...]", progname, mstr); + case MODE_ls: + mstr = mstr ? : incl_mode ? "ls " : ""; + errx(1, "Usage: %s %s[-h] [-s] [path]", progname, mstr); case MODE_chmod: mstr = incl_mode ? "chmod " : ""; errx(1, "Usage: %s %s[-h] [-s] key ", progname, mstr); @@ -101,6 +109,111 @@ do_rm(char *path, struct xs_handle *xsh, warnx("could not remove path %s", path); return 1; } +} + +#define STRING_MAX XENSTORE_ABS_PATH_MAX+1024 +static int max_width = 80; +static int desired_width = 60; +static int show_whole_path = 0; + +#define TAG " = \"...\"" +#define TAG_LEN strlen(TAG) + +#define MIN(a, b) (((a) < (b))? (a) : (b)) + +void do_ls(struct xs_handle *h, char *path, int cur_depth, int show_perms) +{ + static struct expanding_buffer ebuf; + char **e; + char newpath[STRING_MAX], *val; + int newpath_len; + int i; + unsigned int num, len; + + e = xs_directory(h, XBT_NULL, path, &num); + if (e == NULL) + err(1, "xs_directory (%s)", path); + + for (i = 0; i 2; break; + case MODE_ls: + transaction = 0; + break; default: transaction = 1; break; + } + + if ( mode == MODE_ls ) + { + memset(&ws, 0, sizeof(ws)); + ret = ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws); + if (!ret) + max_width = ws.ws_col - 2; } xsh = socket ? xs_daemon_open() : xs_domain_open(); diff -r f9122c15f214 -r af555f1dfa47 tools/xenstore/xsls.c --- a/tools/xenstore/xsls.c Tue Apr 08 13:40:30 2008 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,171 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define STRING_MAX XENSTORE_ABS_PATH_MAX+1024 -static int max_width = 80; -static int desired_width = 60; -static int show_whole_path = 0; - -#define TAG " = \"...\"" -#define TAG_LEN strlen(TAG) - -#define MIN(a, b) (((a) < (b))? (a) : (b)) - -void print_dir(struct xs_handle *h, char *path, int cur_depth, int show_perms) -{ - static struct expanding_buffer ebuf; - char **e; - char newpath[STRING_MAX], *val; - int newpath_len; - int i; - unsigned int num, len; - - e = xs_directory(h, XBT_NULL, path, &num); - if (e == NULL) - err(1, "xs_directory (%s)", path); - - for (i = 0; i