diff options
author | Kamil Rytarowski <n54@gmx.com> | 2017-10-28 21:48:33 +0200 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2017-11-02 16:19:34 +0000 |
commit | 094611b426b3b532a3ec72256cb4e958149269d3 (patch) | |
tree | c0d235ad0e5cbd7fc02523665ab8ebae3cd03583 /util/oslib-posix.c | |
parent | fa73e146250181852c0915aa65df8d54d35485fa (diff) | |
download | qemu-094611b426b3b532a3ec72256cb4e958149269d3.zip qemu-094611b426b3b532a3ec72256cb4e958149269d3.tar.gz qemu-094611b426b3b532a3ec72256cb4e958149269d3.tar.bz2 |
oslib-posix: Use sysctl(2) call to resolve exec_dir on NetBSD
NetBSD 8.0(beta) ships with KERN_PROC_PATHNAME in sysctl(2).
Older NetBSD versions can use argv[0] parsing fallback.
This code section is partly shared with FreeBSD.
Signed-off-by: Kamil Rytarowski <n54@gmx.com>
Message-id: 20171028194833.23858-1-n54@gmx.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'util/oslib-posix.c')
-rw-r--r-- | util/oslib-posix.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 382bd4a..77369c9 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -49,6 +49,10 @@ #include <libutil.h> #endif +#ifdef __NetBSD__ +#include <sys/sysctl.h> +#endif + #include "qemu/mmap-alloc.h" #ifdef CONFIG_DEBUG_STACK_USAGE @@ -250,9 +254,14 @@ void qemu_init_exec_dir(const char *argv0) p = buf; } } -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) \ + || (defined(__NetBSD__) && defined(KERN_PROC_PATHNAME)) { +#if defined(__FreeBSD__) static int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; +#else + static int mib[4] = {CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME}; +#endif size_t len = sizeof(buf) - 1; *buf = '\0'; |