From patchwork Wed Jul 27 13:35:34 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: 1661257 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=bYd8fMoE; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LtFY80ZR5z9sB4 for ; Wed, 27 Jul 2022 23:50:51 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5ADCD84044; Wed, 27 Jul 2022 15:50:38 +0200 (CEST) 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="bYd8fMoE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9F8E184044; Wed, 27 Jul 2022 15:35:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4F55883FAE for ; Wed, 27 Jul 2022 15:35:47 +0200 (CEST) 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=1658928946; 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; bh=kMEopT7WlM54WixWaGi7LhrcMGzniLJoeu7gFCvUDKw=; b=bYd8fMoEtmYgbW1HOsFvppjZ2V6SvtcY7r+WNGoit7ZAFH5qHDXmg8Llu+6AqY9lWtuxd9 VTZVwfn9Rh8GRkELlntcf1mUwCdxhFf9F50+e/Pytht+buag4/HADkXbuAbCkCC7LTVPvh /LJkg5aw279HgvZJI3Z2jUePuTZ/C9g= 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.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-212-hxt4G3E_PnSzLA5Cj1pVXQ-1; Wed, 27 Jul 2022 09:35:43 -0400 X-MC-Unique: hxt4G3E_PnSzLA5Cj1pVXQ-1 Received: by mail-wr1-f71.google.com with SMTP id h9-20020adfa4c9000000b0021ee4a48ea7so185465wrb.10 for ; Wed, 27 Jul 2022 06:35:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kMEopT7WlM54WixWaGi7LhrcMGzniLJoeu7gFCvUDKw=; b=gqcvMUKd0WMY5FK+R49oUmX1gHD5SlR77bKvqJxOP7V5pItGoFJzX1tw7YN9ExvMMS JKIDwNmo5mZxKcdCZae85zxr8McWw83DspVX+qkpYwgUYsGWjUl5CFMOM2VZM4fQ1nEX qGb5nP8vwcwS+eTFRX3jJdYp7tvEy8FHFDUQZSxxb86Fk0jDgOJZuX9Gcq6TV9BU0Doy PLLquXnq9GlsfCqnqkgX2s1feJ8YZA9e4wNAKNN5w8+yBhXuHyQ4dMxcUI8IzIo2Zd+i UESQacT8BfvoH0zMU1OIaxovWVDgTY6MeZngqjYNoHdyZLDUBxVfQtR4t/xete6BWg9+ opVA== X-Gm-Message-State: AJIora8T4KLZT4klUz9bdOGYtwB/EzvV6ws28ZHB4ZVfw6+F95uf/zto k2Hxn8NhAxcQK3MoSNz3KbikZGNgdPwmBK/mHB8v+6VWmno5J3eXdANs4C6p8wZ6sD325rP2+N8 MfEtcYqRiwPqlFT15jDvCAhgSQbEirk6YHpNbojHHpJTjW5eeQyxzhuVF0LztIjoTIQ== X-Received: by 2002:a05:600c:2194:b0:3a3:bea:1017 with SMTP id e20-20020a05600c219400b003a30bea1017mr3068902wme.44.1658928941914; Wed, 27 Jul 2022 06:35:41 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vcyqXuxMdx0lo/oNHj3Op7K3E3u7wiqvQdfV91e1Txnx06ZJPecB+0868pCLhY1xUeDfvf+g== X-Received: by 2002:a05:600c:2194:b0:3a3:bea:1017 with SMTP id e20-20020a05600c219400b003a30bea1017mr3068880wme.44.1658928941493; Wed, 27 Jul 2022 06:35:41 -0700 (PDT) Received: from fedora.. (34.red-79-157-70.dynamicip.rima-tde.net. [79.157.70.34]) by smtp.gmail.com with ESMTPSA id n41-20020a05600c502900b0039c5ab7167dsm2286083wmr.48.2022.07.27.06.35.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 06:35:41 -0700 (PDT) From: Enric Balletbo i Serra X-Google-Original-From: Enric Balletbo i Serra To: u-boot@lists.denx.de Cc: Enric Balletbo i Serra , Heinrich Schuchardt Subject: [PATCH] cmd: part: Add partition-related type command Date: Wed, 27 Jul 2022 15:35:34 +0200 Message-Id: <20220727133534.126824-1-eballetbo@redhat.com> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eballetb@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Mailman-Approved-At: Wed, 27 Jul 2022 15:50:35 +0200 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 partittion 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 --- cmd/part.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 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" );