From owner-p4-projects@FreeBSD.ORG Sat Aug 8 09:30:41 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E62381065674; Sat, 8 Aug 2009 09:30:40 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8BBFC1065670 for ; Sat, 8 Aug 2009 09:30:40 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 7A1CA8FC0A for ; Sat, 8 Aug 2009 09:30:40 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n789UeGk091673 for ; Sat, 8 Aug 2009 09:30:40 GMT (envelope-from trasz@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n789UeI5091671 for perforce@freebsd.org; Sat, 8 Aug 2009 09:30:40 GMT (envelope-from trasz@freebsd.org) Date: Sat, 8 Aug 2009 09:30:40 GMT Message-Id: <200908080930.n789UeI5091671@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to trasz@freebsd.org using -f From: Edward Tomasz Napierala To: Perforce Change Reviews Cc: Subject: PERFORCE change 167099 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Aug 2009 09:30:42 -0000 http://perforce.freebsd.org/chv.cgi?CH=167099 Change 167099 by trasz@trasz_anger on 2009/08/08 09:30:39 Style fixes. Affected files ... .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_hrl.c#48 edit .. //depot/projects/soc2009/trasz_limits/sys/sys/hrl.h#30 edit .. //depot/projects/soc2009/trasz_limits/usr.sbin/hrl/hrl.c#23 edit Differences ... ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_hrl.c#48 (text+ko) ==== @@ -55,6 +55,9 @@ #define HRF_DONT_INHERIT 1 #define HRF_DONT_ACCUMULATE 2 +/* Default buffer size for hrl_get_rules(2). */ +#define HRL_DEFAULT_BUFSIZE 4096 + int hrl_group_accounting = 0; TUNABLE_INT("kern.hrl_group_accounting", &hrl_group_accounting); @@ -588,7 +591,7 @@ return (0); } - if (filter->hr_amount >= 0) { + if (filter->hr_amount != HRL_AMOUNT_UNDEFINED) { if (rule->hr_amount != filter->hr_amount) return (0); } @@ -725,7 +728,7 @@ rule->hr_per = HRL_SUBJECT_UNDEFINED; rule->hr_resource = HRL_RESOURCE_UNDEFINED; rule->hr_action = HRL_ACTION_UNDEFINED; - rule->hr_amount = -1; + rule->hr_amount = HRL_AMOUNT_UNDEFINED; refcount_init(&rule->hr_refcount, 1); return (rule); @@ -786,7 +789,7 @@ return (0); if (rule->hr_action == HRL_ACTION_UNDEFINED) return (0); - if (rule->hr_amount < 0) + if (rule->hr_amount == HRL_AMOUNT_UNDEFINED) return (0); if (rule->hr_per == HRL_SUBJECT_UNDEFINED) return (0); @@ -859,7 +862,7 @@ } if (amountstr == NULL || amountstr[0] == '\0') - rule->hr_amount = -1; + rule->hr_amount = HRL_AMOUNT_UNDEFINED; else { error = str2int64(amountstr, &rule->hr_amount); if (error) @@ -1285,7 +1288,7 @@ hrl_get_rules(struct thread *td, struct hrl_get_rules_args *uap) { int error; - size_t bufsize = HRL_MAX_RULES; + size_t bufsize = HRL_DEFAULT_BUFSIZE; char *inputstr, *buf; struct sbuf *sb; struct hrl_rule *filter; @@ -1354,7 +1357,7 @@ hrl_get_limits(struct thread *td, struct hrl_get_limits_args *uap) { int error; - size_t bufsize = HRL_MAX_RULES; + size_t bufsize = HRL_DEFAULT_BUFSIZE; char *inputstr, *buf; struct sbuf *sb; struct hrl_rule *filter; ==== //depot/projects/soc2009/trasz_limits/sys/sys/hrl.h#30 (text+ko) ==== @@ -48,6 +48,10 @@ * * 'hr_refcount' is equal to the number of hrl_limit structures * pointing to the rule. + * + * This structure must never change after being added, via hrl_limit + * structures, to subjects. In order to change a limit, add a new + * rule and remove the previous one. */ struct hrl_rule { int hr_subject; @@ -101,7 +105,7 @@ #define HRL_ACTION_SIGXFSZ 0x0009 #define HRL_ACTION_MAX HRL_ACTION_SIGXFSZ -#define HRL_MAX_RULES 1024 +#define HRL_AMOUNT_UNDEFINED -1 /* * 'hrl_usage' defines resource consumption for a particular @@ -138,8 +142,8 @@ void hrl_usage_subtract(struct hrl_usage *dest, const struct hrl_usage *src); void hrl_proc_exiting(struct proc *p); -void hrl_proc_loginclass_changed(struct proc *p); -void hrl_proc_ucred_changed(struct proc *p); +void hrl_proc_loginclass_changed(struct proc *p); +void hrl_proc_ucred_changed(struct proc *p); struct hrl_rule *hrl_rule_alloc(int flags); struct hrl_rule *hrl_rule_duplicate(const struct hrl_rule *rule, int flags); @@ -149,6 +153,9 @@ int hrl_rule_remove(const struct hrl_rule *filter); #else /* !_KERNEL */ +/* + * Syscall interface. + */ __BEGIN_DECLS int hrl_get_usage(const char *inbufp, size_t inbuflen, char *outbufp, size_t outbuflen); int hrl_get_rules(const char *inbufp, size_t inbuflen, char *outbufp, size_t outbuflen); ==== //depot/projects/soc2009/trasz_limits/usr.sbin/hrl/hrl.c#23 (text+ko) ==== @@ -38,7 +38,7 @@ #include #include -#define BUFLEN_DEFAULT 1024 +#define HRL_DEFAULT_BUFSIZE 4096 static id_t parse_user(const char *s) @@ -183,7 +183,7 @@ { int error; char *outbuf = NULL; - size_t outbuflen = BUFLEN_DEFAULT / 4; + size_t outbuflen = HRL_DEFAULT_BUFSIZE / 4; do { outbuflen *= 4; @@ -220,7 +220,7 @@ { int error; char *outbuf = NULL, *tmp; - size_t outbuflen = BUFLEN_DEFAULT / 4; + size_t outbuflen = HRL_DEFAULT_BUFSIZE / 4; do { outbuflen *= 4; @@ -250,7 +250,7 @@ { int error; char *outbuf = NULL; - size_t filterlen, outbuflen = BUFLEN_DEFAULT / 4; + size_t filterlen, outbuflen = HRL_DEFAULT_BUFSIZE / 4; if (filter != NULL) filterlen = strlen(filter) + 1;