Commit Graph

97 Commits

Author SHA1 Message Date
dholland 01cef2d63e Return error on failure instead of hiding it and always returning zero.
From Henning Petersen in PR 44152.
2010-11-26 22:01:53 +00:00
stacktic 7bede9ad38 Do not return -1 on _kvm_read when all the requested data could be read (fix bin/38648) 2010-10-23 14:34:12 +00:00
jym 962a341df6 Change kvm_pa2off() and kvm_kvatop() prototypes (private to kvm(3)):
-int     _kvm_kvatop(kvm_t *, u_long, u_long *);
-off_t   _kvm_pa2off(kvm_t *, u_long);
+int     _kvm_kvatop(kvm_t *, vaddr_t, paddr_t *);
+off_t   _kvm_pa2off(kvm_t *, paddr_t);

Basically, use vaddr_t for VA and paddr_t for PA. In addition, for variables
representing addresses, use paddr_t or vaddr_t, depending on the context.

For most arches, vaddr_t and paddr_t are equivalent to unsigned long. However,
the change was needed for exotic situations, like i386 PAE, were unsigned long
is not suitable for PA which are 64 bits long. As this required a complete
change of the function prototypes, all arches had to be adapted accordingly.

Core files from before this commit should still work with the new code; I did
not see any direct dependency between core's structure and kvatop/pa2off.

The change was compile tested for all arches, as it impacts all of them.

See also:

http://mail-index.netbsd.org/current-users/2010/09/07/msg014249.html
2010-09-20 23:23:16 +00:00
apb 8a61809cf3 Move the code that tries to open _PATH_KSYMS first into a common path,
so that it is used both for the /dev/mem case and the core dump case.

Output from savecore(8) before:
    savecore - - - (null): kvm_openfiles: /netbsd: No such file or directory
and after:
    savecore - - - no core dump
2009-09-14 19:29:20 +00:00
he f9dd8b23a6 Anoter instance of <sys/exec_aout.h> -> <sys/exec.h>. 2009-08-20 11:18:55 +00:00
ad eba222df68 ... and make kvm_dump_inval() work on the raw device. 2008-01-15 14:16:30 +00:00
ad a7a2d171df Handle reading from raw disk devices. 2008-01-15 13:57:41 +00:00
joerg b9d83a2411 Fix a typo in the last change that broke a comparision. 2007-11-08 21:58:26 +00:00
joerg 6475789b74 Add kvm_dump_header and implement kvm_dump_wrtheader on top of it.
This function allows the caller finer control of how the writes happen
and doesn't force stdio as interface. Optimise clear_gap a bit to not
fill the gap byte-wise. Bump minor version of libkvm.
2007-11-08 20:48:04 +00:00
joerg 4267598f61 ANSIfy. 2007-11-08 17:32:30 +00:00
yamt 060eacec48 #include a necessary header directly, rather than via user.h. 2006-05-11 12:00:20 +00:00
christos 17c2501482 Coverity CID 881: Always print an error if allocation failed.
If the program is not specified use getprogname()
2006-03-21 23:47:51 +00:00
christos 0213791d0c 1. Eliminate some unnecessary to kvm_{m,re}alloc.
2. Don't malloc/free procbase/procbase2/lwpbase continuously. Keep track
   of the size, and only do it if necessary.
3. Write a macro to malloc/realloc and set the size of members so that it
   is done correctly. Previous open coded version in kvm_file.c always
   set the length, which is incorrect.
4. Remove bogus check against INT_MAX.
5. use NULL to initialize pointers instead of 0.
2006-02-16 20:48:42 +00:00
yamt 6cae8c8d70 as swap is now optional, ENXIO on /dev/drum is normal. 2005-07-30 16:32:29 +00:00
wiz d20841bb64 Uppercase CPU, plural is CPUs. 2004-02-13 11:36:08 +00:00
cube b9d0c518f9 When using /dev/ksyms, don't keep it open more than strictly necessary.
This allows LKM manipulation while an application using libkvm, such as
vmstat or gkrellm, is running.

Patch reviewed by Anders Magnusson.
2003-11-04 14:59:10 +00:00
agc eb7c1594f1 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22280, verified by myself.
2003-08-07 16:42:00 +00:00
ragge f08d6eb0c9 Make the kvm routines use /dev/ksyms to get the kernel namelist.
If it fails, use /netbsd instead.
2003-05-11 13:37:34 +00:00
thorpej c62a74e6d5 Merge the nathanw_sa branch. 2003-01-18 10:32:11 +00:00
itojun d8cb639e16 use strlcpy to ensure string termination 2002-11-16 23:34:30 +00:00
christos c524f280a6 Use FD_CLOEXEC instead of `1' and don't cast. 2002-09-17 21:37:13 +00:00
atatat 28f3a22acb Default using the value of machdep.booted_kernel from sysctl() if it
is available and points to a file.  The value of "/netbsd" is still
the ultimate fallback.
2002-09-17 20:34:08 +00:00
drochner ead5c05ddb another SETFL->SETFD 2002-09-17 19:50:48 +00:00
drochner 8b4aa8a489 actually do the close-on-exec 2002-09-17 19:38:26 +00:00
christos dd45b62148 Set the close-on-exec bit on all file descriptors we open. Inspired by a
FreeBSD security advisory.

Reviewed by thorpej
2002-09-16 17:20:45 +00:00
soren bdb11c55b6 Don't omit third argument to open(2).
PR lib/15752 from Stephen Ma.
2002-08-08 01:30:09 +00:00
wiz effeef0d33 __STDC__ is always defined on NetBSD. 2002-05-26 18:33:25 +00:00
wiz 9fa0b17629 Give initiali[sz]e all the "i"s it deserves. 2001-09-18 18:15:49 +00:00
msaitoh dedc9b2e09 Add forgotten initialization.
Fixed PR#11446.
2000-11-16 08:57:15 +00:00
sommerfeld f9d3ae0fbb format-string audit cleanups 2000-10-04 16:11:27 +00:00
mrg 3b8ac18da2 <vm/vm.h> -> <uvm/uvm_extern.h> 2000-06-29 06:34:22 +00:00
mrg 10a6db97ee remove redundant vm includes 2000-06-26 15:34:55 +00:00
simonb a9f690ae2a Add kvm interface to the new sysctls:
kvm_getproc2() -> sysctl(KERN_PROC2)
	kvm_getargv2() -> sysctl(KERN_PROC_ARGS, KERN_PROC_ARGV)
	kvm_getenvv2() -> sysctl(KERN_PROC_ARGS, KERN_PROC_ENV)
Add new KVM_NO_FILES flag to kvm_open*() - set up enough state to
use the above calls without having to open any kernel files.

XXX: kvm_getprocs.3 and kvm_open.3 to be updated soon.
2000-05-26 02:42:21 +00:00
simonb f68ec00b50 More trailing white space. 1999-07-02 15:28:49 +00:00
mycroft 5412e6f2c7 Nuke swap_pager.h. 1999-04-01 09:53:09 +00:00
christos cc7ffa0da4 Remove lint 1998-09-27 18:15:58 +00:00
perry a843f0f8a5 bzero->memset, bcopy->memcpy, bcmp->memcmp 1998-08-10 02:43:08 +00:00
thorpej 9aae5a60db Remove some lint. 1998-08-01 21:29:41 +00:00
mycroft 0c4d98ae35 const poisoning. 1998-07-26 17:53:10 +00:00
thorpej 5bc2ba5c36 Oops, missed a couple of pread(2) uses. 1998-06-30 20:40:44 +00:00
thorpej 55c7ea7c28 Use pread(2) and pwrite(2) rather than lseek(2)/{read,write}(2). 1998-06-30 20:29:39 +00:00
msaitoh 1666d3766d fix return value of kvm_read() and kvm_write() 1998-06-29 20:36:30 +00:00
perry 0b7831a37b remove obsolete register declarations 1998-02-03 19:12:13 +00:00
mrg 395c20ea27 clean up WARNS on the alpha. 1997-10-10 08:45:29 +00:00
mikel b4119f6b37 use <sys/cdefs.h> __RCSID() macro 1997-08-15 02:21:56 +00:00
gwr ab2c3b0106 Call _kvm_mdopen(kd) to do machine-dependent initialization. 1997-08-12 16:28:32 +00:00
thorpej 669065c879 Add missing argument to fprintf(). 1997-04-09 21:11:41 +00:00
mrg 9cd5492c02 - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
1997-01-23 14:01:45 +00:00
pk dbaf74ae49 Check return value of _kvm_initvtop(). 1996-11-09 23:44:53 +00:00
cgd e79d25e2e9 Don't use a kernel database based on the file name, use only
/var/db/kvm.db, and only use that if no kernel namelist file
is named.  Update the documentation to describe this.
1996-10-12 00:50:11 +00:00