From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6D41C433EF for ; Tue, 7 Sep 2021 22:19:22 +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 6DFA361101 for ; Tue, 7 Sep 2021 22:19:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6DFA361101 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bsdimp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:42238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNjR3-0004yl-Lb for qemu-devel@archiver.kernel.org; Tue, 07 Sep 2021 18:19:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNj2n-0006a2-UY for qemu-devel@nongnu.org; Tue, 07 Sep 2021 17:54:17 -0400 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]:44834) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mNj2m-0001Ba-4a for qemu-devel@nongnu.org; Tue, 07 Sep 2021 17:54:17 -0400 Received: by mail-io1-xd2f.google.com with SMTP id g9so438703ioq.11 for ; Tue, 07 Sep 2021 14:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gZ1GIZjdhmw+PtxEgB45jDBjSRzqt+uOkvQ7QNISVeo=; b=e8ypGLfx3d253MFW0CzmQW+X645TF7Ab/A1Qrl7A6FVJ6WjKSkOcrlJi/iKuF+8hOX DRlK2ftFskSntezJsoH3kfjLlIvc1ZyENFZQP7huv1LBdA8k9DzPN0wVXPTAvWpTuBvq XD+9xl5otRRdkyw4FUfvd140sO1Q81skFlHi32DjEz5KsxUPGhNBoPKL3lueIh347aNU fL7ilYI0Iy3CN5hLA5Z/SaU/V9bwd6UvNsBImaQ/mm2SdQGPk8MrRBo4T6ktbAqE9eNH C/kEe12mrYxLQ2i93dxeNF3PfDTI1tHJGcFW4ZlscUi4WMZThFHR8KxQNBST+idcJiP1 /o6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gZ1GIZjdhmw+PtxEgB45jDBjSRzqt+uOkvQ7QNISVeo=; b=tj/RotregVnanyS0lVMkBYMfQKs220ci4vnqim0eOFZR7OGng6dZ9Izpb4ZHjwStY4 iyK4yrFJR1uRDX+FRhor2BDnuqk5IXtewDuxsIuGtBZLvsDG/h+AfMUIOw5d7RMdAhLA jw298WahLlqVuuZe3cpujmjzjPFuFvopfRr21jH8Rj7rqrML0vI+5t6+lKw57V1VCVgu aQZiwOXxDTOJVb0nodl5MpgvvDJGPWhnBE/wb4ifFDjdR/BmiF9nTHCdFZ+gFBKE5uQs CJ1AKjC3zb5XPAdLriuoGClai+/uhkwXdrM52RAN18DrLk76IEOGkHBRTh1XMwtHjYP3 Gamw== X-Gm-Message-State: AOAM533dwBisJ7uSMZddmZ2gJWHvjVEz5Z0p1LCMJbTLpTFgO7bzJKKe 4WcLYySghTvgQAW4xzq53wjZMDusPeBAU/aVQ8U= X-Google-Smtp-Source: ABdhPJwTdr/8ffZ9Qawgbngx+xw13yNU4mSJzdZuiigqtmDFA8uNA3ugj5JyGZf7GHh+aas328j01w== X-Received: by 2002:a05:6638:381e:: with SMTP id i30mr453640jav.9.1631051654850; Tue, 07 Sep 2021 14:54:14 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id t17sm192477iln.24.2021.09.07.14.54.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 14:54:14 -0700 (PDT) From: imp@bsdimp.com To: qemu-devel@nongnu.org Subject: [PULL 41/42] bsd-user: Add '-0 argv0' option to bsd-user/main.c Date: Tue, 7 Sep 2021 15:53:31 -0600 Message-Id: <20210907215332.30737-42-imp@bsdimp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210907215332.30737-1-imp@bsdimp.com> References: <20210907215332.30737-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: none client-ip=2607:f8b0:4864:20::d2f; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no 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: , Cc: kevans@freebsd.org, Colin Percival , Richard Henderson , Warner Losh Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Colin Percival Previously it was impossible to emulate a program with a file name different from its argv[0]. With this change, you can run qemu -0 fakename realname args which runs the program "realname" with an argv of "fakename args". Signed-off-by: Colin Percival Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bsd-user/main.c b/bsd-user/main.c index 659dd2b512..6df4f4f011 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -243,6 +243,7 @@ int main(int argc, char **argv) char **target_environ, **wrk; envlist_t *envlist = NULL; bsd_type = HOST_DEFAULT_BSD_TYPE; + char *argv0 = NULL; adjust_ssize(); @@ -367,6 +368,8 @@ int main(int argc, char **argv) do_strace = 1; } else if (!strcmp(r, "trace")) { trace_opt_parse(optarg); + } else if (!strcmp(r, "0")) { + argv0 = argv[optind++]; } else { usage(); } @@ -390,6 +393,9 @@ int main(int argc, char **argv) usage(); } filename = argv[optind]; + if (argv0) { + argv[optind] = argv0; + } if (!trace_init_backends()) { exit(1); -- 2.32.0