Tony Ambrozie wrote: > Your code changes for both zoneadm and zonecfg would preserve the > current zonexxx -z zonename for backwards compatibility purposes, is > that correct?
Correct. There are some command line options that the changes I've made don't support, such as using -R. That's quite deliberate. The aim of the changes was to address the common use cases of the commands and make their use more intuitive when viewed with the other commands in OpenSolaris. Darren > > Thank you, > > > On Mon, Jun 9, 2008 at 11:51 AM, Darren Reed <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > Someone mentioned zonecfg was the cause of some similar awkwardness... > > So here's a patch attached for that. > > Darren > > > > ------- usr/src/cmd/zonecfg/zonecfg.c ------- > > Index: usr/src/cmd/zonecfg/zonecfg.c > *** /biscuit/onnv/usr/src/cmd/zonecfg/zonecfg.c Mon Mar 24 > 17:30:38 2008 > --- /biscuit/onnv_20080608/usr/src/cmd/zonecfg/zonecfg.c > Mon Jun 9 11:47:41 2008 > *************** > *** 1071,1076 **** > --- 1071,1077 ---- > execname, cmd_to_str(CMD_HELP)); > (void) fprintf(fp, "\t%s -z <zone>\t\t\t(%s)\n", > execname, gettext("interactive")); > + (void) fprintf(fp, "\t%s <command> <zone>\n", > execname); > (void) fprintf(fp, "\t%s -z <zone> <command>\n", > execname); > (void) fprintf(fp, "\t%s -z <zone> -f > <command-file>\n", > execname); > *************** > *** 6653,6689 **** > return (execbasename); > } > > ! int > ! main(int argc, char *argv[]) > { > ! int err, arg; > ! struct stat st; > ! > ! /* This must be before anything goes to stdout. */ > ! setbuf(stdout, NULL); > ! > ! saw_error = B_FALSE; > ! cmd_file_mode = B_FALSE; > ! execname = get_execbasename(argv[0]); > ! > ! (void) setlocale(LC_ALL, ""); > ! (void) textdomain(TEXT_DOMAIN); > ! > ! if (getzoneid() != GLOBAL_ZONEID) { > ! zerr(gettext("%s can only be run from the global > zone."), > ! execname); > ! exit(Z_ERR); > ! } > ! > ! if (argc < 2) { > ! usage(B_FALSE, HELP_USAGE | HELP_SUBCMDS); > exit(Z_USAGE); > } > ! if (strcmp(argv[1], cmd_to_str(CMD_HELP)) == 0) { > ! (void) one_command_at_a_time(argc - 1, &(argv[1])); > ! exit(Z_OK); > ! } > > while ((arg = getopt(argc, argv, "?f:R:z:")) != EOF) { > switch (arg) { > case '?': > --- 6654,6679 ---- > return (execbasename); > } > > ! static void > ! set_zonename(char *zonename) > { > ! if (strcmp(zonename, GLOBAL_ZONENAME) == 0) { > ! global_zone = B_TRUE; > ! } else if (zonecfg_validate_zonename(zonename) != Z_OK) { > ! zone_perror(zonename, Z_BOGUS_ZONE_NAME, B_TRUE); > ! usage(B_FALSE, HELP_SYNTAX); > exit(Z_USAGE); > } > ! (void) strlcpy(zone, zonename, sizeof (zone)); > ! (void) strlcpy(revert_zone, zonename, sizeof (zone)); > ! } > > + static void > + get_clioptions(int argc, char *argv[]) > + { > + struct stat st; > + int arg; > + > while ((arg = getopt(argc, argv, "?f:R:z:")) != EOF) { > switch (arg) { > case '?': > *************** > *** 6712,6726 **** > zonecfg_set_root(optarg); > break; > case 'z': > ! if (strcmp(optarg, GLOBAL_ZONENAME) == 0) { > ! global_zone = B_TRUE; > ! } else if > (zonecfg_validate_zonename(optarg) != Z_OK) { > ! zone_perror(optarg, > Z_BOGUS_ZONE_NAME, B_TRUE); > ! usage(B_FALSE, HELP_SYNTAX); > ! exit(Z_USAGE); > ! } > ! (void) strlcpy(zone, optarg, sizeof (zone)); > ! (void) strlcpy(revert_zone, optarg, sizeof > (zone)); > break; > default: > usage(B_FALSE, HELP_USAGE); > --- 6702,6708 ---- > zonecfg_set_root(optarg); > break; > case 'z': > ! set_zonename(optarg); > break; > default: > usage(B_FALSE, HELP_USAGE); > *************** > *** 6727,6733 **** > --- 6709,6761 ---- > exit(Z_USAGE); > } > } > + } > > + int > + main(int argc, char *argv[]) > + { > + int err; > + > + /* This must be before anything goes to stdout. */ > + setbuf(stdout, NULL); > + > + saw_error = B_FALSE; > + cmd_file_mode = B_FALSE; > + execname = get_execbasename(argv[0]); > + > + (void) setlocale(LC_ALL, ""); > + (void) textdomain(TEXT_DOMAIN); > + > + if (getzoneid() != GLOBAL_ZONEID) { > + zerr(gettext("%s can only be run from the global > zone."), > + execname); > + exit(Z_ERR); > + } > + > + if (argc < 2) { > + usage(B_FALSE, HELP_USAGE | HELP_SUBCMDS); > + exit(Z_USAGE); > + } > + if (strcmp(argv[1], cmd_to_str(CMD_HELP)) == 0) { > + (void) one_command_at_a_time(argc - 1, &(argv[1])); > + exit(Z_OK); > + } > + > + if (argc >= 3 && *argv[1] != '-' && *argv[2] != '-') { > + /* > + * We're assuming that the command line has been > written > + * as "zonecfg subcmd zonename" but the parser for > the CLI > + * assumes "zonecfg -z zone subcmd". If we move the > + * subcommand and adjust optind, we can fake > having parsed > + * the "-z zonename"... > + */ > + set_zonename(argv[2]); > + argv[2] = argv[1]; > + optind++; > + } else { > + get_clioptions(argc, argv); > + } > + > if (optind > argc || strcmp(zone, "") == 0) { > usage(B_FALSE, HELP_USAGE); > exit(Z_USAGE); > > _______________________________________________ > zones-discuss mailing list > zones-discuss@opensolaris.org <mailto:zones-discuss@opensolaris.org> > > _______________________________________________ zones-discuss mailing list zones-discuss@opensolaris.org