Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 Aug 2009 09:30:40 GMT
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 167099 for review
Message-ID:  <200908080930.n789UeI5091671@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <string.h>
 #include <sys/hrl.h>
 
-#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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908080930.n789UeI5091671>