From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: Joshua Watt <jpewhacker@gmail.com>
Cc: Simon Glass <sjg@chromium.org>, u-boot@lists.denx.de
Subject: Re: [PATCH v4 2/8] doc: Add gpt command documentation
Date: Tue, 29 Aug 2023 00:59:51 +0200 [thread overview]
Message-ID: <e26582f6-09ba-4c2a-ba84-2e75fec5ee08@gmx.de> (raw)
In-Reply-To: <42cf6878-2bb3-4a58-82cc-96f920cf9e4f@gmx.de>
On 8/29/23 00:45, Heinrich Schuchardt wrote:
> /On 8/28/23 23:56, Joshua Watt wrote:
>> Adds initial documentation for the gpt command
>>
>> Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
>> ---
>> doc/usage/cmd/gpt.rst | 184 ++++++++++++++++++++++++++++++++++++++++++
>> doc/usage/index.rst | 1 +
>> 2 files changed, 185 insertions(+)
>> create mode 100644 doc/usage/cmd/gpt.rst
>>
>> diff --git a/doc/usage/cmd/gpt.rst b/doc/usage/cmd/gpt.rst
>> new file mode 100644
>> index 0000000000..6387c8116f
>> --- /dev/null
>> +++ b/doc/usage/cmd/gpt.rst
>> @@ -0,0 +1,184 @@
>> +.. SPDX-License-Identifier: GPL-2.0+
>> +
>> +gpt command
>> +===========
>> +
>> +Synopsis
>> +--------
>> +
>> +::
>> +
>> + gpt enumerate <interface> <dev>
>> + gpt guid <interface> <dev> [<varname>]
>> + gpt read <interface> <dev> [<varname>]
>> + gpt rename <interface> <dev> <part> <name>
>> + gpt repair <interface> <dev>
>> + gpt setenv <interface> <dev> <partition name>
>> + gpt swap <interface> <dev> <name1> <name2>
>> + gpt verify <interface> <dev> [<partition string>]
>> + gpt write <interface> <dev> <partition string>
>> +
>> +Description
>> +-----------
>> +
>> +The gpt command lets users read, create, modify, or verify the GPT (GUID
>> +Partition Table) partition layout.
>> +
>> +Common arguments:
>> +
>> +interface
>> + interface for accessing the block device (mmc, sata, scsi, usb,
>> ....)
>> +
>> +dev
>> + device number
>> +
>> +partition string
>> + Describes the GPT partition layout for a disk. The syntax is
>> similar to
>> + the one used by the :doc:`mbr command <mbr>` command. The string
>> contains
>> + one or more partition descriptors, each separated by a ";". Each
>> descriptor
>> + contains one or more fields, with each field separated by a ",".
>> Fields are
>> + either of the form "key=value" to set a specific value, or simple
>> "flag" to
>> + set a boolean flag
>> +
>> + The first descriptor can optionally be used to describe
>> parameters for the
>> + whole disk with the following fields:
>> +
>> + * uuid_disk=UUID - Set the UUID for the disk
>> +
>> + Partition descriptors can have the following fields:
>> +
>> + * name=<NAME> - The partition name, required
>> + * start=<BYTES> - The partition start offset in bytes, required
>
> The code has this comment: "start address is optional".
>
>> + * size=<BYTES> - The partition size in bytes or "-" to expand it
>> to the whole free area
>
> This filed is mandatory.
>
>> + * bootable - Set the legacy bootable flag
>
> This field is optional
>
>> + * uuid=<UUID> - The partition UUID, optional if
>> CONFIG_RANDOM_UUID=y is enabled
>> + * type=<UUID> - The partition type GUID, requires
>> CONFIG_PARTITION_TYPE_GUID=y
>
> This field is optional
>
> Thanks for all the updates. Looks much neater now.
>
> The sequence expected in set_gpt_info() is:
>
> uuid (optional if CONFIG_RANDOM_UUID=y),
> type (optional, only usable for CONFIG_PARTITION_TYPE_GUID=y),
> name (mandatory),
> size (mandatory),
> start (optional),
> bootable (optional).
A gross bug in the gpt command is that 'gpt read' creates a different
sequence than 'gpt write' needs.
Furthermore 'gpt read' does not write all fields needed by 'gpt write'
to recreate the partition table: bootable and type are missing.
Best regards
Heinrich
>
> From the description above it is not clear that:
>
> * semicolons are used to separate partitions
> * the exact sequence of fields must be kept
> * commas are used to separate fields
> * no extra white-space is allowed.
>
>> +
>> +
>> + If 'uuid' is not specified, but CONFIG_RANDOM_UUID is enabled, a
>> random UUID
>> + will be generated for the partition
>> +
>> +gpt enumerate
>> +~~~~~~~~~~~~~
>> +
>> +Sets the variable 'gpt_partition_list' to be a list of all the
>> partition names
>> +on the device.
>> +
>> +gpt guid
>> +~~~~~~~~
>> +
>> +Report the GUID of a disk. If 'varname' is specified, the command
>> will set the
>> +variable to the GUID, otherwise it will be printed out.
>> +
>> +gpt read
>> +~~~~~~~~
>> +
>> +Prints the current state of the GPT partition table. If 'varname' is
>> specified,
>> +the variable will be filled with a partition string in the same
>> format as a
>> +'<partition string>', suitable for passing to other 'gpt' commands.
>> If the
>> +argument is omitted, a human readable description is printed out.
>> +CONFIG_CMD_GPT_RENAME=y is required.
>> +
>> +gpt rename
>> +~~~~~~~~~~
>> +
>> +Renames all partitions named 'part' to be 'name'.
>> CONFIG_CMD_GPT_RENAME=y is
>> +required.
>> +
>> +gpt repair
>> +~~~~~~~~~~
>> +
>> +Repairs the GPT partition tables if it they become corrupted.
>> +
>> +gpt setenv
>> +~~~~~~~~~~
>> +
>> +The 'gpt setenv' command will set a series of environment variables with
>> +information about the partition named '<partition name>'. The
>> variables are:
>> +
>> +gpt_partition_addr
>> + the starting offset of the partition in blocks as a hexadecimal
>> number
>> +
>> +gpt_partition_size
>> + the size of the partition in blocks as a hexadecimal number
>> +
>> +gpt_partition_name
>> + the name of the partition
>> +
>> +gpt_partition_entry
>> + the partition number in the table, e.g. 1, 2, 3, etc.
>
> Since eeef58401520 ("cmd: let gpt_partition_entry be hexadecimal") this
> is a hexadecimal number. As partitions are not required to be numbered
> start at 1:
>
> %s/, e.g. 1, 2, 3, etc./as a hexadecimal number/
>
>> +
>> +gpt swap
>> +~~~~~~~~
>> +
>> +Changes the names of all partitions that are named 'name1' to be
>> 'name2', and
>> +all partitions named 'name2' to be 'name1'. CONFIG_CMD_GPT_RENAME=y is
>> +required.
>> +
>> +gpt verify
>> +~~~~~~~~~~
>> +
>> +Sets return value $? to 0 (true) if the partition layout on the
>> +specified disk matches the one in the provided partition string, and
>> 1 (false)
>> +if it does not match. If no partition string is specified, the
>> command will
>> +check if the disk is partitioned or not.
>> +
>> +gpt write
>> +~~~~~~~~~
>> +
>> +(Re)writes the partition table on the disk to match the provided
>> +partition string. It returns 0 on success or 1 on failure.
>> +
>> +Configuration
>> +-------------
>
> All other man-pages have Configuration after Examples.
>
>> +
>> +To use the 'gpt' command you must specify CONFIG_CMD_GPT=y. To enable
>> 'gpt
>> +read', 'gpt swap' and 'gpt rename', you must specify
>> CONFIG_CMD_GPT_RENAME=y.
>> +
>> +Examples
>> +~~~~~~~~
>
> An example for gpt read would be nice.
>
>> +Create 6 partitions on a disk:: > +
>> + => setenv gpt_parts 'uuid_disk=bec9fc2a-86c1-483d-8a0e-0109732277d7;
>> +
>> name=boot,start=4M,size=128M,bootable,type=ebd0a0a2-b9e5-4433-87c0-68b6b72699c7,
>> +
>> name=rootfs,size=3072M,type=0fc63daf-8483-4772-8e79-3d69d8477de4;
>> +
>> name=system-data,size=512M,type=0fc63daf-8483-4772-8e79-3d69d8477de4;
>> + name=[ext],size=-,type=0fc63daf-8483-4772-8e79-3d69d8477de4;
>> + name=user,size=-,type=0fc63daf-8483-4772-8e79-3d69d8477de4;
>> +
>> name=modules,size=100M,type=0fc63daf-8483-4772-8e79-3d69d8477de4;
>> + name=ramdisk,size=8M,type=0fc63daf-8483-4772-8e79-3d69d8477de4
>> + => gpt write mmc 0 $gpt_parts
>
> There is a starting single quotation mark, but I don't see an ending
> single quotation mark.
>
> White-space is not allowed before 'name='. As ugly as it is, please, put
> the whole setenv command into a single line.
>
> You cannot use a comma before name=. It must be a semicolon.
>
> Looking at the code the sequence in the partition descriptors seems to
> be wrong. It should be
>
> uuid (optional if CONFIG_RANDOM_UUID=y),
> type (optional, only usable for CONFIG_PARTITION_TYPE_GUID=y),
> name (mandatory),
> size (mandatory),
> start (optional),
> bootable (optional).
> .
> Please, use a command that you have actually tested and copy it
> verbatim. sandbox_defconfig has a host bind command to attach a file as
> drive. That makes testing easy.
>
>> +
>> +
>> +Verify that the device matches the partition layout described in the
>> variable
>> +$gpt_parts::
>> +
>> + => gpt verify mmc 0 $gpt_parts
>
> How about adding output here:
>
> => gpt verify mmc 0 $gpt_parts; echo $?
> 0
>
> Best regards
>
> Heinrich
>
>> +
>> +
>> +Get the information about the partition named 'rootfs'::
>> +
>> + => gpt setenv mmc 0 rootfs
>> + => echo ${gpt_partition_addr}
>> + 2000
>> + => echo ${gpt_partition_size}
>> + 14a000
>> + => echo ${gpt_partition_name}
>> + rootfs
>> + => echo ${gpt_partition_entry}
>> + 2
>> +
>> +Get the list of partition names on the disk::
>> +
>> + => gpt enumerate
>> + => echo gpt_partition_list
>> + boot rootfs system-data [ext] user modules ramdisk
>> +
>> +
>> +Get the GUID for a disk::
>> +
>> + => gpt guid mmc 0
>> + bec9fc2a-86c1-483d-8a0e-0109732277d7
>> + => gpt guid mmc gpt_disk_uuid
>> + => echo ${gpt_disk_uuid}
>> + bec9fc2a-86c1-483d-8a0e-0109732277d7
>> diff --git a/doc/usage/index.rst b/doc/usage/index.rst
>> index f45a7f5502..fa702920fa 100644
>> --- a/doc/usage/index.rst
>> +++ b/doc/usage/index.rst
>> @@ -66,6 +66,7 @@ Shell commands
>> cmd/for
>> cmd/fwu_mdata
>> cmd/gpio
>> + cmd/gpt
>> cmd/host
>> cmd/imxtract
>> cmd/load
>
next prev parent reply other threads:[~2023-08-28 22:59 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-15 16:26 [PATCH 0/6] cmd: gpt: GPT manipulation improvements Joshua Watt
2023-08-15 16:26 ` [PATCH 1/6] cmd: gpt: Remove confusing help text Joshua Watt
2023-08-18 14:23 ` Tom Rini
2023-08-23 23:57 ` Simon Glass
2023-08-15 16:26 ` [PATCH 2/6] cmd: gpt: Add command to set bootable flags Joshua Watt
2023-08-15 18:39 ` Simon Glass
2023-08-15 16:26 ` [PATCH 3/6] cmd: gpt: Add gpt_partition_bootable variable Joshua Watt
2023-08-15 16:26 ` [PATCH 4/6] cmd: gpt: Preserve type GUID if enabled Joshua Watt
2023-08-15 16:26 ` [PATCH 5/6] cmd: gpt: Preserve bootable flag Joshua Watt
2023-08-15 16:27 ` [PATCH 6/6] cmd: gpt: Add command to swap partition order Joshua Watt
2023-08-23 23:57 ` Simon Glass
2023-08-23 16:47 ` [PATCH v2 0/8] cmd: gpt: GPT manipulation improvements Joshua Watt
2023-08-23 16:47 ` [PATCH v2 1/8] cmd: gpt: Remove confusing help text Joshua Watt
2023-08-23 18:15 ` Tom Rini
2023-08-23 16:47 ` [PATCH v2 2/8] doc: Add gpt command documentation Joshua Watt
2023-08-23 18:15 ` Tom Rini
2023-08-23 23:57 ` Simon Glass
2023-08-23 16:47 ` [PATCH v2 3/8] tests: gpt: Remove test order dependency Joshua Watt
2023-08-23 23:57 ` Simon Glass
2023-08-24 3:29 ` Joshua Watt
2023-08-23 16:47 ` [PATCH v2 4/8] cmd: gpt: Add gpt_partition_bootable variable Joshua Watt
2023-08-23 23:57 ` Simon Glass
2023-08-23 16:47 ` [PATCH v2 5/8] cmd: gpt: Add command to set bootable flags Joshua Watt
2023-08-23 23:57 ` Simon Glass
2023-08-23 16:47 ` [PATCH v2 6/8] cmd: gpt: Preserve type GUID if enabled Joshua Watt
2023-08-23 23:57 ` Simon Glass
2023-08-23 16:47 ` [PATCH v2 7/8] cmd: gpt: Preserve bootable flag Joshua Watt
2023-08-23 23:57 ` Simon Glass
2023-08-23 16:47 ` [PATCH v2 8/8] cmd: gpt: Add command to swap partition order Joshua Watt
2023-08-25 19:38 ` [PATCH v3 0/8] cmd: gpt: GPT manipulation improvements Joshua Watt
2023-08-25 19:38 ` [PATCH v3 1/8] cmd: gpt: Remove confusing help text Joshua Watt
2023-08-25 19:38 ` [PATCH v3 2/8] doc: Add gpt command documentation Joshua Watt
2023-08-25 23:53 ` Simon Glass
2023-08-28 21:52 ` Joshua Watt
2023-08-26 1:57 ` Heinrich Schuchardt
2023-08-28 19:29 ` Joshua Watt
2023-08-28 20:01 ` Heinrich Schuchardt
2023-08-28 21:01 ` Joshua Watt
2023-08-25 19:38 ` [PATCH v3 3/8] tests: gpt: Remove test order dependency Joshua Watt
2023-08-25 19:38 ` [PATCH v3 4/8] cmd: gpt: Add gpt_partition_bootable variable Joshua Watt
2023-08-25 23:53 ` Simon Glass
2023-08-25 19:38 ` [PATCH v3 5/8] cmd: gpt: Add command to set bootable flags Joshua Watt
2023-08-25 19:38 ` [PATCH v3 6/8] cmd: gpt: Preserve type GUID if enabled Joshua Watt
2023-08-25 23:53 ` Simon Glass
2023-08-26 0:37 ` Heinrich Schuchardt
2023-08-25 19:38 ` [PATCH v3 7/8] cmd: gpt: Preserve bootable flag Joshua Watt
2023-08-25 19:38 ` [PATCH v3 8/8] cmd: gpt: Add command to swap partition order Joshua Watt
2023-08-25 23:53 ` Simon Glass
2023-08-26 1:00 ` Heinrich Schuchardt
2023-08-28 21:56 ` [PATCH v4 0/8] cmd: gpt: GPT manipulation improvements Joshua Watt
2023-08-28 21:56 ` [PATCH v4 1/8] cmd: gpt: Remove confusing help text Joshua Watt
2023-08-28 22:05 ` Heinrich Schuchardt
2023-08-28 21:56 ` [PATCH v4 2/8] doc: Add gpt command documentation Joshua Watt
2023-08-28 22:45 ` Heinrich Schuchardt
2023-08-28 22:59 ` Heinrich Schuchardt [this message]
2023-08-29 13:22 ` Joshua Watt
2023-08-28 21:56 ` [PATCH v4 3/8] tests: gpt: Remove test order dependency Joshua Watt
2023-08-28 21:56 ` [PATCH v4 4/8] cmd: gpt: Add gpt_partition_bootable variable Joshua Watt
2023-08-28 21:56 ` [PATCH v4 5/8] cmd: gpt: Add command to set bootable flags Joshua Watt
2023-08-28 22:54 ` Heinrich Schuchardt
2023-08-29 13:24 ` Joshua Watt
2023-08-28 21:56 ` [PATCH v4 6/8] cmd: gpt: Preserve type GUID if enabled Joshua Watt
2023-08-28 21:56 ` [PATCH v4 7/8] cmd: gpt: Preserve bootable flag Joshua Watt
2023-08-28 21:56 ` [PATCH v4 8/8] cmd: gpt: Add command to swap partition order Joshua Watt
2023-08-31 16:51 ` [PATCH v5 0/8] cmd: gpt: GPT manipulation improvements Joshua Watt
2023-08-31 16:51 ` [PATCH v5 1/8] cmd: gpt: Remove confusing help text Joshua Watt
2023-08-31 16:51 ` [PATCH v5 2/8] doc: Add gpt command documentation Joshua Watt
2023-08-31 16:51 ` [PATCH v5 3/8] tests: gpt: Remove test order dependency Joshua Watt
2023-09-12 15:17 ` Tom Rini
2023-08-31 16:51 ` [PATCH v5 4/8] cmd: gpt: Add gpt_partition_bootable variable Joshua Watt
2023-08-31 16:51 ` [PATCH v5 5/8] cmd: gpt: Add command to set bootable flags Joshua Watt
2023-08-31 16:51 ` [PATCH v5 6/8] cmd: gpt: Preserve type GUID if enabled Joshua Watt
2023-08-31 16:51 ` [PATCH v5 7/8] cmd: gpt: Preserve bootable flag Joshua Watt
2023-08-31 16:51 ` [PATCH v5 8/8] cmd: gpt: Add command to swap partition order Joshua Watt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e26582f6-09ba-4c2a-ba84-2e75fec5ee08@gmx.de \
--to=xypron.glpk@gmx.de \
--cc=jpewhacker@gmail.com \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.