diff options
Diffstat (limited to 'usr.bin/rctl')
-rw-r--r-- | usr.bin/rctl/Makefile | 3 | ||||
-rw-r--r-- | usr.bin/rctl/rctl.8 | 12 | ||||
-rw-r--r-- | usr.bin/rctl/rctl.c | 47 |
3 files changed, 55 insertions, 7 deletions
diff --git a/usr.bin/rctl/Makefile b/usr.bin/rctl/Makefile index c5c32eba52eb..0191bdd811c3 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 3f72b9122171..fe147562b7d0 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 185788d09756..b5342583958d 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); |