X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvspace.c;h=db2ef2ab2ef06f2af9c63640e4c36a3bc0cee681;hb=4e63a3343f7f5a4ac9f6d18bac1ad51b5cfd042d;hp=20c14a35082e15a2dfb654bc66dafa2d03723813;hpb=91365cf6f8d78ceddb70c8663c3982b3fcbca1c7;p=util-vserver.git diff --git a/src/vspace.c b/src/vspace.c index 20c14a3..db2ef2a 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 }, @@ -142,18 +143,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 +166,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 +184,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 +218,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 +247,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