util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] prlimit: add a units column
@ 2011-10-24 10:30 Davidlohr Bueso
  2011-10-26 21:25 ` Karel Zak
  0 siblings, 1 reply; 4+ messages in thread
From: Davidlohr Bueso @ 2011-10-24 10:30 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

From: Davidlohr Bueso <dave@gnu.org>

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
 sys-utils/prlimit.c |   40 ++++++++++++++++++++++++----------------
 1 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/sys-utils/prlimit.c b/sys-utils/prlimit.c
index 74c7fc9..49f8f6e 100644
--- a/sys-utils/prlimit.c
+++ b/sys-utils/prlimit.c
@@ -55,27 +55,28 @@ enum {
 struct prlimit_desc {
 	const char *name;
 	const char *help;
+	const char *unit;
 	int resource;
 };
 
 static struct prlimit_desc prlimit_desc[] =
 {
-	[AS]         = { "AS",         N_("address space limit"),                RLIMIT_AS },
-	[CORE]       = { "CORE",       N_("max core file size"),                 RLIMIT_CORE },
-	[CPU]        = { "CPU",        N_("CPU time in secs"),                   RLIMIT_CPU },
-	[DATA]       = { "DATA",       N_("max data size"),                      RLIMIT_DATA },
-	[FSIZE]      = { "FSIZE",      N_("max file size"),                      RLIMIT_FSIZE },
-	[LOCKS]      = { "LOCKS",      N_("max amount of file locks held"),      RLIMIT_LOCKS },
-	[MEMLOCK]    = { "MEMLOCK",    N_("max locked-in-memory address space"), RLIMIT_MEMLOCK },
-	[MSGQUEUE]   = { "MSGQUEUE",   N_("max bytes in POSIX mqueues"),         RLIMIT_MSGQUEUE },
-	[NICE]       = { "NICE",       N_("max nice prio allowed to raise"),     RLIMIT_NICE },
-	[NOFILE]     = { "NOFILE",     N_("max amount of open files"),           RLIMIT_NOFILE },
-	[NPROC]      = { "NPROC",      N_("max number of processes"),            RLIMIT_NPROC },
-	[RSS]        = { "RSS",        N_("max resident set size"),              RLIMIT_RSS },
-	[RTPRIO]     = { "RTPRIO",     N_("max real-time priority"),             RLIMIT_RTPRIO },
-	[RTTIME]     = { "RTTIME",     N_("timeout for real-time tasks"),        RLIMIT_RTTIME },
-	[SIGPENDING] = { "SIGPENDING", N_("max amount of pending signals"),      RLIMIT_SIGPENDING },
-	[STACK]      = { "STACK",      N_("max stack size"),                     RLIMIT_STACK }
+	[AS]         = { "AS",         N_("address space limit"),                "bytes",     RLIMIT_AS },
+	[CORE]       = { "CORE",       N_("max core file size"),                 "blocks",    RLIMIT_CORE },
+	[CPU]        = { "CPU",        N_("CPU time"),                           "seconds",   RLIMIT_CPU },
+	[DATA]       = { "DATA",       N_("max data size"),                      "bytes",     RLIMIT_DATA },
+	[FSIZE]      = { "FSIZE",      N_("max file size"),                      "blocks",    RLIMIT_FSIZE },
+	[LOCKS]      = { "LOCKS",      N_("max amount of file locks held"),      NULL,        RLIMIT_LOCKS },
+	[MEMLOCK]    = { "MEMLOCK",    N_("max locked-in-memory address space"), "kbytes",    RLIMIT_MEMLOCK },
+	[MSGQUEUE]   = { "MSGQUEUE",   N_("max bytes in POSIX mqueues"),         "bytes",     RLIMIT_MSGQUEUE },
+	[NICE]       = { "NICE",       N_("max nice prio allowed to raise"),     NULL,        RLIMIT_NICE },
+	[NOFILE]     = { "NOFILE",     N_("max amount of open files"),           NULL,        RLIMIT_NOFILE },
+	[NPROC]      = { "NPROC",      N_("max number of processes"),            NULL,        RLIMIT_NPROC },
+	[RSS]        = { "RSS",        N_("max resident set size"),              "pages",     RLIMIT_RSS },
+	[RTPRIO]     = { "RTPRIO",     N_("max real-time priority"),             NULL,        RLIMIT_RTPRIO },
+	[RTTIME]     = { "RTTIME",     N_("timeout for real-time tasks"),        "microsecs", RLIMIT_RTTIME },
+	[SIGPENDING] = { "SIGPENDING", N_("max amount of pending signals"),      NULL,        RLIMIT_SIGPENDING },
+	[STACK]      = { "STACK",      N_("max stack size"),                     "kbytes",    RLIMIT_STACK }
 };
 
 struct prlimit {
@@ -91,6 +92,7 @@ enum {
 	COL_RES,
 	COL_SOFT,
 	COL_HARD,
+	COL_UNITS,
 };
 
 /* column names */
@@ -107,6 +109,7 @@ struct colinfo infos[] = {
 	[COL_HELP]    = { "DESCRIPTION", 0.1,  TT_FL_TRUNC, N_("resource description")},
 	[COL_SOFT]    = { "SOFT",        0.1,  TT_FL_RIGHT, N_("soft limit")},
 	[COL_HARD]    = { "HARD",        1,    TT_FL_RIGHT, N_("hard limit (ceiling)")},
+	[COL_UNITS]   = { "UNITS",       0.1,    TT_FL_TRUNC, N_("units")},
 };
 
 #define NCOLS ARRAY_SIZE(infos)
@@ -217,6 +220,10 @@ static void add_tt_line(struct tt *tt, struct prlimit *l)
 				asprintf(&str, "%s", "unlimited") :
 				asprintf(&str, "%llu", (unsigned long long) l->rlim.rlim_max);
 			break;
+		case COL_UNITS:
+			rc =  l->desc->unit ? asprintf(&str, "%s", l->desc->unit) :
+			                      asprintf(&str, "------");
+			break;
 		default:
 			break;
 		}
@@ -557,6 +564,7 @@ int main(int argc, char **argv)
 		columns[ncolumns++] = COL_HELP;
 		columns[ncolumns++] = COL_SOFT;
 		columns[ncolumns++] = COL_HARD;
+		columns[ncolumns++] = COL_UNITS;
 	}
 
 	if (!n) {
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] prlimit: add a units column
  2011-10-24 10:30 [PATCH] prlimit: add a units column Davidlohr Bueso
@ 2011-10-26 21:25 ` Karel Zak
  2011-11-02 17:40   ` Davidlohr Bueso
  0 siblings, 1 reply; 4+ messages in thread
From: Karel Zak @ 2011-10-26 21:25 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: util-linux

On Mon, Oct 24, 2011 at 12:30:58PM +0200, Davidlohr Bueso wrote:
> +	[AS]         = { "AS",         N_("address space limit"),                "bytes",     RLIMIT_AS },
> +	[CORE]       = { "CORE",       N_("max core file size"),                 "blocks",    RLIMIT_CORE },
> +	[CPU]        = { "CPU",        N_("CPU time"),                           "seconds",   RLIMIT_CPU },
> +	[DATA]       = { "DATA",       N_("max data size"),                      "bytes",     RLIMIT_DATA },
> +	[FSIZE]      = { "FSIZE",      N_("max file size"),                      "blocks",    RLIMIT_FSIZE },
> +	[LOCKS]      = { "LOCKS",      N_("max amount of file locks held"),      NULL,        RLIMIT_LOCKS },
> +	[MEMLOCK]    = { "MEMLOCK",    N_("max locked-in-memory address space"), "kbytes",    RLIMIT_MEMLOCK },
> +	[MSGQUEUE]   = { "MSGQUEUE",   N_("max bytes in POSIX mqueues"),         "bytes",     RLIMIT_MSGQUEUE },
> +	[NICE]       = { "NICE",       N_("max nice prio allowed to raise"),     NULL,        RLIMIT_NICE },
> +	[NOFILE]     = { "NOFILE",     N_("max amount of open files"),           NULL,        RLIMIT_NOFILE },
> +	[NPROC]      = { "NPROC",      N_("max number of processes"),            NULL,        RLIMIT_NPROC },
> +	[RSS]        = { "RSS",        N_("max resident set size"),              "pages",     RLIMIT_RSS },
> +	[RTPRIO]     = { "RTPRIO",     N_("max real-time priority"),             NULL,        RLIMIT_RTPRIO },
> +	[RTTIME]     = { "RTTIME",     N_("timeout for real-time tasks"),        "microsecs", RLIMIT_RTTIME },
> +	[SIGPENDING] = { "SIGPENDING", N_("max amount of pending signals"),      NULL,        RLIMIT_SIGPENDING },
> +	[STACK]      = { "STACK",      N_("max stack size"),                     "kbytes",    RLIMIT_STACK }

 Why without N_() ?

> +		case COL_UNITS:
> +			rc =  l->desc->unit ? asprintf(&str, "%s", l->desc->unit) :
> +			                      asprintf(&str, "------");
> +			break;

  str = l->desc->unit ? xstrdup(_(l->desc->unit)) : NULL;
 
 NULL should not be a problem for tt_* functions.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] prlimit: add a units column
  2011-10-26 21:25 ` Karel Zak
@ 2011-11-02 17:40   ` Davidlohr Bueso
  2011-11-07  8:58     ` Karel Zak
  0 siblings, 1 reply; 4+ messages in thread
From: Davidlohr Bueso @ 2011-11-02 17:40 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

On Wed, 2011-10-26 at 23:25 +0200, Karel Zak wrote:
> On Mon, Oct 24, 2011 at 12:30:58PM +0200, Davidlohr Bueso wrote:
> > +	[AS]         = { "AS",         N_("address space limit"),                "bytes",     RLIMIT_AS },
> > +	[CORE]       = { "CORE",       N_("max core file size"),                 "blocks",    RLIMIT_CORE },
> > +	[CPU]        = { "CPU",        N_("CPU time"),                           "seconds",   RLIMIT_CPU },
> > +	[DATA]       = { "DATA",       N_("max data size"),                      "bytes",     RLIMIT_DATA },
> > +	[FSIZE]      = { "FSIZE",      N_("max file size"),                      "blocks",    RLIMIT_FSIZE },
> > +	[LOCKS]      = { "LOCKS",      N_("max amount of file locks held"),      NULL,        RLIMIT_LOCKS },
> > +	[MEMLOCK]    = { "MEMLOCK",    N_("max locked-in-memory address space"), "kbytes",    RLIMIT_MEMLOCK },
> > +	[MSGQUEUE]   = { "MSGQUEUE",   N_("max bytes in POSIX mqueues"),         "bytes",     RLIMIT_MSGQUEUE },
> > +	[NICE]       = { "NICE",       N_("max nice prio allowed to raise"),     NULL,        RLIMIT_NICE },
> > +	[NOFILE]     = { "NOFILE",     N_("max amount of open files"),           NULL,        RLIMIT_NOFILE },
> > +	[NPROC]      = { "NPROC",      N_("max number of processes"),            NULL,        RLIMIT_NPROC },
> > +	[RSS]        = { "RSS",        N_("max resident set size"),              "pages",     RLIMIT_RSS },
> > +	[RTPRIO]     = { "RTPRIO",     N_("max real-time priority"),             NULL,        RLIMIT_RTPRIO },
> > +	[RTTIME]     = { "RTTIME",     N_("timeout for real-time tasks"),        "microsecs", RLIMIT_RTTIME },
> > +	[SIGPENDING] = { "SIGPENDING", N_("max amount of pending signals"),      NULL,        RLIMIT_SIGPENDING },
> > +	[STACK]      = { "STACK",      N_("max stack size"),                     "kbytes",    RLIMIT_STACK }
> 
>  Why without N_() ?

I don't know why I always avoid N(), sorry.

> 
> > +		case COL_UNITS:
> > +			rc =  l->desc->unit ? asprintf(&str, "%s", l->desc->unit) :
> > +			                      asprintf(&str, "------");
> > +			break;
> 
>   str = l->desc->unit ? xstrdup(_(l->desc->unit)) : NULL;
>  
>  NULL should not be a problem for tt_* functions.

Sorry for the delay, below is the corrected version.

Thanks,
Davidlohr

From: Davidlohr Bueso <dave@gnu.org>
Date: Wed, 2 Nov 2011 18:38:12 +0100
Subject: [PATCH] prlimit: add units column

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
 sys-utils/prlimit.c |   39 +++++++++++++++++++++++----------------
 1 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/sys-utils/prlimit.c b/sys-utils/prlimit.c
index 74c7fc9..1574b29 100644
--- a/sys-utils/prlimit.c
+++ b/sys-utils/prlimit.c
@@ -55,27 +55,28 @@ enum {
 struct prlimit_desc {
 	const char *name;
 	const char *help;
+	const char *unit;
 	int resource;
 };
 
 static struct prlimit_desc prlimit_desc[] =
 {
-	[AS]         = { "AS",         N_("address space limit"),                RLIMIT_AS },
-	[CORE]       = { "CORE",       N_("max core file size"),                 RLIMIT_CORE },
-	[CPU]        = { "CPU",        N_("CPU time in secs"),                   RLIMIT_CPU },
-	[DATA]       = { "DATA",       N_("max data size"),                      RLIMIT_DATA },
-	[FSIZE]      = { "FSIZE",      N_("max file size"),                      RLIMIT_FSIZE },
-	[LOCKS]      = { "LOCKS",      N_("max amount of file locks held"),      RLIMIT_LOCKS },
-	[MEMLOCK]    = { "MEMLOCK",    N_("max locked-in-memory address space"), RLIMIT_MEMLOCK },
-	[MSGQUEUE]   = { "MSGQUEUE",   N_("max bytes in POSIX mqueues"),         RLIMIT_MSGQUEUE },
-	[NICE]       = { "NICE",       N_("max nice prio allowed to raise"),     RLIMIT_NICE },
-	[NOFILE]     = { "NOFILE",     N_("max amount of open files"),           RLIMIT_NOFILE },
-	[NPROC]      = { "NPROC",      N_("max number of processes"),            RLIMIT_NPROC },
-	[RSS]        = { "RSS",        N_("max resident set size"),              RLIMIT_RSS },
-	[RTPRIO]     = { "RTPRIO",     N_("max real-time priority"),             RLIMIT_RTPRIO },
-	[RTTIME]     = { "RTTIME",     N_("timeout for real-time tasks"),        RLIMIT_RTTIME },
-	[SIGPENDING] = { "SIGPENDING", N_("max amount of pending signals"),      RLIMIT_SIGPENDING },
-	[STACK]      = { "STACK",      N_("max stack size"),                     RLIMIT_STACK }
+	[AS]         = { "AS",         N_("address space limit"),                N_("bytes"),     RLIMIT_AS },
+	[CORE]       = { "CORE",       N_("max core file size"),                 N_("blocks"),    RLIMIT_CORE },
+	[CPU]        = { "CPU",        N_("CPU time"),                           N_("seconds"),   RLIMIT_CPU },
+	[DATA]       = { "DATA",       N_("max data size"),                      N_("bytes"),     RLIMIT_DATA },
+	[FSIZE]      = { "FSIZE",      N_("max file size"),                      N_("blocks"),    RLIMIT_FSIZE },
+	[LOCKS]      = { "LOCKS",      N_("max amount of file locks held"),      NULL,            RLIMIT_LOCKS },
+	[MEMLOCK]    = { "MEMLOCK",    N_("max locked-in-memory address space"), N_("kbytes"),    RLIMIT_MEMLOCK },
+	[MSGQUEUE]   = { "MSGQUEUE",   N_("max bytes in POSIX mqueues"),         N_("bytes"),     RLIMIT_MSGQUEUE },
+	[NICE]       = { "NICE",       N_("max nice prio allowed to raise"),     NULL,            RLIMIT_NICE },
+	[NOFILE]     = { "NOFILE",     N_("max amount of open files"),           NULL,            RLIMIT_NOFILE },
+	[NPROC]      = { "NPROC",      N_("max number of processes"),            NULL,            RLIMIT_NPROC },
+	[RSS]        = { "RSS",        N_("max resident set size"),              N_("pages"),     RLIMIT_RSS },
+	[RTPRIO]     = { "RTPRIO",     N_("max real-time priority"),             NULL,            RLIMIT_RTPRIO },
+	[RTTIME]     = { "RTTIME",     N_("timeout for real-time tasks"),        N_("microsecs"), RLIMIT_RTTIME },
+	[SIGPENDING] = { "SIGPENDING", N_("max amount of pending signals"),      NULL,            RLIMIT_SIGPENDING },
+	[STACK]      = { "STACK",      N_("max stack size"),                     N_("kbytes"),    RLIMIT_STACK }
 };
 
 struct prlimit {
@@ -91,6 +92,7 @@ enum {
 	COL_RES,
 	COL_SOFT,
 	COL_HARD,
+	COL_UNITS,
 };
 
 /* column names */
@@ -107,6 +109,7 @@ struct colinfo infos[] = {
 	[COL_HELP]    = { "DESCRIPTION", 0.1,  TT_FL_TRUNC, N_("resource description")},
 	[COL_SOFT]    = { "SOFT",        0.1,  TT_FL_RIGHT, N_("soft limit")},
 	[COL_HARD]    = { "HARD",        1,    TT_FL_RIGHT, N_("hard limit (ceiling)")},
+	[COL_UNITS]   = { "UNITS",       0.1,  TT_FL_TRUNC, N_("units")},
 };
 
 #define NCOLS ARRAY_SIZE(infos)
@@ -217,6 +220,9 @@ static void add_tt_line(struct tt *tt, struct prlimit *l)
 				asprintf(&str, "%s", "unlimited") :
 				asprintf(&str, "%llu", (unsigned long long) l->rlim.rlim_max);
 			break;
+		case COL_UNITS:
+			str = l->desc->unit ? xstrdup(_(l->desc->unit)) : NULL;
+			break;
 		default:
 			break;
 		}
@@ -557,6 +563,7 @@ int main(int argc, char **argv)
 		columns[ncolumns++] = COL_HELP;
 		columns[ncolumns++] = COL_SOFT;
 		columns[ncolumns++] = COL_HARD;
+		columns[ncolumns++] = COL_UNITS;
 	}
 
 	if (!n) {
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] prlimit: add a units column
  2011-11-02 17:40   ` Davidlohr Bueso
@ 2011-11-07  8:58     ` Karel Zak
  0 siblings, 0 replies; 4+ messages in thread
From: Karel Zak @ 2011-11-07  8:58 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: util-linux

On Wed, Nov 02, 2011 at 06:40:19PM +0100, Davidlohr Bueso wrote:
>  sys-utils/prlimit.c |   39 +++++++++++++++++++++++----------------
>  1 files changed, 23 insertions(+), 16 deletions(-)

 Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-07  8:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-24 10:30 [PATCH] prlimit: add a units column Davidlohr Bueso
2011-10-26 21:25 ` Karel Zak
2011-11-02 17:40   ` Davidlohr Bueso
2011-11-07  8:58     ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).