From patchwork Sat Oct 28 19:48:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamil Rytarowski X-Patchwork-Id: 10031097 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8223E6039A for ; Sat, 28 Oct 2017 20:03:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6165D28872 for ; Sat, 28 Oct 2017 20:03:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43B9028894; Sat, 28 Oct 2017 20:03:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A1EAF28872 for ; Sat, 28 Oct 2017 20:03:04 +0000 (UTC) Received: from localhost ([::1]:33866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8XJr-0002lv-Rz for patchwork-qemu-devel@patchwork.kernel.org; Sat, 28 Oct 2017 16:02:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8XJC-0002le-03 for qemu-devel@nongnu.org; Sat, 28 Oct 2017 16:02:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8XJ8-0000rN-V4 for qemu-devel@nongnu.org; Sat, 28 Oct 2017 16:02:18 -0400 Received: from mout.gmx.net ([212.227.17.20]:63495) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e8XJ8-0000qE-Ko for qemu-devel@nongnu.org; Sat, 28 Oct 2017 16:02:14 -0400 Received: from localhost.localdomain ([185.58.161.191]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0Lq9Ma-1dUoqJ3I1Y-00dpRZ; Sat, 28 Oct 2017 22:02:11 +0200 From: Kamil Rytarowski To: qemu-devel@nongnu.org Date: Sat, 28 Oct 2017 21:48:33 +0200 Message-Id: <20171028194833.23858-1-n54@gmx.com> X-Mailer: git-send-email 2.14.3 X-Provags-ID: V03:K0:0fAOHhMXevKCn1x1koapeX/k6bMYH/FrRqUH+w+fBQsGyepf1kk rggCfFFMHM91nUwK7MYjM2dvfm5sYhoP42SAYcrUB+bNDTRYNKr4P/NWR7IvLPiPb3x9dGl 38NHKKcMaVHg9TWDuWHPYjiCoJyfiGgn0HvDshlcPZn5YasHlzyqaVDXv1JfRSHgwahuLRS uubYTZVWQeDaVPb+viiig== X-UI-Out-Filterresults: notjunk:1; V01:K0:T7TD+yI9E3g=:VTbDKJQWpPKGrVNstOnSap xKm7fEQDSHUOgAoEt1DG4rZRA6VKstutWZVJ1f26LPNGeUo3mMQazrWrjCuhEfDcMU32wnPjk tNJiJGEF5lU6aEjtLCBxoSW7zW0u/jmr7AwK5QGElSveXBcfJSuADh5ZKbYx3B3bFDBM36xqA ka+ubQmsQbxxlt6ijutdpy99OqAf+QV5MXUkdpcq4LrnpkRxGSI8TZqupp+yYm0Q3xsGOjxtL 7O0SYfCDmVAQU/EQOh2Je/LOFq9Xm1GzOTHIcROK20Pwz4PwJ/TXghBi/enBGMii4RhsC0NXD d726vnhqp+ElTMjRBCw+yhyt+nmvfqlYJjiu/Yng8KJtkQpQvgtZ1OAc+Ak6r3gcf4P1LeU5F LPPgYf/KrKVyWGaZJRg4qkQLO3eka70CSU8V0rPu78zX2kjZKNbA3qdrbS7iIXLU8qcQtZrDy L6A7Lbih8SICaBG8berQHiGZ8XHa/zYHW5KKARIl1CDID4u0TdvhiJGxQrGvhNJ3wWZLCrhNs fgfEAqVfLzcj//rJ3i1HrmR5KeWCgoAMyN+vHkwBouQYltcFFprVnB7Vi4p3JEGyfRcmzDxuL gUH5uAcFHJfiluvl6fsOUupXSlc4k94d6QZYrTq9dcVLiCe8ZvnK4doztxRpEIdcGGRxCHKb+ WdkVWK2Fsp34xgVgMFU04XeauOv8Rhq+plJFwNDWJQfzdLuV16lbp6HBA1pmQ48GtL66f27Oc xQr1qJYXL5BZkbwSCG3CJBfBvv7XyJArQkp+prgclBknFrFcGTAzFFJ2qYUG+Weju0om2yNwV yP8AJEYSFstYgqC8a2y1+RBoiZGUQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.20 Subject: [Qemu-devel] [PATCH] oslib-posix: Use sysctl(2) call to resolve exec_dir on NetBSD X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kamil Rytarowski Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- util/oslib-posix.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 382bd4a231..77369c92ce 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -49,6 +49,10 @@ #include #endif +#ifdef __NetBSD__ +#include +#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';