summaryrefslogtreecommitdiffstats
path: root/usr.bin/rctl
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
committersjg <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
commit65145fa4c81da358fcbc3b650156dab705dfa34e (patch)
tree55c065b6730aaac2afb6c29933ee6ec5fa4c4249 /usr.bin/rctl
parent60ff4eb0dff94a04d75d0d52a3957aaaf5f8c693 (diff)
parente6b664c390af88d4a87208bc042ce503da664c3b (diff)
downloadFreeBSD-src-65145fa4c81da358fcbc3b650156dab705dfa34e.zip
FreeBSD-src-65145fa4c81da358fcbc3b650156dab705dfa34e.tar.gz
Merge sync of head
Diffstat (limited to 'usr.bin/rctl')
-rw-r--r--usr.bin/rctl/Makefile3
-rw-r--r--usr.bin/rctl/rctl.812
-rw-r--r--usr.bin/rctl/rctl.c47
3 files changed, 55 insertions, 7 deletions
diff --git a/usr.bin/rctl/Makefile b/usr.bin/rctl/Makefile
index c5c32eb..0191bdd 100644
--- a/usr.bin/rctl/Makefile
+++ b/usr.bin/rctl/Makefile
@@ -3,7 +3,6 @@
PROG= rctl
MAN= rctl.8
-DPADD= ${LIBUTIL}
-LDADD= -lutil
+LIBADD= util
.include <bsd.prog.mk>
diff --git a/usr.bin/rctl/rctl.8 b/usr.bin/rctl/rctl.8
index 3f72b91..fe14756 100644
--- a/usr.bin/rctl/rctl.8
+++ b/usr.bin/rctl/rctl.8
@@ -233,6 +233,18 @@ for a list of supported signals
Not all actions are supported for all resources.
Attempting to add a rule with an action not supported by a given resource will
result in error.
+.Sh LOADER TUNABLES
+Tunables can be set at the
+.Xr loader 8
+prompt, or
+.Xr loader.conf 5 .
+.Bl -tag -width indent
+.It Va kern.racct.enable: No 1
+Enable
+.Nm .
+This defaults to 1, unless
+.Cd "options RACCT_DEFAULT_TO_DISABLED"
+is set in the kernel configuration file.
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
diff --git a/usr.bin/rctl/rctl.c b/usr.bin/rctl/rctl.c
index 185788d..b534258 100644
--- a/usr.bin/rctl/rctl.c
+++ b/usr.bin/rctl/rctl.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/rctl.h>
+#include <sys/sysctl.h>
#include <assert.h>
#include <ctype.h>
#include <err.h>
@@ -305,13 +306,37 @@ print_rules(char *rules, int hflag, int nflag)
}
static void
+enosys(void)
+{
+ int error, racct_enable;
+ size_t racct_enable_len;
+
+ racct_enable_len = sizeof(racct_enable);
+ error = sysctlbyname("kern.racct.enable",
+ &racct_enable, &racct_enable_len, NULL, 0);
+
+ if (error != 0) {
+ if (errno == ENOENT)
+ errx(1, "RACCT/RCTL support not present in kernel; see rctl(8) for details");
+
+ err(1, "sysctlbyname");
+ }
+
+ if (racct_enable == 0)
+ errx(1, "RACCT/RCTL present, but disabled; enable using kern.racct.enable=1 tunable");
+}
+
+static void
add_rule(char *rule)
{
int error;
error = rctl_add_rule(rule, strlen(rule) + 1, NULL, 0);
- if (error != 0)
+ if (error != 0) {
+ if (errno == ENOSYS)
+ enosys();
err(1, "rctl_add_rule");
+ }
free(rule);
}
@@ -330,8 +355,11 @@ show_limits(char *filter, int hflag, int nflag)
error = rctl_get_limits(filter, strlen(filter) + 1, outbuf,
outbuflen);
- if (error && errno != ERANGE)
+ if (error && errno != ERANGE) {
+ if (errno == ENOSYS)
+ enosys();
err(1, "rctl_get_limits");
+ }
} while (error && errno == ERANGE);
print_rules(outbuf, hflag, nflag);
@@ -345,8 +373,11 @@ remove_rule(char *filter)
int error;
error = rctl_remove_rule(filter, strlen(filter) + 1, NULL, 0);
- if (error != 0)
+ if (error != 0) {
+ if (errno == ENOSYS)
+ enosys();
err(1, "rctl_remove_rule");
+ }
free(filter);
}
@@ -399,8 +430,11 @@ show_usage(char *filter, int hflag)
error = rctl_get_racct(filter, strlen(filter) + 1, outbuf,
outbuflen);
- if (error && errno != ERANGE)
+ if (error && errno != ERANGE) {
+ if (errno == ENOSYS)
+ enosys();
err(1, "rctl_get_racct");
+ }
} while (error && errno == ERANGE);
while ((tmp = strsep(&outbuf, ",")) != NULL) {
@@ -439,8 +473,11 @@ show_rules(char *filter, int hflag, int nflag)
err(1, "realloc");
error = rctl_get_rules(filter, filterlen, outbuf, outbuflen);
- if (error && errno != ERANGE)
+ if (error && errno != ERANGE) {
+ if (errno == ENOSYS)
+ enosys();
err(1, "rctl_get_rules");
+ }
} while (error && errno == ERANGE);
print_rules(outbuf, hflag, nflag);
OpenPOWER on IntegriCloud