From: Ivana Hutarova Varekova Date: Thu, 2 Sep 2010 10:17:41 +0000 (+0200) Subject: add the long options to cgget X-Git-Tag: v0.37.1~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72500d9494bab92ef9096b8d71392387b6562f66;p=thirdparty%2Flibcgroup.git add the long options to cgget This patch adds the long options parsing to cgget to be consistent with the other tools Signed-off-by: Ivana Hutarova Varekova Signed-off-by: Jan Safranek --- diff --git a/doc/man/cgget.1 b/doc/man/cgget.1 index 543f7f2f..c8d3048d 100644 --- a/doc/man/cgget.1 +++ b/doc/man/cgget.1 @@ -21,7 +21,7 @@ is the name of the cgroup which should be read. This parameter can be used multiple times. .TP -.B -r +.B -r, --variable defines parameter to display. This option can be used multiple times. @@ -31,7 +31,7 @@ defines controller which values should be displaied. This option can be used multiple times. .TP -.B -a +.B -a, --all print the variables for all controllers which consists given cgroup .TP @@ -39,9 +39,13 @@ print the variables for all controllers which consists given cgroup do not print headers, i.e. name of groups. .TP -.B -v +.B -v, --values-only print only values, not parameter names. +.TP +.B -h, --help +display help and exit + .SH EXAMPLES .nf $ cgget -r cpuset.cpus -r cpuset.mems first second diff --git a/src/tools/cgget.c b/src/tools/cgget.c index 71381e11..f63a98bb 100644 --- a/src/tools/cgget.c +++ b/src/tools/cgget.c @@ -15,6 +15,16 @@ #define LL_MAX 100 +static struct option const long_options[] = +{ + {"variable", required_argument, NULL, 'r'}, + {"help", no_argument, NULL, 'h'}, + {"all", no_argument, NULL, 'a'}, + {"values-only", no_argument, NULL, 'v'}, + {NULL, 0, NULL, 0} +}; + + static void usage(int status, const char *program_name) { if (status != 0) @@ -22,7 +32,7 @@ static void usage(int status, const char *program_name) " try %s -h' for more information.\n", program_name); else { - printf("Usage: %s [-nv] [-r] [-g] [-a] ..."\ + printf("Usage: %s [-nv] [-r] [-g] [-a] ... "\ " ...\n", program_name); } } @@ -279,7 +289,8 @@ int main(int argc, char *argv[]) } /* Parse arguments. */ - while ((c = getopt(argc, argv, "r:hnvg:a")) != -1) { + while ((c = getopt_long(argc, argv, "r:hnvg:a", long_options, NULL)) + > 0) { switch (c) { case 'h': usage(0, argv[0]);