Chunyan Liu
2012-Nov-20 02:59 UTC
[PATCH V2]xenstore-chmod: handle arbitrary number of perms rather than MAX_PERMS constant
Constant MAX_PERMS 16 is too small to use in some occasions, e.g. if there are more than 16 domU(s) on one hypervisor (it''s easy to achieve) and one wants to do xenstore-chmod PATH to all domU(s). So, remove MAX_PERMS limitation and make it as arbitrary number of perms. Signed-off-by: Chunyan Liu <cyliu@suse.com> Change to V1: Follow Ian''s comment, change ''perms'' to be array instead of pointer. diff -r 8b93ac0c93f3 tools/xenstore/xenstore_client.c --- a/tools/xenstore/xenstore_client.c Tue Nov 13 11:19:17 2012 +0000 +++ b/tools/xenstore/xenstore_client.c Tue Nov 20 10:35:33 2012 +0800 @@ -25,7 +25,6 @@ #define PATH_SEP ''/'' #define MAX_PATH_LEN 256 -#define MAX_PERMS 16 enum mode { MODE_unknown, @@ -416,31 +415,28 @@ perform(enum mode mode, int optind, int break; } case MODE_chmod: { - struct xs_permissions perms[MAX_PERMS]; - int nperms = 0; /* save path pointer: */ char *path = argv[optind++]; + int nperms = argc - optind; + struct xs_permissions perms[nperms]; + int i; - for (; argv[optind]; optind++, nperms++) + for (i = 0; argv[optind]; optind++, i++) { - if (MAX_PERMS <= nperms) - errx(1, "Too many permissions specified. " - "Maximum per invocation is %d.", MAX_PERMS); - - perms[nperms].id = atoi(argv[optind]+1); + perms[i].id = atoi(argv[optind]+1); switch (argv[optind][0]) { case ''n'': - perms[nperms].perms = XS_PERM_NONE; + perms[i].perms = XS_PERM_NONE; break; case ''r'': - perms[nperms].perms = XS_PERM_READ; + perms[i].perms = XS_PERM_READ; break; case ''w'': - perms[nperms].perms = XS_PERM_WRITE; + perms[i].perms = XS_PERM_WRITE; break; case ''b'': - perms[nperms].perms = XS_PERM_READ | XS_PERM_WRITE; + perms[i].perms = XS_PERM_READ | XS_PERM_WRITE; break; default: errx(1, "Invalid permission specification: ''%c''",
Ian Campbell
2012-Nov-23 09:52 UTC
Re: [PATCH V2]xenstore-chmod: handle arbitrary number of perms rather than MAX_PERMS constant
On Tue, 2012-11-20 at 02:59 +0000, Chunyan Liu wrote:> Constant MAX_PERMS 16 is too small to use in some occasions, e.g. if > there are more than 16 domU(s) on one hypervisor (it''s easy to > achieve) and one wants to do xenstore-chmod PATH to all domU(s). So, > remove MAX_PERMS limitation and make it as arbitrary number of perms. > > Signed-off-by: Chunyan Liu <cyliu@suse.com>Acked-by: Ian Campbell <ian.campbell@citrix.com> Unfortunately the patch is whitespace damaged and therefore doesn''t apply. There are some stray hard tabs in the source which have turned into soft tabs in your mail. http://wiki.xen.org/wiki/Submitting_Xen_Patches has some hints on using hg patchbomb to avoid this, and also a link to Linux''s email-client.txt which has hints on how to avoid whitespace mangling with various clients. BTW, I''d be happy for you to cleanup the hard tabs in lines which you are touching anyway, but they need to be present in the "-" line for the patch to apply of course. Ian.