Received: from list by lists.gnu.org with archive (Exim 4.71) id 1exdXL-0004Cv-SX for mharc-grub-devel@gnu.org; Sun, 18 Mar 2018 15:00:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60366) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1exdXG-0004CL-62 for grub-devel@gnu.org; Sun, 18 Mar 2018 15:00:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1exdXF-0004qm-4P for grub-devel@gnu.org; Sun, 18 Mar 2018 15:00:02 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:42051) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1exdXE-0004qV-RA for grub-devel@gnu.org; Sun, 18 Mar 2018 15:00:01 -0400 Received: by mail-pf0-x242.google.com with SMTP id a16so6149349pfn.9 for ; Sun, 18 Mar 2018 12:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to; bh=GgU0g6G3jZlterLt8Jyy3kEgQ7ycXm+4768Mk+h8jsA=; b=cIoNdmoEO0JnF3lRBUOSi9gl/vwjWHZ6Z/4ujlVemvZLQO0tsTKf7tpa2mP+/ru5Dm MKYR+oNXop6wT6G+JF9XpvfgnHGDDjFlnwOBKtwgRnmh0SyxPMadIotkAeglDRkhpinM DDZO/j1uEPNuiRhf0Nj1X9DWxRbH4akjBuvmTMMZhSKIFvTS2DijTOnQHsHj5um25hzh rngJYtCZBvEZi0kwpTVs04sa84lKvHJZOCv2wXkDCFzdgvLRy9jwpaZOFQeMaWGqnw5d 6xTE5UM9lN1T2MkkK4jYMs9yxQTMZ03Z2GwqwnU4SnIe/JZ63M4MP7cY6WN3MN0jBilz zc1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to; bh=GgU0g6G3jZlterLt8Jyy3kEgQ7ycXm+4768Mk+h8jsA=; b=okaxjPtMH+UsBx24KeDCA4WkzxyXZAovfNbS7jJjZ9Zc2K5lUsD5KOo4Tvg3IYAkmQ yiM+DVsBIfWbzw9KviR4CzB8605EdgmhZs3Sh+qV8KJiKuoWI4i192gmhnagnewhYxlP h25T9b/lnhD8hQ7B4/9pnT3TnB6u94XqEApPFFz2tHzkWwUKGjbwG/RXHaG7XgoYYW6F 0dHzqScZGj9EauQn1qbtBj+d8M8TI0nNbR5dUpQT/U3Z+i4qfZA5sjByiaPnqEZFHUup 1jwpORmTzlE3qK++ZnigVzbQVtD7BScLxCSH3JOxe9o6f5QzIZKR7e0OduUXZdOiRiFf 3K9g== X-Gm-Message-State: AElRT7EMGIY/HZCS28pGLHecleNWYmwgJmh6e1uV0nQ1RDMv9ioR0SVR dg9NtllIGwTfmW4wEAAmTQQUog== X-Google-Smtp-Source: AG47ELvKj2WMoWFUjOkrrHXnd3SzitlF3Jt/st7RYqSGwh67WUZOQvlpIGnPKDVWn+nKFtGWF5E9sw== X-Received: by 10.99.124.79 with SMTP id l15mr7094075pgn.19.1521399599183; Sun, 18 Mar 2018 11:59:59 -0700 (PDT) Received: from ?IPv6:2601:602:9c01:e86a:2ec2:3a19:cd81:76ab? ([2601:602:9c01:e86a:2ec2:3a19:cd81:76ab]) by smtp.googlemail.com with ESMTPSA id k195sm24228208pgc.71.2018.03.18.11.59.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Mar 2018 11:59:57 -0700 (PDT) Subject: Re: [GRUB PARTUUID PATCH V5 2/3] Add PARTUUID detection support to grub-probe To: Daniel Kiper Cc: grub-devel@gnu.org References: <20180204194737.22662-1-nvinson234@gmail.com> <20180204194737.22662-3-nvinson234@gmail.com> <20180220174156.GG29532@router-fw-old.local.net-space.pl> From: Nick Vinson Message-ID: <35d6c938-ebb5-ebda-e4fb-5f6f4fd0c24e@gmail.com> Date: Sun, 18 Mar 2018 11:59:56 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180220174156.GG29532@router-fw-old.local.net-space.pl> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="7hQ6NeBUAcizWr2QDn1cG0pCOpfvmIaxl" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Mar 2018 19:00:06 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --7hQ6NeBUAcizWr2QDn1cG0pCOpfvmIaxl Content-Type: multipart/mixed; boundary="kvH5tHu0bKZFOUBat4r526EZ4mp2gMIni"; protected-headers="v1" From: Nick Vinson To: Daniel Kiper Cc: grub-devel@gnu.org Message-ID: <35d6c938-ebb5-ebda-e4fb-5f6f4fd0c24e@gmail.com> Subject: Re: [GRUB PARTUUID PATCH V5 2/3] Add PARTUUID detection support to grub-probe References: <20180204194737.22662-1-nvinson234@gmail.com> <20180204194737.22662-3-nvinson234@gmail.com> <20180220174156.GG29532@router-fw-old.local.net-space.pl> In-Reply-To: <20180220174156.GG29532@router-fw-old.local.net-space.pl> --kvH5tHu0bKZFOUBat4r526EZ4mp2gMIni Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 02/20/2018 09:41 AM, Daniel Kiper wrote: > On Sun, Feb 04, 2018 at 11:47:36AM -0800, Nicholas Vinson wrote: >> Add PARTUUID detection support grub-probe for MBR and GPT partition >> schemes. The Linux kernel supports mounting the root filesystem by >> Linux device name or by the Partition [GU]UID. GRUB's mkconfig, >> however, currently only supports specifing the rootfs in the kernel >> command-line by Linux device name unless an initramfs is also present.= >> When an initramfs is present GRUB's mkconfig will set the kernel's roo= t >> parameter value to either the Linux device name or to the filesystem >> [GU]UID. >> >> Therefore, the only way to protect a Linux system from failing to boot= >> when its Linux storage device names change is to either manually edit >> grub.cfg or /etc/default/grub and append root=3DPARTUUID=3Dxxx to the >> command-line or create an initramfs that understands how to mount >> devices by filesystem [G]UID and let grub-mkconfig pass the filesystem= >> [GU]UID to the initramfs. >> >> The goal of this patch set is to enable root=3DPARTUUID=3Dxxx support = in >> grub-mkconfig, so that users don't have to manually edit >> /etc/default/grub or grub.cfg, or create an initramfs for the sole >> purpose of having a robust bootloader configuration for Linux. >> --- >> util/grub-probe.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++= +++++ >> 1 file changed, 51 insertions(+) >> >> diff --git a/util/grub-probe.c b/util/grub-probe.c >> index 21cb80fbe..3656e32e8 100644 >> --- a/util/grub-probe.c >> +++ b/util/grub-probe.c >> @@ -28,6 +28,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -62,6 +63,7 @@ enum { >> PRINT_DRIVE, >> PRINT_DEVICE, >> PRINT_PARTMAP, >> + PRINT_PARTUUID, >> PRINT_ABSTRACTION, >> PRINT_CRYPTODISK_UUID, >> PRINT_HINT_STR, >> @@ -85,6 +87,7 @@ static const char *targets[] =3D >> [PRINT_DRIVE] =3D "drive", >> [PRINT_DEVICE] =3D "device", >> [PRINT_PARTMAP] =3D "partmap", >> + [PRINT_PARTUUID] =3D "partuuid", >> [PRINT_ABSTRACTION] =3D "abstraction", >> [PRINT_CRYPTODISK_UUID] =3D "cryptodisk_uuid", >> [PRINT_HINT_STR] =3D "hints_string", >> @@ -181,6 +184,48 @@ probe_partmap (grub_disk_t disk, char delim) >> } >> } >> >> +static void >> +probe_partuuid (grub_disk_t disk, char delim) >> +{ >> + /* >> + * Nested partitions not supported for now. >> + * Non-nested partitions must have disk->partition->parent =3D=3D N= ULL >> + */ >> + if (disk->partition && disk->partition->parent =3D=3D NULL) >> + { >> + if (strcmp(disk->partition->partmap->name, "msdos") =3D=3D 0) >> + { >> + /* >> + * The partition GUID for MSDOS is the partition number (startin= g >> + * with 1) prepended with the NT disk signature. >> + */ >> + grub_uint32_t nt_disk_sig; >=20 > Here you use spaces... >=20 >> + grub_partition_t p =3D disk->partition; >=20 > ...and here tab and spaces. I prefer the latter. > Please fix this. >=20 Fixed. >> + disk->partition =3D p->parent; >> + >> + if (grub_disk_read (disk, 0, GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,= >> + sizeof(nt_disk_sig), &nt_disk_sig) =3D=3D 0) >> + { >> + grub_printf ("%08x-%02x", >> + grub_le_to_cpu32(nt_disk_sig), 1 + p->number); >> + } >=20 > These curly brackets are not needed. Please remove them and leave empty= > line before next instruction. >=20 Curly braces removed and a new line added. >> + disk->partition =3D p; >> + } >> + else if (strcmp(disk->partition->partmap->name, "gpt") =3D=3D 0= ) >> + { >> + grub_partition_t p =3D disk->partition; >> + struct grub_gpt_partentry gptdata; >> + >> + disk->partition =3D p->parent; >> + >> + if (grub_disk_read (disk, p->offset, p->index, >> + sizeof(gptdata), &gptdata) =3D=3D 0) >> + print_gpt_guid(gptdata.guid); >=20 > Please add empty line here. >=20 Added. These changes will also be included in version 6. Thanks, Nicholas Vinson >> + disk->partition =3D p; >> + } >> + } >> +} >> + >=20 > Otherwise patch LGMT. >=20 > Daniel >=20 --kvH5tHu0bKZFOUBat4r526EZ4mp2gMIni-- --7hQ6NeBUAcizWr2QDn1cG0pCOpfvmIaxl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEE18QFYzlwGKI8bhHQAGpoeGzkaOIFAlqutywACgkQAGpoeGzk aOLh2w//QBS5x2Hbb2lnYed2Wso5juKFJeUWH0ejfgK93Vl86lfeuvad217tPRkv jNZMj6x9mj3FazFwqzygppxhzacLsFTzOFtpQ1B8ziIWT9FX5Km8j+mT2bIYqds3 1CseY68SWB6/F/rFb2erQU1RoKwh9Q5igBDiYtIVtbFFf1fZitAtiq3/OKmvWl5J iAFQrJCl8Qe8jrONnKy+71A5yGhGFWP3vAIEr0mu3qlaP6bYyX9SXJ9A5buRuicZ wVfoRa1aXOmkWzFQPPgDEO1LjfxrJM9XWg7EG9Xk2/YY3cbZkYybDmoVqBhUuwOf BtlXsPl+pTGJD43qcqgyGC+L3i2Rsnu57rwsomr5BtI57YoRY483UUcs9qcrMtee hHao0KCqPywQMTOTA1EIbo+KMZFOFxX3doy9eeklQHlgoWaAbaE9c9+LdZl3oRBY eQOiadqt+9nQpuzUa3N/TPrdsyKBB0uDcPWUtAdCqGJ1wptNyb7p1+goYFuicDPy 6LXnsen+CnIwxHSndCOLRCOvVc5hh0dzp32f9gHRU+ZXfPSXjjd9HFf/5rqTYKIJ UDZanGCLl2a1R8lApCfeN+4oygpz8gFjYf+2heAnd6/bqb1HhMfOigKDNBP+UBPa KyuYirGBMc9mgXTsHPz3UU0myQyk3HyzkeAQO6o8imHxayLEuh4= =d8H7 -----END PGP SIGNATURE----- --7hQ6NeBUAcizWr2QDn1cG0pCOpfvmIaxl--