From nobody Wed Dec 07 18:06:30 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NS4wl1b6yz4jRcJ; Wed, 7 Dec 2022 18:06:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NS4wl0K0qz4Lsr; Wed, 7 Dec 2022 18:06:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670436391; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sboz8TmHdCUYLy6TYkPkjGi7YP4DLa5jDdEBtGZ0I8w=; b=XB/dSVGs+CexpP2j65vCP83ISDDxI1mEZmmJUfCR6AwVc6Rkz3ONHPOMbAecxFdPmAYUuL Ueu1ijaSfQQIvloPHkEsXr/VVD22SufaXi8LLf3l7tKLikj/OrQZQP7bCq78E4djhRwYiH EuMqPDEendyhkSm4VDbusYkhm+eMKaZUIGdYX55TDYL89viQ/eBRa8Mivi1E08CRLONJv1 PhX4waDO8zJcPXHyYBEewKScdroSeqxykHIbsdoMHEPZ4+TvGH3wjudkaUYV5LQq3NzLD2 YANx0PIrQZgLFQe3PYywjjORRKNqsjY/z1/pZduSgfriBHSLIq5AXN6sqOOQDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670436391; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sboz8TmHdCUYLy6TYkPkjGi7YP4DLa5jDdEBtGZ0I8w=; b=Y68UXkk9bvnK+ol++j2gUHSXUQ5s05JnhFAetarf9b5Bx9g5eUvf9NNuOHpgqUo3Lv5Mpb tUoab1zZHrLCVh75QUlE+ThKvUNEqCCs+awrO/GyNyv1OIhC+oGDxH5SbyLa//o8+G1YI4 pukl2V3DXEn/je4qHLsH+gNT/uD1+qkf74fUW63Iqi/uIACCrMGVW+8Hi4xcKP6vo1WxF2 clY+DrAA0RSCHE6eP16jOf3M1E7iea3vdkLXZCSeaVe/keVbHLCcM1BVKeYe3gBaRQ8kJt t4qXnJo/RBPEI4EZXz+8zNgsppffFnKZOKmGbr7fYt1PDtfxmCpOyMy0id5iEw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1670436391; a=rsa-sha256; cv=none; b=yZLdZz0H5QA+N1NCbRi1vppWXOOZT2zaJsWuIRRjU2jk/XG1Lvoy6gYu7iiZzLaeBWZjTh QnwZg8LWUUdWzKUxEI1yxqDspbq4W76UYW6fX6fc8I21UJNXMgOiMbRr9EZJF4mMq3jvYV ZFhPX0IS6R33frH7I/lMvfyeXyxi/ofUv9Lu1c6kbVmUy7DQE6u3kHV9v8QjB7Z9BtY2BP HteT1VN+eMvl3s7uDKQmPzl2TXpp9L5tB91sCeR71Bo2XlPBE7My1QZukEuMLKJYGXwyAF KXcFMU2f4XmtRPu1Lml3xnlpe3TKmNQah+DfcEbdKnHVyDhj5c7lmowgYPetzQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NS4wk63THzQwK; Wed, 7 Dec 2022 18:06:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2B7I6Uer072528; Wed, 7 Dec 2022 18:06:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2B7I6USc072527; Wed, 7 Dec 2022 18:06:30 GMT (envelope-from git) Date: Wed, 7 Dec 2022 18:06:30 GMT Message-Id: <202212071806.2B7I6USc072527@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: e1ff7945e1b3 - main - stand/kboot: Parse the command line args List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e1ff7945e1b3a9af34f092d9cca72ed802671c20 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=e1ff7945e1b3a9af34f092d9cca72ed802671c20 commit e1ff7945e1b3a9af34f092d9cca72ed802671c20 Author: Warner Losh AuthorDate: 2022-12-07 17:58:44 +0000 Commit: Warner Losh CommitDate: 2022-12-07 18:00:54 +0000 stand/kboot: Parse the command line args Do the standard command line parsing... With a small twist to deal with the quirks of booting via linuxboot to the initrd from the command line in shell.efi and other observed oddities. Sponsored by: Netflix --- stand/kboot/main.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/stand/kboot/main.c b/stand/kboot/main.c index e8a9365b2c4c..2bbe14d79253 100644 --- a/stand/kboot/main.c +++ b/stand/kboot/main.c @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -75,6 +76,32 @@ kboot_getdev(void **vdev, const char *devspec, const char **path) return (devparse(dev, devspec, path)); } +static int +parse_args(int argc, const char **argv) +{ + int howto = 0; + + /* + * When run as init, sometimes argv[0] is a EFI-ESP path, other times + * it's the name of the init program, and sometimes it's a placeholder + * string, so we exclude it here. For the other args, look for DOS-like + * and Unix-like absolte paths and exclude parsing it if we find that, + * otherwise parse it as a command arg (so looking for '-X', 'foo' or + * 'foo=bar'). This is a little different than EFI where it argv[0] + * often times is the first argument passed in. There are cases when + * linux-booting via EFI that we have the EFI path we used to run + * bootXXX.efi as the arguments to init, so we need to exclude the paths + * there as well. + */ + for (int i = 1; i < argc; i++) { + if (argv[i][0] != '\\' && argv[i][0] != '/') { + howto |= boot_parse_arg(argv[i]); + } + } + + return (howto); +} + int main(int argc, const char **argv) { @@ -107,13 +134,8 @@ main(int argc, const char **argv) /* Initialize all the devices */ devinit(); - /* Choose bootdev if provided */ - if (argc > 1) - bootdev = argv[1]; - else - bootdev = ""; - if (argc > 2) - hostfs_root = argv[2]; + /* Parse the command line args -- ignoring for now the console selection */ + parse_args(argc, argv); printf("Boot device: %s with hostfs_root %s\n", bootdev, hostfs_root);