X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvspace.c;h=37ac2c3944d285503aab81cbf52c1e16d21bb3af;hb=73afdcb42e2afc885dfb06995a6dac6a0c725040;hp=20c14a35082e15a2dfb654bc66dafa2d03723813;hpb=91365cf6f8d78ceddb70c8663c3982b3fcbca1c7;p=util-vserver.git diff --git a/src/vspace.c b/src/vspace.c index 20c14a3..37ac2c3 100644 --- a/src/vspace.c +++ b/src/vspace.c @@ -49,6 +49,7 @@ CMDLINE_OPTIONS[] = { { "new", no_argument, 0, 'n' }, { "enter", required_argument, 0, 'e' }, { "set", no_argument, 0, 's' }, + { "index", required_argument, 0, 'i' }, { "mask", required_argument, 0, 'm' }, { "default", no_argument, 0, 'd' }, { "~default", no_argument, 0, 'd' | 0x10000 }, @@ -85,6 +86,7 @@ showHelp(int fd, char const *cmd, int res) " there; is mandatory in this\n" " case\n" " --set|-s ... assign the current spaces to the current context\n" + " --index|-i ... work with the namespaces for \n" "\n" "* specifies the spaces to manipulate.\n" "It can be any combination of:\n" @@ -142,18 +144,18 @@ newSpaces(uint_least64_t mask) } static void -enterSpaces(xid_t xid, uint_least64_t mask) +enterSpaces(xid_t xid, uint_least64_t mask, uint32_t index) { - if (vc_enter_namespace(xid, mask)==-1) { + if (vc_enter_namespace(xid, mask, index)==-1) { perror(ENSC_WRAPPERS_PREFIX "vc_enter_namespace()"); exit(wrapper_exit_code); } } static void -setSpaces(xid_t xid, uint_least64_t mask) +setSpaces(xid_t xid, uint_least64_t mask, uint32_t index) { - if (vc_set_namespace(xid, mask)==-1) { + if (vc_set_namespace(xid, mask, index)==-1) { perror(ENSC_WRAPPERS_PREFIX "vc_set_namespace()"); exit(wrapper_exit_code); } @@ -165,11 +167,12 @@ int main(int argc, char *argv[]) bool do_enter = false; bool do_set = false; uint_least64_t mask = 0; + uint32_t index = 0; xid_t xid = VC_NOCTX; int sum = 0; while (1) { - int c = getopt_long(argc, argv, "+nsce:m:" "MFIUSPN", CMDLINE_OPTIONS, 0); + int c = getopt_long(argc, argv, "+nsce:m:i:" "MFIUSPN", CMDLINE_OPTIONS, 0); uint_least64_t thisbit = 0; if (c==-1) break; @@ -182,6 +185,17 @@ int main(int argc, char *argv[]) do_enter = true; xid = Evc_xidopt2xid(optarg,true); break; + case 'i' : { + unsigned long index_l; + if (!isNumberUnsigned(optarg, &index_l, true)) { + WRITE_MSG(2, "Invalid index '"); + WRITE_STR(2, optarg); + WRITE_MSG(2, "'; try '--help' for more information\n"); + return wrapper_exit_code; + } + index = (uint32_t)index_l; + break; + } case 'm' : { unsigned long mask_l; if (!isNumberUnsigned(optarg, &mask_l, true)) { @@ -205,7 +219,7 @@ int main(int argc, char *argv[]) if (thisbit == (__typeof__(thisbit)) -1) { thisbit = vc_get_space_mask(); if (thisbit == (__typeof__(thisbit)) -1) - thisbit = CLONE_NEWNS | CLONE_FS; + thisbit = 0; } break; @@ -234,8 +248,8 @@ int main(int argc, char *argv[]) WRITE_MSG(2, "No command specified; try '--help' for more information\n"); else { if (do_new) newSpaces(mask); - else if (do_set) setSpaces(VC_SAMECTX, mask); - else if (do_enter) enterSpaces(xid, mask); + else if (do_set) setSpaces(VC_SAMECTX, mask, index); + else if (do_enter) enterSpaces(xid, mask, index); if (optind