add a function to report the name of the file kvm_open{,.files} is using.

This commit is contained in:
christos 2011-09-12 21:11:31 +00:00
parent 7638c70b09
commit b8c5a24416
5 changed files with 20 additions and 8 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.47 2011/02/14 18:27:24 matt Exp $
# $NetBSD: Makefile,v 1.48 2011/09/12 21:11:31 christos Exp $
# from: @(#)Makefile 8.1 (Berkeley) 6/4/93
USE_FORT?= yes # used primarily by setgid programs
@ -39,6 +39,7 @@ SRCS+= kvm_m68k_cmn.c kvm_sun2.c kvm_sun3.c kvm_sun3x.c
.endif
MAN= kvm.3 kvm_dump.3 kvm_geterr.3 kvm_getfiles.3 kvm_getloadavg.3 \
kvm_getkernelname.3 \
kvm_getprocs.3 kvm_nlist.3 kvm_open.3 kvm_read.3 kvm_getlwps.3
MLINKS+=kvm_getprocs.3 kvm_getargv.3 kvm_getprocs.3 kvm_getenvv.3

View File

@ -1,4 +1,4 @@
.\" $NetBSD: kvm.3,v 1.11 2003/08/07 16:44:35 agc Exp $
.\" $NetBSD: kvm.3,v 1.12 2011/09/12 21:11:32 christos Exp $
.\"
.\" Copyright (c) 1992, 1993
.\" The Regents of the University of California. All rights reserved.
@ -33,7 +33,7 @@
.\"
.\" @(#)kvm.3 8.1 (Berkeley) 6/4/93
.\"
.Dd August 18, 2002
.Dd September 14, 2011
.Dt KVM 3
.Os
.Sh NAME
@ -99,6 +99,7 @@ interface to physical memory
.Xr kvm_getargv 3 ,
.Xr kvm_getenvv 3 ,
.Xr kvm_geterr 3 ,
.Xr kvm_getkernelname 3 ,
.Xr kvm_getloadavg 3 ,
.Xr kvm_getlwps 3 ,
.Xr kvm_getprocs 3 ,

View File

@ -1,4 +1,4 @@
/* $NetBSD: kvm.c,v 1.97 2010/11/26 22:01:53 dholland Exp $ */
/* $NetBSD: kvm.c,v 1.98 2011/09/12 21:11:32 christos Exp $ */
/*-
* Copyright (c) 1989, 1992, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)kvm.c 8.2 (Berkeley) 2/13/94";
#else
__RCSID("$NetBSD: kvm.c,v 1.97 2010/11/26 22:01:53 dholland Exp $");
__RCSID("$NetBSD: kvm.c,v 1.98 2011/09/12 21:11:32 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -90,6 +90,12 @@ kvm_geterr(kvm_t *kd)
return (kd->errbuf);
}
const char *
kvm_getkernelname(kvm_t *kd)
{
return kd->kernelname;
}
/*
* Report an error using printf style arguments. "program" is kd->program
* on hard errors, and 0 on soft errors, so that under sun error emulation,
@ -336,7 +342,9 @@ _kvm_open(kvm_t *kd, const char *uf, const char *mf, const char *sf, int flag,
_kvm_syserr(kd, kd->program, "%s", uf);
goto failed;
}
strlcpy(kd->kernelname, uf, sizeof(kd->kernelname));
} else {
strlcpy(kd->kernelname, _PATH_KSYMS, sizeof(kd->kernelname));
/*
* We're here because /dev/ksyms was opened
* successfully. However, we don't want to keep it

View File

@ -1,4 +1,4 @@
.\" $NetBSD: kvm_open.3,v 1.17 2010/03/22 21:55:06 joerg Exp $
.\" $NetBSD: kvm_open.3,v 1.18 2011/09/12 21:11:32 christos Exp $
.\"
.\" Copyright (c) 1992, 1993
.\" The Regents of the University of California. All rights reserved.
@ -33,7 +33,7 @@
.\"
.\" @(#)kvm_open.3 8.3 (Berkeley) 4/19/94
.\"
.Dd September 14, 2009
.Dd September 14, 2011
.Dt KVM_OPEN 3
.Os
.Sh NAME
@ -224,6 +224,7 @@ function returns 0 on success and -1 on failure.
.Xr kvm_getargv 3 ,
.Xr kvm_getenvv 3 ,
.Xr kvm_geterr 3 ,
.Xr kvm_getkernelname 3 ,
.Xr kvm_getprocs 3 ,
.Xr kvm_nlist 3 ,
.Xr kvm_read 3 ,

View File

@ -1,4 +1,4 @@
/* $NetBSD: kvm_private.h,v 1.19 2010/09/26 22:28:05 jym Exp $ */
/* $NetBSD: kvm_private.h,v 1.20 2011/09/12 21:11:32 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -90,6 +90,7 @@ struct __kvm {
size_t fdalign;
uint8_t *iobuf;
size_t iobufsz;
char kernelname[MAXPATHLEN];
};
/* Levels of aliveness */