From patchwork Thu Sep 25 17:47:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 424 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758822534; bh=5Z9JRY20QvfzUBQ1lO9j07d1GLQ293yaS8pFpzowMxE=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=pbzuKFvLF7NDSYFk+xal9eJqTmsqltl4XyzrQBKvF6tx92OACfP5jsn7qRD26mFVZ 7g73mVmPeadMTpx5C+09v6+2A5u3J3wck0fXkpf0OsCs1ZwwFcwL+iShpZqciHbEeb svep1n2vYZYaJMDruI+cC9Bfek8EJcbBVb+3Gm8R2Y1AumOkuo7185dgc/jgJzO0F0 0y5hx3qJybxGRN4xAqf/dDSPby5OaE/lyyJV3l5zkt2RDmsexVPMku7Zgr1m2s2muN 4bd6rk/0AAk5CJdAJ2XchpZI05CQw3ZLdLybQjb+GubaQfWXikgWL52bGNwPuuZAMO UoTmPCd4MtZ6w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EA3C367D93 for ; Thu, 25 Sep 2025 11:48:54 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id YajZ1pmNl15d for ; Thu, 25 Sep 2025 11:48:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758822534; bh=5Z9JRY20QvfzUBQ1lO9j07d1GLQ293yaS8pFpzowMxE=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=pbzuKFvLF7NDSYFk+xal9eJqTmsqltl4XyzrQBKvF6tx92OACfP5jsn7qRD26mFVZ 7g73mVmPeadMTpx5C+09v6+2A5u3J3wck0fXkpf0OsCs1ZwwFcwL+iShpZqciHbEeb svep1n2vYZYaJMDruI+cC9Bfek8EJcbBVb+3Gm8R2Y1AumOkuo7185dgc/jgJzO0F0 0y5hx3qJybxGRN4xAqf/dDSPby5OaE/lyyJV3l5zkt2RDmsexVPMku7Zgr1m2s2muN 4bd6rk/0AAk5CJdAJ2XchpZI05CQw3ZLdLybQjb+GubaQfWXikgWL52bGNwPuuZAMO UoTmPCd4MtZ6w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D8EA167CAC for ; Thu, 25 Sep 2025 11:48:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758822532; bh=IAQljyEwU8Fxw47UU2JUAqt+w+mjoRYlEFeuyF5SP1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tvMN5n5Y6glp50AIUyBp+lyiFp1SOhtFaqFukNwjg8+J7Z0FmpLZL9SLMkrq8T1W+ Kono+00ouwewKMvvIn3fA8YHKXdlrjiOlNd77mNbbgGAyefwXjj1RYM+PDyP5g2EF2 0y57cMiDAVJFT5ZykQLKAXIwnjhRPjJ3RAMzTXNFD2FXZHDu6invyAd374hVLBg4V5 qVErMtG/2iIagU0cdu5QjehMuTfsX9YD3FMuNMc1Ha2BejFe+RZf0R4w8z9PVdsg2J MD32YfsPy6lFupxP0CLwQbm6S3O9Sd02THMtO/SfOFtOONKA4kr589TXT6qziixYS5 wdALHr+BPmgRQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E251867CA2; Thu, 25 Sep 2025 11:48:52 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 8DOTim-kQhYI; Thu, 25 Sep 2025 11:48:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758822529; bh=T9wQ8bvqeFxx9qnlb78NqKu6N4VvEZQiSRiJVyNLftw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Iy75ZCLhz1mE8M9vgeDsoNf3jUVQ3UKyWlbWVpU5JjXsT0MlwvhVXSH3jZOaQAB0k PIuv31Xc0lX9lHuItrqI0qQBolTcTI85y7tM6L2NfCim4mFHx5VguGSlrFUHFbTEwp iyeScTBfO7E1ehcMdl9btF7avW6b22eOBstTWHRO6ySfnK4eoZWH3AQJ3PiO00FmOp rGyTz1Gc/ILpMS7lFLruhpglZofUmwsqq+D+2IGZ8Qi/TPvPtKE/x8qQWVy2nufrIP IF8lEYSdQ6K5/xf2gzxEV7YGp7vSxHvdvsE4GpceC7j+XRAe+9sVDlrhRTuY3NanB6 S/DhPggkujI5Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id DD2D667CEF; Thu, 25 Sep 2025 11:48:48 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 25 Sep 2025 11:47:36 -0600 Message-ID: <20250925174753.3429102-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250925174753.3429102-1-sjg@u-boot.org> References: <20250925174753.3429102-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: U3ZHY64WYKE6KSKA45YA7XHZY3DNREHM X-Message-ID-Hash: U3ZHY64WYKE6KSKA45YA7XHZY3DNREHM X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/22] doc: test: Add docs and test for part_find List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add some documentation and a test for this new command. Signed-off-by: Simon Glass --- doc/usage/cmd/part_find.rst | 119 ++++++++++++++++++++++++++++++++++++ doc/usage/index.rst | 1 + test/cmd/Makefile | 1 + test/cmd/part_find.c | 42 +++++++++++++ 4 files changed, 163 insertions(+) create mode 100644 doc/usage/cmd/part_find.rst create mode 100644 test/cmd/part_find.c diff --git a/doc/usage/cmd/part_find.rst b/doc/usage/cmd/part_find.rst new file mode 100644 index 00000000000..fd5bd6578d5 --- /dev/null +++ b/doc/usage/cmd/part_find.rst @@ -0,0 +1,119 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +.. index:: + single: part_find (command) + +part_find command +================= + +Synopsis +-------- + +:: + + part_find + part_find self + +Description +----------- + +The `part_find` command is used to find a partition with a given type GUID. When +it finds one, it sets the target_part environment variable to the corresponding +``interface dev:part`` string. + +uuid + Universally Unique Identifier (UUID) to search, expressed as a string + +self + This is only permitted in the EFI app. It indicates that the required + partition is the one from which the app was started. + +Example +------- + +This shows searching for an EFI system partition and looking at the files on +that partition:: + + => host bind 1 mmc5.img + => part list host 0 + + Partition Map for host device 0 -- Partition Type: EFI + + Part Start LBA End LBA Name + Attributes + Type GUID + Partition GUID + 1 0x0000202f 0x0000282e "" + attrs: 0x0000000000000000 + type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 + (data) + guid: 6b1e51e3-427c-9f45-a947-e467b7216356 + 2 0x0000002d 0x0000082c "" + attrs: 0x0000000000000000 + type: fe3a2a5d-4f32-41a7-b725-accc3285a309 + (cros-kern) + guid: dece619f-4876-e140-a6c9-8c208a0c9099 + 3 0x0000202e 0x0000202e "" + attrs: 0x0000000000000000 + type: 3cb8e202-3b7e-47dd-8a3c-7ff2a13cfcec + (cros-root) + guid: 078cee87-a195-ae4c-a974-8ba3a3d783b3 + 4 0x0000082d 0x0000102c "" + attrs: 0x0000000000000000 + type: fe3a2a5d-4f32-41a7-b725-accc3285a309 + (cros-kern) + guid: 08d2f20f-d941-fc43-96f6-948931289d71 + 5 0x0000202d 0x0000202d "" + attrs: 0x0000000000000000 + type: 3cb8e202-3b7e-47dd-8a3c-7ff2a13cfcec + (cros-root) + guid: 0b23ba00-a11c-ed4e-8b49-5e8738899569 + 6 0x00000029 0x00000029 "" + attrs: 0x0000000000000000 + type: fe3a2a5d-4f32-41a7-b725-accc3285a309 + (cros-kern) + guid: 6d8158a8-f82d-0d4d-8983-a3ada4eb9b73 + 7 0x0000002a 0x0000002a "" + attrs: 0x0000000000000000 + type: 3cb8e202-3b7e-47dd-8a3c-7ff2a13cfcec + (cros-root) + guid: 76e8f9b0-7db7-3844-8f18-21de93485211 + 8 0x0000102d 0x0000182c "" + attrs: 0x0000000000000000 + type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 + (data) + guid: 071dfd2d-173c-f64b-9474-3318665e1d24 + 9 0x0000002b 0x0000002b "" + attrs: 0x0000000000000000 + type: 2e0a753d-9e48-43b0-8337-b15192cb1b5e + (cros-rsrv) + guid: b9d078c3-bafa-cd48-b771-a0aaa18d5008 + 10 0x0000002c 0x0000002c "" + attrs: 0x0000000000000000 + type: 2e0a753d-9e48-43b0-8337-b15192cb1b5e + (cros-rsrv) + guid: 7b0c0234-1a29-0c4f-bceb-40fae8f7b27c + 11 0x00000028 0x00000028 "" + attrs: 0x0000000000000000 + type: cab6e88e-abf3-4102-a07a-d4bb9be3c1d3 + (cros-fw) + guid: aced715d-cd1f-394a-9e3e-24b54a7b1472 + 12 0x0000182d 0x0000202c "" + attrs: 0x0000000000000000 + type: c12a7328-f81f-11d2-ba4b-00a0c93ec93b + (system) + guid: e1672afd-75ee-d74e-be95-8726b12b5e74 + => part_find c12a7328-f81f-11d2-ba4b-00a0c93ec93b + => print target_part + target_part=host 0:c + => ls $target_part + EFI/ + + 0 file(s), 1 dir(s) + + +Return value +------------ + +The return value $? is set to 0 (true) if the command succeeds. If no partition +could be found, the return value $? is set to 1 (false). diff --git a/doc/usage/index.rst b/doc/usage/index.rst index eeda632b1a0..4d6b2f5227a 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -100,6 +100,7 @@ Shell commands cmd/mv cmd/panic cmd/part + cmd/part_find cmd/pause cmd/pinmux cmd/printenv diff --git a/test/cmd/Makefile b/test/cmd/Makefile index 5fe6ac7bb3e..773b3d7569b 100644 --- a/test/cmd/Makefile +++ b/test/cmd/Makefile @@ -28,6 +28,7 @@ obj-$(CONFIG_CMD_MEMINFO) += meminfo.o endif obj-$(CONFIG_CMD_MEMORY) += mem_copy.o obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o +obj-$(CONFIG_CMD_PART_FIND) += part_find.o ifdef CONFIG_CMD_PCI obj-$(CONFIG_CMD_PCI_MPS) += pci_mps.o endif diff --git a/test/cmd/part_find.c b/test/cmd/part_find.c new file mode 100644 index 00000000000..1663d4a654f --- /dev/null +++ b/test/cmd/part_find.c @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test for 'part_find' command + * + * Copyright 2024 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include +#include + +/* Test 'part_find' command */ +static int cmd_test_part_find(struct unit_test_state *uts) +{ + struct udevice *dev; + ofnode root, node; + + /* Enable the requested mmc node since we need a second bootflow */ + root = oftree_root(oftree_default()); + node = ofnode_find_subnode(root, "mmc5"); + ut_assert(ofnode_valid(node)); + ut_assertok(lists_bind_fdt(gd->dm_root, node, &dev, NULL, false)); + + ut_assertok(device_probe(dev)); + + ut_assertok(env_set("target_part", NULL)); + ut_assertok(run_command("part_find c12a7328-f81f-11d2-ba4b-00a0c93ec93b", 0)); + ut_assert_console_end(); + ut_asserteq_str("mmc 5:c", env_get("target_part")); + + ut_asserteq(1, run_command("part_find invalid", 0)); + ut_asserteq_str("mmc 5:c", env_get("target_part")); + + ut_assert_console_end(); + + return 0; +} +CMD_TEST(cmd_test_part_find, UTF_CONSOLE | UTF_DM | UTF_SCAN_FDT);