Improve 'search' grub-shell command with functionality to search for a partition by PARTUUID and PARTLABEL strings. This is useful for embedded systems where FSUUID is not guaranteed to be constant, e.g. it is not preserved between system updates, and modifying grub.cfg is undesired.
Signed-off-by: Vitaly Kuzmichev <[email protected]> --- V2: This patch is based on Michael Grzeschik version from 27 May 2019 [1] with the following changes: 1. Addressed review feedback from Daniel Kiper [2] and Nick Vinson [3]. 2. Added support for GPT PARTUUID. 3. Moved MBR disk signature reading from partmap/msdos.c to commands/search.c to read it only when it is needed. [1] https://lists.gnu.org/archive/html/grub-devel/2019-05/msg00124.html [2] https://lists.gnu.org/archive/html/grub-devel/2019-05/msg00131.html [3] https://lists.gnu.org/archive/html/grub-devel/2019-05/msg00134.html V3, V4: Coding style and spelling fixes. V5: 1. Reworked basing on suggestions from Glenn Washburn [4][5][6]. Now reading GPT and MBR UUIDs is split into two different helper functions. However, grub_uuidcasecmp() is used to compare UUIDs instead of comparing in binary. 2. Integrated patch from Daniel Wagenknecht for searching by PARTLABEL support [7], and reworked it basing on Glenn Washburn feedback [8]. Currently only 36 characters of partition name are used to compare. 3. Added showing PARTLABEL to 'probe' command, simplified code for 'probe --part-uuid' command. 4. Updated documentation. (36 characters limit is also documented). 5. Moved some commmon code in FAT, F2FS, NTFS, ISO9660, and chainloader modules to common inline helper function grub_utf16_to_utf8_alloc(). 6. Provided small fix for grub_uuidcasecmp(). [4] https://lists.gnu.org/archive/html/grub-devel/2022-02/msg00013.html [5] https://lists.gnu.org/archive/html/grub-devel/2022-02/msg00095.html [6] https://lists.gnu.org/archive/html/grub-devel/2022-02/msg00100.html [7] https://lists.gnu.org/archive/html/grub-devel/2020-11/msg00188.html [8] https://lists.gnu.org/archive/html/grub-devel/2022-09/msg00115.html Vitaly Kuzmichev (16): partmap/gpt: Add grub_gpt_partition_get_uuid() partmap/msdos: Add grub_mbr_partition_get_uuid() commands/probe: Simplify 'probe --part-uuid' command include/grub/misc.h: Fix edge case in grub_uuidcasecmp() commands/search: Add support to search by partition PARTUUID include/grub/charset.h: Enhance grub_utf16_to_utf8() include/grub/charset.h: Add grub_utf16_{strlen,strnlen}() include/grub/charset.h: Add grub_utf16_to_utf8_alloc() partmap/gpt: Add grub_gpt_partition_get_label() commands/search: Add support to search by partition PARTLABEL commands/probe: Add command option to display partition PARTLABEL docs/grub.texi: Update documentation for 'probe' and 'search' commands fs/f2fs: Simplify to use grub_utf16_to_utf8_alloc() fs/fat: Simplify to use grub_utf16_to_utf8_alloc() fs/iso9660: Simplify to use grub_utf16_to_utf8_alloc() fs/ntfs: Simplify to use grub_utf16_to_utf8_alloc() docs/grub.texi | 47 ++++++++++++---- grub-core/Makefile.core.def | 10 ++++ grub-core/commands/efi/lsefisystab.c | 2 +- grub-core/commands/probe.c | 81 ++++++++++++--------------- grub-core/commands/search.c | 47 +++++++++++++++- grub-core/commands/search_partlabel.c | 5 ++ grub-core/commands/search_partuuid.c | 5 ++ grub-core/commands/search_wrap.c | 16 +++++- grub-core/commands/usbtest.c | 2 +- grub-core/fs/f2fs.c | 24 ++------ grub-core/fs/fat.c | 24 ++++---- grub-core/fs/hfsplus.c | 4 +- grub-core/fs/iso9660.c | 15 +---- grub-core/fs/jfs.c | 3 +- grub-core/fs/ntfs.c | 18 +----- grub-core/fs/udf.c | 3 +- grub-core/kern/efi/efi.c | 15 +++-- grub-core/loader/efi/chainloader.c | 2 +- grub-core/loader/i386/xnu.c | 2 +- grub-core/osdep/windows/hostdisk.c | 2 +- grub-core/partmap/gpt.c | 72 ++++++++++++++++++++++++ grub-core/partmap/msdos.c | 32 +++++++++++ include/grub/charset.h | 70 ++++++++++++++++++++++- include/grub/gpt_partition.h | 5 ++ include/grub/misc.h | 3 +- include/grub/msdos_partition.h | 3 + include/grub/search.h | 6 ++ 27 files changed, 378 insertions(+), 140 deletions(-) create mode 100644 grub-core/commands/search_partlabel.c create mode 100644 grub-core/commands/search_partuuid.c -- 2.34.1 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
