PERFORCE change 188454 for review
Edward Tomasz Napierala
trasz at FreeBSD.org
Wed Feb 2 16:27:50 UTC 2011
http://p4web.freebsd.org/@@188454?ac=10
Change 188454 by trasz at trasz_victim on 2011/02/02 16:27:15
Add -n option to rctl(8).
Affected files ...
.. //depot/projects/soc2009/trasz_limits/usr.bin/rctl/rctl.8#4 edit
.. //depot/projects/soc2009/trasz_limits/usr.bin/rctl/rctl.c#4 edit
Differences ...
==== //depot/projects/soc2009/trasz_limits/usr.bin/rctl/rctl.8#4 (text+ko) ====
@@ -34,12 +34,14 @@
.Sh SYNOPSIS
.Nm
.Op Fl h
+.Op Fl n
.Op Ar filter
.Nm
.Fl a
.Op Ar rule
.Nm
.Op Fl h
+.Op Fl n
.Fl l
.Op Ar filter
.Nm
@@ -78,6 +80,8 @@
"Human-readable" output.
Use unit suffixes: Byte, Kilobyte, Megabyte,
Gigabyte, Terabyte and Petabyte.
+.It Fl n
+Display user IDs numerically rather than converting them to a user name.
.Pp
.Sh RULE SYNTAX
Syntax for a rule is subject:subject-id:resource:action=amount/per.
==== //depot/projects/soc2009/trasz_limits/usr.bin/rctl/rctl.c#4 (text+ko) ====
@@ -283,18 +283,18 @@
* Print rules, one per line.
*/
static void
-print_rules(char *rules, int hflag)
+print_rules(char *rules, int hflag, int nflag)
{
char *rule;
while ((rule = strsep(&rules, ",")) != NULL) {
if (rule[0] == '\0')
break; /* XXX */
- rule = humanize_ids(rule);
+ if (nflag == 0)
+ rule = humanize_ids(rule);
if (hflag)
rule = humanize_amount(rule);
printf("%s\n", rule);
- free(rule);
}
}
@@ -310,7 +310,7 @@
}
static void
-show_limits(char *filter, int hflag)
+show_limits(char *filter, int hflag, int nflag)
{
int error;
char *outbuf = NULL;
@@ -327,7 +327,7 @@
err(1, "rctl_get_limits");
} while (error && errno == ERANGE);
- print_rules(outbuf, hflag);
+ print_rules(outbuf, hflag, nflag);
free(filter);
free(outbuf);
}
@@ -412,7 +412,7 @@
* Query the kernel about resource limit rules and print them out.
*/
static void
-show_rules(char *filter, int hflag)
+show_rules(char *filter, int hflag, int nflag)
{
int error;
char *outbuf = NULL;
@@ -434,7 +434,7 @@
err(1, "rctl_get_rules");
} while (error && errno == ERANGE);
- print_rules(outbuf, hflag);
+ print_rules(outbuf, hflag, nflag);
free(outbuf);
}
@@ -449,10 +449,11 @@
int
main(int argc __unused, char **argv __unused)
{
- int ch, aflag = 0, hflag = 0, lflag = 0, rflag = 0, uflag = 0;
+ int ch, aflag = 0, hflag = 0, nflag = 0, lflag = 0, rflag = 0,
+ uflag = 0;
char *rule = NULL;
- while ((ch = getopt(argc, argv, "a:hl:r:u:")) != -1) {
+ while ((ch = getopt(argc, argv, "a:hl:nr:u:")) != -1) {
switch (ch) {
case 'a':
aflag = 1;
@@ -465,6 +466,9 @@
lflag = 1;
rule = strdup(optarg);
break;
+ case 'n':
+ nflag = 1;
+ break;
case 'r':
rflag = 1;
rule = strdup(optarg);
@@ -506,7 +510,7 @@
}
if (lflag) {
- show_limits(rule, hflag);
+ show_limits(rule, hflag, nflag);
return (0);
}
@@ -520,6 +524,6 @@
return (0);
}
- show_rules(rule, hflag);
+ show_rules(rule, hflag, nflag);
return (0);
}
More information about the p4-projects
mailing list