Add getbootfile(3) to libutil, and a man page.

Bump libutil version to 5.5.
This commit is contained in:
wiz 2001-04-06 14:31:14 +00:00
parent d599e51cc7
commit b1593d9814
5 changed files with 162 additions and 7 deletions

View File

@ -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. # Note: libtermcap and libtermlib are hardlinked and share the same version.
./usr/lib/libamu.so.2.0 base-amd-shlib ./usr/lib/libamu.so.2.0 base-amd-shlib
./usr/lib/libasn1.so.4.0 base-krb5-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/libtermcap.so.0.4 base-sys-shlib
./usr/lib/libtermlib.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/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/libwrap.so.0.2 base-net-shlib
./usr/lib/libz.so.0.2 base-sys-shlib ./usr/lib/libz.so.0.2 base-sys-shlib
./usr/lib/runemodule/libBIG5.so.3.0 base-rune-lib ./usr/lib/runemodule/libBIG5.so.3.0 base-rune-lib

View File

@ -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 # @(#)Makefile 8.1 (Berkeley) 6/4/93
LIB= util LIB= util
CPPFLAGS+=-DLIBC_SCCS 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 \ login.c login_cap.c login_tty.c \
logout.c logwtmp.c opendisk.c passwd.c pw_scan.c pidfile.c pidlock.c \ logout.c logwtmp.c opendisk.c passwd.c pw_scan.c pidfile.c pidlock.c \
pty.c securepath.c ttyaction.c ttymsg.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 \ login.3 login_cap.3 opendisk.3 \
openpty.3 pidfile.3 pidlock.3 pw_getconf.3 pw_init.3 pw_lock.3 \ openpty.3 pidfile.3 pidlock.3 pw_getconf.3 pw_init.3 pw_lock.3 \
secure_path.3 ttyaction.3 ttymsg.3 secure_path.3 ttyaction.3 ttymsg.3

66
lib/libutil/getbootfile.3 Normal file
View File

@ -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 .

89
lib/libutil/getbootfile.c Normal file
View File

@ -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);
}

View File

@ -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 # Remember to update distrib/sets/lists/base/shl.* when changing
# #
major=5 major=5
minor=4 minor=5