Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add getbootfile(3) to libutil, and a man page.
details: https://anonhg.NetBSD.org/src/rev/c208ee41d89f
branches: trunk
changeset: 508134:c208ee41d89f
user: wiz <wiz%NetBSD.org@localhost>
date: Fri Apr 06 14:31:14 2001 +0000
description:
Add getbootfile(3) to libutil, and a man page.
Bump libutil version to 5.5.
diffstat:
distrib/sets/lists/base/shl.mi | 4 +-
lib/libutil/Makefile | 6 +-
lib/libutil/getbootfile.3 | 66 +++++++++++++++++++++++++++++++
lib/libutil/getbootfile.c | 89 ++++++++++++++++++++++++++++++++++++++++++
lib/libutil/shlib_version | 4 +-
5 files changed, 162 insertions(+), 7 deletions(-)
diffs (214 lines):
diff -r b6beb7fae329 -r c208ee41d89f distrib/sets/lists/base/shl.mi
--- a/distrib/sets/lists/base/shl.mi Fri Apr 06 14:18:56 2001 +0000
+++ b/distrib/sets/lists/base/shl.mi Fri Apr 06 14:31:14 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.131 2001/04/02 16:49:43 tshiozak Exp $
+# $NetBSD: shl.mi,v 1.132 2001/04/06 14:31:15 wiz Exp $
# Note: libtermcap and libtermlib are hardlinked and share the same version.
./usr/lib/libamu.so.2.0 base-amd-shlib
./usr/lib/libasn1.so.4.0 base-krb5-shlib
@@ -44,7 +44,7 @@
./usr/lib/libtermcap.so.0.4 base-sys-shlib
./usr/lib/libtermlib.so.0.4 base-sys-shlib
./usr/lib/libusb.so.0.1 base-sys-shlib
-./usr/lib/libutil.so.5.4 base-sys-shlib
+./usr/lib/libutil.so.5.5 base-sys-shlib
./usr/lib/libwrap.so.0.2 base-net-shlib
./usr/lib/libz.so.0.2 base-sys-shlib
./usr/lib/runemodule/libBIG5.so.3.0 base-rune-lib
diff -r b6beb7fae329 -r c208ee41d89f lib/libutil/Makefile
--- a/lib/libutil/Makefile Fri Apr 06 14:18:56 2001 +0000
+++ b/lib/libutil/Makefile Fri Apr 06 14:31:14 2001 +0000
@@ -1,14 +1,14 @@
-# $NetBSD: Makefile,v 1.28 2000/12/06 13:37:53 tron Exp $
+# $NetBSD: Makefile,v 1.29 2001/04/06 14:31:14 wiz Exp $
# @(#)Makefile 8.1 (Berkeley) 6/4/93
LIB= util
CPPFLAGS+=-DLIBC_SCCS
-SRCS= fparseln.c getmaxpartitions.c getrawpartition.c \
+SRCS= fparseln.c getbootfile.c getmaxpartitions.c getrawpartition.c \
login.c login_cap.c login_tty.c \
logout.c logwtmp.c opendisk.c passwd.c pw_scan.c pidfile.c pidlock.c \
pty.c securepath.c ttyaction.c ttymsg.c
-MAN= fparseln.3 getmaxpartitions.3 getrawpartition.3 \
+MAN= fparseln.3 getbootfile.3 getmaxpartitions.3 getrawpartition.3 \
login.3 login_cap.3 opendisk.3 \
openpty.3 pidfile.3 pidlock.3 pw_getconf.3 pw_init.3 pw_lock.3 \
secure_path.3 ttyaction.3 ttymsg.3
diff -r b6beb7fae329 -r c208ee41d89f lib/libutil/getbootfile.3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libutil/getbootfile.3 Fri Apr 06 14:31:14 2001 +0000
@@ -0,0 +1,66 @@
+.\" $NetBSD: getbootfile.3,v 1.1 2001/04/06 14:31:14 wiz Exp $
+.\"
+.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Thomas Klausner.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the NetBSD
+.\" Foundation, Inc. and its contributors.
+.\" 4. Neither the name of The NetBSD Foundation nor the names of its
+.\" contributors may be used to endorse or promote products derived
+.\" from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd April 6, 2001
+.Dt GETBOOTFILE 3
+.Os
+.Sh NAME
+.Nm getbootfile
+.Nd get the name of the booted kernel file
+.Sh LIBRARY
+.Lb libutil
+.Sh SYNOPSIS
+.Fd #include <util.h>
+.Ft const char *
+.Fn getbootfile void
+.Sh DESCRIPTION
+.Fn getbootfile
+returns a static pointer to the full path name of the file from which
+the current kernel was loaded. If it can not be determined, or the
+file is not ``secure'' (see
+.Xr secure_path 3 ) ,
+.Dv _PATH_UNIX
+from
+.Pa Aq paths.h
+is returned instead.
+.Sh SEE ALSO
+.Xr secure_path 3 ,
+.Xr sysctl 3
+.Sh HISTORY
+The
+.Nm
+function call appeared in
+.Fx 2.0 .
diff -r b6beb7fae329 -r c208ee41d89f lib/libutil/getbootfile.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libutil/getbootfile.c Fri Apr 06 14:31:14 2001 +0000
@@ -0,0 +1,89 @@
+/* $NetBSD: getbootfile.c,v 1.1 2001/04/06 14:31:14 wiz Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Thomas Klausner.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: getbootfile.c,v 1.1 2001/04/06 14:31:14 wiz Exp $");
+#endif
+
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <machine/cpu.h>
+#include <paths.h>
+#include <util.h>
+
+#ifdef CPU_BOOTED_KERNEL
+static char name[MAXPATHLEN];
+#endif
+
+const char *
+getbootfile(void)
+{
+#ifdef CPU_BOOTED_KERNEL
+ int mib[2];
+ size_t size;
+#endif
+ const char *kernel;
+
+ kernel = _PATH_UNIX;
+#ifdef CPU_BOOTED_KERNEL
+ /* find real boot-kernel name */
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_BOOTED_KERNEL;
+ size = sizeof(name) - 1;
+ if (sysctl(mib, 2, name + 1, &size, NULL, NULL) == 0) {
+ /*
+ * traditionally, this sysctl returns the relative
+ * path of the kernel with the leading slash stripped
+ * -- could be empty, though (e.g. when netbooting).
+ */
+ if (name[1] != '\0') {
+ name[0] = '/';
+ kernel = name;
+ }
+
+ /* check if we got a valid and 'secure' filename */
+ if (secure_path(kernel) != 0) {
+ /* doesn't seems so, fall back to default */
+ kernel = _PATH_UNIX;
+ }
+ }
+#endif
+
+ return (kernel);
+}
diff -r b6beb7fae329 -r c208ee41d89f lib/libutil/shlib_version
--- a/lib/libutil/shlib_version Fri Apr 06 14:18:56 2001 +0000
+++ b/lib/libutil/shlib_version Fri Apr 06 14:31:14 2001 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: shlib_version,v 1.22 2000/12/06 13:37:53 tron Exp $
+# $NetBSD: shlib_version,v 1.23 2001/04/06 14:31:14 wiz Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
major=5
-minor=4
+minor=5
Home |
Main Index |
Thread Index |
Old Index