Module Name:    src
Committed By:   ad
Date:           Sun Mar 29 10:58:28 UTC 2009

Modified Files:
        src/sys/kern: init_main.c
        src/sys/sys: systm.h

Log Message:
Add a cental banner() function to print the copyright and version info.


To generate a diff of this commit:
cvs rdiff -u -r1.384 -r1.385 src/sys/kern/init_main.c
cvs rdiff -u -r1.234 -r1.235 src/sys/sys/systm.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/init_main.c
diff -u src/sys/kern/init_main.c:1.384 src/sys/kern/init_main.c:1.385
--- src/sys/kern/init_main.c:1.384	Sat Mar 21 14:41:30 2009
+++ src/sys/kern/init_main.c	Sun Mar 29 10:58:28 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: init_main.c,v 1.384 2009/03/21 14:41:30 ad Exp $	*/
+/*	$NetBSD: init_main.c,v 1.385 2009/03/29 10:58:28 ad Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.384 2009/03/21 14:41:30 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.385 2009/03/29 10:58:28 ad Exp $");
 
 #include "opt_ddb.h"
 #include "opt_ipsec.h"
@@ -912,3 +912,40 @@
 	}
 	return t;
 }
+
+/*
+ * Print the system start up banner.
+ *
+ * - Print a limited banner if AB_SILENT.
+ * - Always send normal banner to the log.
+ */
+void
+banner(void)
+{
+	static char notice[] = " Notice: this software is "
+	    "protected by copyright";
+	char pbuf[80];
+	void (*pr)(const char *, ...);
+	int i;
+
+	if ((boothowto & AB_SILENT) != 0) {
+		snprintf(pbuf, sizeof(pbuf), "%s %s (%s)",
+		    ostype, osrelease, kernel_ident);
+		printf("%s", pbuf);
+		for (i = 80 - strlen(pbuf) - sizeof(notice); i != 0; i--)
+			printf(" ");
+		printf("%s\n", notice);
+		pr = aprint_normal;
+	} else {
+		pr = printf;
+	}
+
+	memset(pbuf, 0, sizeof(pbuf));
+	(*pr)("%lld physmem\n", (long long)ptoa(physmem));
+	(*pr)("%lld free\n", (long long)ptoa(uvmexp.free));
+	(*pr)("%s%s", copyright, version);
+	format_bytes(pbuf, sizeof(pbuf), ctob((uint64_t)physmem));
+	(*pr)("total memory = %s\n", pbuf);
+	format_bytes(pbuf, sizeof(pbuf), ctob((uint64_t)uvmexp.free));
+	(*pr)("avail memory = %s\n", pbuf);
+}

Index: src/sys/sys/systm.h
diff -u src/sys/sys/systm.h:1.234 src/sys/sys/systm.h:1.235
--- src/sys/sys/systm.h:1.234	Mon Feb 23 20:27:59 2009
+++ src/sys/sys/systm.h	Sun Mar 29 10:58:28 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: systm.h,v 1.234 2009/02/23 20:27:59 rmind Exp $	*/
+/*	$NetBSD: systm.h,v 1.235 2009/03/29 10:58:28 ad Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1988, 1991, 1993
@@ -216,6 +216,7 @@
 int	humanize_number(char *, size_t, uint64_t, const char *, int);
 
 void	twiddle(void);
+void	banner(void);
 #endif /* _KERNEL */
 
 void	panic(const char *, ...)

Reply via email to