xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] xenstore-chmod: handle arbitrary number of perms rather than MAX_PERMS constant
@ 2012-11-26  3:37 Chunyan Liu
  2012-11-27 14:15 ` Ian Campbell
  0 siblings, 1 reply; 2+ messages in thread
From: Chunyan Liu @ 2012-11-26  3:37 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.campbell

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>

---
Change to V2:
Cleanup hard tabs in lines touched in the patch.
Resend patch by hg patchbomb to avoid whitespace damage.

diff -r 8b93ac0c93f3 -r d0f86e88e3c1 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	Mon Nov 26 11:33:39 2012 +0800
@@ -25,7 +25,6 @@
 #define PATH_SEP '/'
 #define MAX_PATH_LEN 256
 
-#define MAX_PERMS 16
 
 enum mode {
     MODE_unknown,
@@ -407,44 +406,41 @@ perform(enum mode mode, int optind, int 
                 output("%s\n", list[i]);
             }
             free(list);
-	    optind++;
-	    break;
-	}
-	case MODE_ls: {
-	    do_ls(xsh, argv[optind], 0, prefix);
- 	    optind++;
- 	    break;
+            optind++;
+            break;
+        }
+        case MODE_ls: {
+            do_ls(xsh, argv[optind], 0, prefix);
+            optind++;
+            break;
         }
         case MODE_chmod: {
-            struct xs_permissions perms[MAX_PERMS];
-            int nperms = 0;
             /* save path pointer: */
             char *path = argv[optind++];
-            for (; argv[optind]; optind++, nperms++)
+            int nperms = argc - optind;
+            struct xs_permissions perms[nperms];
+            int i;
+            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'",
-			 argv[optind][0]);
+                         argv[optind][0]);
                 }
             }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] xenstore-chmod: handle arbitrary number of perms rather than MAX_PERMS constant
  2012-11-26  3:37 [PATCH v3] xenstore-chmod: handle arbitrary number of perms rather than MAX_PERMS constant Chunyan Liu
@ 2012-11-27 14:15 ` Ian Campbell
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Campbell @ 2012-11-27 14:15 UTC (permalink / raw)
  To: Chunyan Liu; +Cc: xen-devel@lists.xensource.com

On Mon, 2012-11-26 at 03:37 +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>

Applied, thanks.

> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-11-27 14:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-26  3:37 [PATCH v3] xenstore-chmod: handle arbitrary number of perms rather than MAX_PERMS constant Chunyan Liu
2012-11-27 14:15 ` Ian Campbell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).