PERFORCE change 163154 for review

Edward Tomasz Napierala trasz at FreeBSD.org
Sun May 31 09:30:26 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=163154

Change 163154 by trasz at trasz_victim on 2009/05/31 09:29:42

	Fix build, ad 'per' parameter and cosmetical fixes.

Affected files ...

.. //depot/projects/soc2009/trasz_limits/sys/sys/hrl.h#2 edit
.. //depot/projects/soc2009/trasz_limits/usr.sbin/hrl/Makefile#2 edit
.. //depot/projects/soc2009/trasz_limits/usr.sbin/hrl/hrl.c#2 edit

Differences ...

==== //depot/projects/soc2009/trasz_limits/sys/sys/hrl.h#2 (text+ko) ====

@@ -49,15 +49,13 @@
 #define	HRL_SUBJECT_PROCESS	0x0001
 #define	HRL_SUBJECT_USER	0x0002
 #define	HRL_SUBJECT_GROUP	0x0003
-#define	HRL_SUBJECT_JAIL	0x0004
+#define	HRL_SUBJECT_LOGINCLASS	0x0004
+#define	HRL_SUBJECT_JAIL	0x0005
 #define	HRL_SUBJECT_MAX		HRL_SUBJECT_JAIL
 
-#define	HRL_PER_UNDEFINED	0x0000
-#define	HRL_PER_PROCESS		0x0001
-#define	HRL_PER_USER		0x0002
-#define	HRL_PER_GROUP		0x0003
-#define	HRL_PER_JAIL		0x0004
-#define	HRL_PER_MAX		HRL_PER_JAIL
+/*
+ * 'hl_per' takes the same flags as 'hl_subject'.
+ */
 
 #define	HRL_OBJECT_UNDEFINED	0x0000
 #define	HRL_OBJECT_CPUTIME	0x0001

==== //depot/projects/soc2009/trasz_limits/usr.sbin/hrl/Makefile#2 (text+ko) ====

@@ -1,6 +1,7 @@
 # $FreeBSD$
 
 PROG=   hrl
+MAN=
 
 WARNS?=	6
 

==== //depot/projects/soc2009/trasz_limits/usr.sbin/hrl/hrl.c#2 (text+ko) ====

@@ -46,6 +46,9 @@
 	case HRL_SUBJECT_GROUP:
 		printf("group:%u", (unsigned int)id);
 		break;
+	case HRL_SUBJECT_LOGINCLASS:
+		printf("class:%u", (unsigned int)id);
+		break;
 	case HRL_SUBJECT_JAIL:
 		printf("jail:%u", (unsigned int)id);
 		break;
@@ -135,6 +138,32 @@
 	}
 }
 
+static void
+print_per(int per)
+{
+
+	switch (per) {
+	case HRL_SUBJECT_PROCESS:
+		printf("process");
+		break;
+	case HRL_SUBJECT_USER:
+		printf("user");
+		break;
+	case HRL_SUBJECT_GROUP:
+		printf("group");
+		break;
+	case HRL_SUBJECT_LOGINCLASS:
+		printf("class");
+		break;
+	case HRL_SUBJECT_JAIL:
+		printf("jail");
+		break;
+	default:
+		printf("undefined<0x%x>", per);
+		break;
+	}
+}
+
 int
 main(int argc __unused, char **argv __unused)
 {
@@ -145,6 +174,11 @@
 	if (error)
 		err(1, "hrl_get");
 
+	if (nentries == 0) {
+		printf("No resource limits defined.\n");
+		return (0);
+	}
+
 	limits = malloc(sizeof(struct hrl_limit) * nentries);
 	if (limits == NULL)
 		err(1, "malloc");
@@ -153,6 +187,8 @@
 	if (error)
 		err(1, "hrl_get");
 
+	printf("Defined resource limits:\n");
+
 	for (i = 0; i < nentries; i++) {
 		print_subject(limits[i]->hl_subject, limits[i]->hl_subject_id);
 		printf(":");
@@ -160,7 +196,12 @@
 		printf(":");
 		print_action(limits[i]->hl_action);
 		printf(":");
-		printf("%jd\n", limits[i]->hl_amount);
+		printf("%jd", limits[i]->hl_amount);
+		if (limits[i]->hl_subject != limits[i]->hl_per) {
+			printf("/");
+			print_per(limits[i]->hl_per);
+		}
+		printf("\n");
 	}
 
 	return (0);


More information about the p4-projects mailing list