libkvm: Make return value of kvm_getfiles(3) consistent.
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 14 Oct 2015 11:56:05 +0000 (19:56 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 14 Oct 2015 12:10:08 +0000 (20:10 +0800)
commit0db87cb783123272bb50d1e8e94e4dbd1a35b998
tree08cd1c5a80d9bcd61768edeee6651f4aab7fc58f
parent141605ed78f5928392143b35aa1d6ac04e76dc90
libkvm: Make return value of kvm_getfiles(3) consistent.

The return value was inconsistent if this function is called on
coredump and on live kernel:
- The leading filehead will trash return value if it is called on
  live kernel.
- Live kernel returns an array of kinfo_file but coredump returns
  an array of file.

It probably only worked when KERN_FILE sysctl returned an array
of files and when the filehead was just a file ptr; or it never
worked (it reversed nfiles' and filehead's kernel address when
reading from coredump).

We now let it return an array of kinfo_file without any weird
leading stuffs.

While I'm here clean it up a little bit (mainly use NULL instead
of 0).

This also paves the way to split filehead.
lib/libkvm/kvm.h
lib/libkvm/kvm_file.c
lib/libkvm/kvm_getfiles.3
test/kvm/kvm_file/Makefile [new file with mode: 0644]
test/kvm/kvm_file/test_kvm_file.c [new file with mode: 0644]