diff options
Diffstat (limited to 'tools/xenstore/xsls.c')
-rw-r--r-- | tools/xenstore/xsls.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/tools/xenstore/xsls.c b/tools/xenstore/xsls.c index 4d3b1aa1af..cf5ff6e7e6 100644 --- a/tools/xenstore/xsls.c +++ b/tools/xenstore/xsls.c @@ -6,6 +6,7 @@ #include <getopt.h> #include <unistd.h> #include <sys/ioctl.h> +#include <termios.h> static int max_width = 80; static int desired_width = 60; @@ -93,14 +94,8 @@ void usage(int argc, char *argv[]) int main(int argc, char *argv[]) { struct winsize ws; - int ret; - int c; - int show_perm = 0; - - struct xs_handle *xsh = xs_daemon_open(); - - if (xsh == NULL) - err(1, "xs_daemon_open"); + int ret, c, socket = 0, show_perm = 0; + struct xs_handle *xsh; #define PAD 2 @@ -109,12 +104,15 @@ int main(int argc, char *argv[]) if (!ret) max_width = ws.ws_col - PAD; - while (0 < (c = getopt(argc, argv, "p"))) { + while (0 < (c = getopt(argc, argv, "ps"))) { switch (c) { case 'p': show_perm = 1; max_width -= 16; break; + case 's': + socket = 1; + break; case ':': case '?': default: @@ -123,6 +121,10 @@ int main(int argc, char *argv[]) } } + xsh = socket ? xs_daemon_open() : xs_domain_open(); + if (xsh == NULL) + err(1, socket ? "xs_daemon_open" : "xs_domain_open"); + print_dir(xsh, (argc - optind) == 1 ? argv[optind] : "/", 0, show_perm); return 0; |