On 05/09/2011 10:40 AM, Ivana Hutarova Varekova wrote:
> Most of the tools use <controllers>:<path> together with -g option
> (cgcreate, cgget and cgclassify), this patch adds this option to
> lscgroups tool
>
> Signed-off-by: Ivana Hutarova Varekova <[email protected]>
Acked-By: Jan Safranek <[email protected]>
> ---
>
> doc/man/lscgroup.1 | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/doc/man/lscgroup.1 b/doc/man/lscgroup.1
> index 0950af3..08b60d4 100644
> --- a/doc/man/lscgroup.1
> +++ b/doc/man/lscgroup.1
> @@ -7,7 +7,7 @@
> lscgroup \- list all cgroups
>
> .SH SYNOPSIS
> -\fBlscgroup\fR [<\fIcontrollers>:<path\fR>] [...]
> +\fBlscgroup\fR [[\fB-g\fR] <\fIcontrollers>:<path\fR>] [...]
> .br
> \fBlscgroup\fR [\fB-h|--help\fR]
>
> diff --git a/src/tools/lscgroup.c b/src/tools/lscgroup.c
> index 82e0117..e6b1d09 100644
> --- a/src/tools/lscgroup.c
> +++ b/src/tools/lscgroup.c
> @@ -249,6 +249,7 @@ int main(int argc, char *argv[])
>
> int ret = 0;
> int c;
> + int i;
>
> int flags = 0;
>
> @@ -256,27 +257,36 @@ int main(int argc, char *argv[])
>
> static struct option options[] = {
> {"help", 0, 0, 'h'},
> + {"group", required_argument, NULL, 'g'},
> {0, 0, 0, 0}
> };
>
> + memset(cgroup_list, 0, sizeof(cgroup_list));
> +
> /* parse arguments */
> - while ((c = getopt_long(argc, argv, "h", options, NULL)) > 0) {
> + while ((c = getopt_long(argc, argv, "hg:", options, NULL)) > 0) {
> switch (c) {
> case 'h':
> usage(0, argv[0]);
> - return 0;
> + ret = 0;
> + goto err;
> + case 'g':
> + ret = parse_cgroup_spec(cgroup_list, optarg,
> + CG_HIER_MAX);
> + if (ret) {
> + fprintf(stderr, "%s: cgroup controller"
> + " and path parsing failed (%s)\n",
> + argv[0], optarg);
> + return ret;
> + }
> + break;
> default:
> usage(1, argv[0]);
> - return -1;
> + ret = 1;
> + goto err;
> }
> }
>
> - memset(cgroup_list, 0, sizeof(cgroup_list));
> -
> - /* no cgroup on input */
> - if (optind < argc)
> - flags |= FL_LIST;
> -
> /* read the list of controllers */
> while (optind < argc) {
> ret = parse_cgroup_spec(cgroup_list, argv[optind],
> @@ -290,8 +300,23 @@ int main(int argc, char *argv[])
> optind++;
> }
>
> - /* print the information, based on list of input cgroups and flags */
> + if (cgroup_list[0] != NULL) {
> + /* cgroups on input */
> + flags |= FL_LIST;
> + }
> +
> + /* print the information
> + based on list of input cgroups and flags */
> ret = cgroup_list_cgroups(argv[0], cgroup_list, flags);
>
> +err:
> + if (cgroup_list[0]) {
> + for (i = 0; i < CG_HIER_MAX; i++) {
> + if (cgroup_list[i])
> + cgroup_free_group_spec(cgroup_list[i]);
> + }
> + }
> +
> +
> return ret;
> }
>
>
> ------------------------------------------------------------------------------
> WhatsUp Gold - Download Free Network Management Software
> The most intuitive, comprehensive, and cost-effective network
> management toolset available today. Delivers lowest initial
> acquisition cost and overall TCO of any competing solution.
> http://p.sf.net/sfu/whatsupgold-sd
> _______________________________________________
> Libcg-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/libcg-devel
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel