[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] xenstore-stat v2



You can just use:

xenstore-ls -p

You'll get output like this:

tool = ""  . . . . . . . . . . . . . . . . . . . . . . . . .  (n0)
 xenstored = ""  . . . . . . . . . . . . . . . . . . . . . .  (n0)
vm = ""  . . . . . . . . . . . . . . . . . . . . . . . . . .  (n0)
 59809a69-1c6d-48f1-bbbe-ed08e3d69b36 = "" . . . . . . . . .  (n0,r4)
  uuid = "59809a69-1c6d-48f1-bbbe-ed08e3d69b36"  . . . . . .  (n0,r4)
  name = "domU"  . . . . . . . . . . . . . . . . . . . . . .  (n0,r4)
  pool_name = "Pool-0" . . . . . . . . . . . . . . . . . . .  (n0,r4)
  image = "" . . . . . . . . . . . . . . . . . . . . . . . .  (n0,r4)
   ostype = "linux"  . . . . . . . . . . . . . . . . . . . .  (n0,r4)
   kernel = "/boot/vmlinuz-domU" . . . . . . . . . . . . . .  (n0,r4)
   ramdisk = "/boot/initrd.img-domU" . . . . . . . . . . . .  (n0,r4)
     .
     .
     .


Patrick


On 30 March 2011 05:23, Frank Pan <frankpzh@xxxxxxxxx> wrote:
> The entries in xenstore have permission attributes. The
> attributes can be easily altered by xenstore-chmod, however,
> I cannot find a easy way to see them.
>
> I've modified xenstore_client.c to raise a new utility.
> The utility checks the permission and makes an easy-look output.
>
> Please tell me any suggestions.
> Thanks.
>
> Signed-off-by: Frank Pan <frankpzh@xxxxxxxxx>
> ---
> Âtools/xenstore/Makefile     Â|  Â2 +-
> Âtools/xenstore/xenstore_client.c | Â 58 
> ++++++++++++++++++++++++++++++++++++++
> Â2 files changed, 59 insertions(+), 1 deletions(-)
>
> diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
> index 35e68d0..ca57e9c 100644
> --- a/tools/xenstore/Makefile
> +++ b/tools/xenstore/Makefile
> @@ -9,7 +9,7 @@ CFLAGS += -I.
> ÂCFLAGS += $(CFLAGS_libxenctrl)
>
> ÂCLIENTS := xenstore-exists xenstore-list xenstore-read xenstore-rm
> xenstore-chmod
> -CLIENTS += xenstore-write xenstore-ls xenstore-watch
> +CLIENTS += xenstore-write xenstore-ls xenstore-watch xenstore-stat
>
> Â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
>
> diff --git a/tools/xenstore/xenstore_client.c 
> b/tools/xenstore/xenstore_client.c
> index 94b82b9..cd8b4d8 100644
> --- a/tools/xenstore/xenstore_client.c
> +++ b/tools/xenstore/xenstore_client.c
> @@ -37,6 +37,7 @@ enum mode {
> Â Â MODE_rm,
> Â Â MODE_write,
> Â Â MODE_watch,
> + Â ÂMODE_stat,
> Â};
>
> Âstatic char *output_buf = NULL;
> @@ -99,6 +100,9 @@ usage(enum mode mode, int incl_mode, const char *progname)
> Â Â case MODE_watch:
> Â Â Â Âmstr = incl_mode ? "watch " : "";
> Â Â Â Âerrx(1, "Usage: %s %s[-h] [-n NR] key", progname, mstr);
> + Â Âcase MODE_stat:
> + Â Â Â mstr = incl_mode ? "stat " : "";
> + Â Â Â errx(1, "Usage: %s %s[-h] [-s] key [...]", progname, mstr);
> Â Â }
> Â}
>
> @@ -286,6 +290,52 @@ do_watch(struct xs_handle *xsh, int max_events)
> Â Â }
> Â}
>
> +static const char *
> +perm_type_str(int perm_type)
> +{
> + Â Âswitch (perm_type) {
> + Â Âcase XS_PERM_WRITE:
> + Â Â Â Âreturn "-w";
> + Â Âcase XS_PERM_READ:
> + Â Â Â Âreturn "r-";
> + Â Âcase XS_PERM_READ|XS_PERM_WRITE:
> + Â Â Â Âreturn "rw";
> + Â Âcase XS_PERM_NONE:
> + Â Â Â Âreturn "--";
> + Â Âdefault:
> + Â Â Â Âreturn "uu";
> + Â Â}
> +}
> +
> +static void
> +do_stat(struct xs_handle *xsh, xs_transaction_t xth, char *path)
> +{
> + Â Âunsigned int i, nperms;
> + Â Âstruct xs_permissions *perms;
> +
> + Â Âperms = xs_get_permissions(xsh, xth, path, &nperms);
> + Â Âif (!perms)
> + Â Â Â Âerrx(1, "Unable to get permission on %s\n", path);
> +
> + Â Âif (!nperms) {
> + Â Â Â Âfree(perms);
> + Â Â Â Âerrx(1, "Cannot determine owner of %s\n", path);
> + Â Â}
> +
> + Â Âoutput("Path:\t\t\t%s\n", path);
> + Â Âoutput("Owner:\t\t\t%d\n", perms[0].id);
> + Â Âoutput("Default permission:\t%s\n", perm_type_str(perms[0].perms));
> + Â Âoutput("Permissions:\t\t");
> + Â Âfor (i = 1; i < nperms; i++) {
> + Â Â Â Âoutput("%d: %s", perms[i].id,
> + Â Â Â Â Â Â Â perm_type_str(perms[i].perms));
> + Â Â Â Âif (i < nperms - 1)
> + Â Â Â Â Â Âoutput(" ");
> + Â Â}
> + Â Âoutput("\n");
> + Â Âfree(perms);
> +}
> +
> Âstatic int
> Âperform(enum mode mode, int optind, int argc, char **argv, struct
> xs_handle *xsh,
> Â Â Â Â xs_transaction_t xth, int prefix, int tidy, int upto, int
> recurse, int nr_watches)
> @@ -459,6 +509,12 @@ perform(enum mode mode, int optind, int argc,
> char **argv, struct xs_handle *xsh
> Â Â Â Â Â Â Â Â Â Â errx(1, "Unable to add watch on %s\n", w);
> Â Â Â Â Â Â }
> Â Â Â Â Â Â do_watch(xsh, nr_watches);
> + Â Â Â Â Â Âbreak;
> + Â Â Â Â}
> + Â Â Â Âcase MODE_stat: {
> + Â Â Â Â Â Âdo_stat(xsh, xth, argv[optind]);
> + Â Â Â Â Â Âoptind++;
> + Â Â Â Â Â Âbreak;
> Â Â Â Â }
> Â Â Â Â }
> Â Â }
> @@ -486,6 +542,8 @@ static enum mode lookup_mode(const char *m)
> Â Â Â Âreturn MODE_read;
> Â Â else if (strcmp(m, "watch") == 0)
> Â Â Â Âreturn MODE_watch;
> + Â Âelse if (strcmp(m, "stat") == 0)
> + Â Â Â return MODE_stat;
>
> Â Â errx(1, "unknown mode %s\n", m);
> Â Â return 0;
> --
> 1.7.1
>
> --
> æéç, Frank Pan
>
> Computer Science and Technology
> Tsinghua University
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel
>
>

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.