git: libkvm: Make return value of kvm_getfiles(3) consistent.

Sepherosa Ziehau sephe at
Wed Oct 14 05:10:19 PDT 2015

commit 0db87cb783123272bb50d1e8e94e4dbd1a35b998
Author: Sepherosa Ziehau <sephe at>
Date:   Wed Oct 14 19:56:05 2015 +0800

    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.

Summary of changes:
 lib/libkvm/kvm.h                  |   4 +-
 lib/libkvm/kvm_file.c             | 244 ++++++++++++++++++++++++++------------
 lib/libkvm/kvm_getfiles.3         |   7 +-
 test/kvm/kvm_file/Makefile        |   7 ++
 test/kvm/kvm_file/test_kvm_file.c |  96 +++++++++++++++
 5 files changed, 277 insertions(+), 81 deletions(-)
 create mode 100644 test/kvm/kvm_file/Makefile
 create mode 100644 test/kvm/kvm_file/test_kvm_file.c

DragonFly BSD source repository

More information about the Commits mailing list