From patchwork Thu Dec 22 10:30:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enric Balletbo i Serra X-Patchwork-Id: 1718863 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WaPmsZ2Z; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NdCKM623gz23dT for ; Fri, 23 Dec 2022 01:25:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CF8D685477; Thu, 22 Dec 2022 15:24:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="WaPmsZ2Z"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1FE67852D0; Thu, 22 Dec 2022 11:30:56 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6B71F851D7 for ; Thu, 22 Dec 2022 11:30:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=eballetb@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671705052; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3HZhiRKOMwW0E5zcWURNwxTYpMdgNAZHf4VEYz7r04Y=; b=WaPmsZ2ZXXD10Qu0nPgIRlWhKQa53I8oJ/xRKuBQZpbsJn3FRtR6Bj36V6Ws1D40oEsj9P h47KmNgBRLzND2YHckUH5yz2mQkQZO2zQ5rSo8NgO+mrOcbILtzM9GC13m4YJmx3aVAusB Ep5EOBzw3jPyw+i5lvCU0ixxMgqoHdQ= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-619-TxuAZO5IP9-2mI_tp17I7A-1; Thu, 22 Dec 2022 05:30:51 -0500 X-MC-Unique: TxuAZO5IP9-2mI_tp17I7A-1 Received: by mail-wr1-f71.google.com with SMTP id n12-20020adfc60c000000b0026647ef69f4so299582wrg.10 for ; Thu, 22 Dec 2022 02:30:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3HZhiRKOMwW0E5zcWURNwxTYpMdgNAZHf4VEYz7r04Y=; b=BbLPTF330dS4fniocXv48RgvYZilgRcTRdlLbO06liYkMSjefesNfIBv2pFD0DLqvZ xJ1SzfQUPUktnxcoiX2B1XySf1UDzlmVcVsReWkYJbuPRuInTxVz5gsatH/uVEEmKi7h /klDEIZt4fxdPHa7Bw8DUbtMpw/daj1zQzQdSnPBAptuyPASHfJ/ZIV0AYvDFiFykz+/ rk/pBOsRreswYayxWFWqzAR3wS2OzOp4jE+9P86/FGgTx5j3lwbHxZDRuRhU8DUanFyK j+J6gKMiLpAjGA97q8J4G1OX/CsetIYQSQzBTMCz0jZsTPlStwPYl82nx6Ts4dZl8rwt pIIQ== X-Gm-Message-State: AFqh2kqLFQkOFNP/Nd4xnF2nSZcInyquIepHX0hXOF68/sXTHNYFYhSr pQvfHwVw7cgupLced3ILVvXhg4mfxa68KMRGhMwOCjN+uPsQpeJLc0K7leWP8A4U0Dv7lh/zP5d +akXd8J7IsQg2j0NMS6VzaaSjCxeAbXizyA3qYE27jwUs/s/4Pvi2EO2daHOSwxLPPw== X-Received: by 2002:a05:600c:3ac3:b0:3d1:cfcb:7d19 with SMTP id d3-20020a05600c3ac300b003d1cfcb7d19mr4339296wms.32.1671705049821; Thu, 22 Dec 2022 02:30:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXtQBzIxBFdRZS9NFt7MwqR/K6C1tGEM5ZgT/mCh4IDkJV0GiqWk01RQXSpff/bdQ3Bf9x1c5w== X-Received: by 2002:a05:600c:3ac3:b0:3d1:cfcb:7d19 with SMTP id d3-20020a05600c3ac300b003d1cfcb7d19mr4339279wms.32.1671705049548; Thu, 22 Dec 2022 02:30:49 -0800 (PST) Received: from localhost.localdomain ([109.167.21.147]) by smtp.gmail.com with ESMTPSA id q2-20020a1cf302000000b003d1cc0464a2sm581037wmq.8.2022.12.22.02.30.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Dec 2022 02:30:49 -0800 (PST) From: Enric Balletbo i Serra X-Google-Original-From: Enric Balletbo i Serra To: u-boot@lists.denx.de Cc: trini@konsulko.com, xypron.glpk@gmx.de, Enric Balletbo i Serra Subject: [PATCH v2 3/4] cmd: part: Add partition-related type command Date: Thu, 22 Dec 2022 11:30:31 +0100 Message-Id: <20221222103032.149098-4-eballetbo@redhat.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221222103032.149098-1-eballetbo@redhat.com> References: <20221222103032.149098-1-eballetbo@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Mailman-Approved-At: Thu, 22 Dec 2022 15:24:36 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean This implements the following command: part type mmc 0:1 -> print partition type UUID part type mmc 0:1 uuid -> set environment variable to partition type UUID "part type" can be useful when writing a bootcmd which searches for a specific partition type to enable automatic discovery of partitions and their intended usage or mount point. Signed-off-by: Enric Balletbo i Serra Reviewed-by: Simon Glass --- (no changes since v1) cmd/part.c | 29 +++++++++++++++++++++++++++++ doc/usage/cmd/part.rst | 12 ++++++++++++ 2 files changed, 41 insertions(+) diff --git a/cmd/part.c b/cmd/part.c index 9d419c967c..26b0cc84fe 100644 --- a/cmd/part.c +++ b/cmd/part.c @@ -182,6 +182,29 @@ static int do_part_number(int argc, char *const argv[]) return do_part_info(argc, argv, CMD_PART_INFO_NUMBER); } +static int do_part_type(int argc, char *const argv[]) +{ + int part; + struct blk_desc *dev_desc; + struct disk_partition info; + + if (argc < 2) + return CMD_RET_USAGE; + if (argc > 3) + return CMD_RET_USAGE; + + part = blk_get_device_part_str(argv[0], argv[1], &dev_desc, &info, 0); + if (part < 0) + return 1; + + if (argc > 2) + env_set(argv[2], info.type_guid); + else + printf("%s\n", info.type_guid); + + return 0; +} + static int do_part_types(int argc, char * const argv[]) { struct part_driver *drv = ll_entry_start(struct part_driver, @@ -218,6 +241,8 @@ static int do_part(struct cmd_tbl *cmdtp, int flag, int argc, return do_part_size(argc - 2, argv + 2); else if (!strcmp(argv[1], "number")) return do_part_number(argc - 2, argv + 2); + else if (!strcmp(argv[1], "type")) + return do_part_type(argc - 2, argv + 2); else if (!strcmp(argv[1], "types")) return do_part_types(argc - 2, argv + 2); return CMD_RET_USAGE; @@ -244,6 +269,10 @@ U_BOOT_CMD( "part number \n" " - set environment variable to the partition number using the partition name\n" " part must be specified as partition name\n" + "part type :\n" + " - print partition type\n" + "part type : \n" + " - set environment variable to partition type\n" "part types\n" " - list supported partition table types" ); diff --git a/doc/usage/cmd/part.rst b/doc/usage/cmd/part.rst index 0d098c7e3f..85cca0f0c7 100644 --- a/doc/usage/cmd/part.rst +++ b/doc/usage/cmd/part.rst @@ -13,6 +13,7 @@ Synopis part start part size part number + part type : [varname] part types Description @@ -81,6 +82,17 @@ part must be specified as partition name. varname a variable to store the current partition number value into +The 'part type' command prints or sets an environment variable to the partition type UUID. + + interface + interface for accessing the block device (mmc, sata, scsi, usb, ....) + dev + device number + part + partition number + varname + a variable to store the current partition type UUID value into + The 'part types' command list supported partition table types. Example