From patchwork Tue Jun 16 16:10:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David CARLIER X-Patchwork-Id: 11608203 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1FC5F92A for ; Tue, 16 Jun 2020 16:11:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E9801208D5 for ; Tue, 16 Jun 2020 16:11:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E83cMfY3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E9801208D5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlEBk-00077I-7Z for patchwork-qemu-devel@patchwork.kernel.org; Tue, 16 Jun 2020 12:11:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlEB5-00064L-Di; Tue, 16 Jun 2020 12:11:11 -0400 Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]:35157) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlEB3-00056Z-J6; Tue, 16 Jun 2020 12:11:11 -0400 Received: by mail-ed1-x542.google.com with SMTP id e12so14700804eds.2; Tue, 16 Jun 2020 09:11:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=tQGTgMA17a4o6iebS1HxA6AgY6W7CBwK/BaZI98DayA=; b=E83cMfY3rnxAqY8XBmXPvAc/fvzBgSODYggbL92DfEvs+SWHT/sJEJP1IXC19cc5mX d324qLCxN8Bw8fmPlBxUeY9wvqi7TKYb/MGDCZEIcOOVN9pdE9oay0EfA0HLFumgb92d BBKtYxYEqgYq7N4PIgCFye7pzm6EIpEsl8qqY3NrQMHUZQx9BJkmZ1PWtt2zDWlepW0O RmlWaXKcVz3OIK2as1rLgwmLJ9jwNEEmhb4jbfEAyCKY8JRbJRsQmqeCXHZ5DfBswDm7 pmd2YRTCk3V0vlz6uQAKK+cbfLp4d/lVjK4+TxkYnrivf047zlWzt6AN6nDyO9HP67ZS i0Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=tQGTgMA17a4o6iebS1HxA6AgY6W7CBwK/BaZI98DayA=; b=XCW7K/JDpp/+X4ZKyyEnmS94BNXWmB+L/8qQJ+ySP5XLo6Q/aq++HI4KIlR5q5DyLM UTsmDuOALHAPMzqOK3BWYYEBhxaE/fhYXXhrm3yLZUbMl4W419bXlnia38HcABqbO+NE ruz7zigBNsXAzWp/urAz2Wn8uTcqNh4XUJYffaIzV6Th4WKhbIRh/cqu5fcTWhh09ZHb F7xlUANURqjhavcIyUiAmZPSgy5QqStqErcK5I//PFKl2wNS0KZV6X50krNZQq2kG+Wz rHjOh3cvAiaMyvYYZYeDKgxila3SraoUYFgRRKDwfCabLQoAA8ZMIlZwKmPVag+p1iCz YYqw== X-Gm-Message-State: AOAM530v5dU6AQFV7OT30syVpcf5I+8OyIlJpXc9hhqnXJG6rjO3WnEZ AbA2I9ld1D7LwDfwJTxF+xZ/hcd5sGda+Cg1PSm/GK7d49Q= X-Google-Smtp-Source: ABdhPJySHc2+PvED6EqeGjumwLlo+9qhCqZBo0PfV3LbE/jNelL7nSvuH9N72v0ShxcS0+hcscOwFfUVc2EfavjjwN4= X-Received: by 2002:aa7:da14:: with SMTP id r20mr3309742eds.7.1592323867344; Tue, 16 Jun 2020 09:11:07 -0700 (PDT) MIME-Version: 1.0 From: David CARLIER Date: Tue, 16 Jun 2020 17:10:56 +0100 Message-ID: Subject: [PATCH V4] util/oslib-posix : qemu_init_exec_dir implementation for Mac To: QEMU Trivial , qemu-devel Received-SPF: pass client-ip=2a00:1450:4864:20::542; envelope-from=devnexen@gmail.com; helo=mail-ed1-x542.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From 7eef8b803cdb0e7148fdf894d2992052695c1ff8 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Tue, 26 May 2020 21:35:27 +0100 Subject: [PATCH] util/oslib-posix : qemu_init_exec_dir implementation for Mac Using dyld API to get the full path of the current process. Signed-off-by: David Carlier --- util/oslib-posix.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 916f1be224..3612c2c80e 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -57,6 +57,10 @@ #include #endif +#ifdef __APPLE__ +#include +#endif + #include "qemu/mmap-alloc.h" #ifdef CONFIG_DEBUG_STACK_USAGE @@ -375,6 +379,16 @@ void qemu_init_exec_dir(const char *argv0) p = buf; } } +#elif defined(__APPLE__) + { + uint32_t len = sizeof(buf); + if (_NSGetExecutablePath(buf, &len) == 0) { + char fpath[PATH_MAX]; + buf[len - 1] = 0; + realpath(buf, fpath); + p = fpath; + } + } #endif /* If we don't have any way of figuring out the actual executable location then try argv[0]. */