block/partitions/core.c | 2 ++ 1 file changed, 2 insertions(+)
From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Both most common formats have uuid in addition to partition name:
GPT: standard uuid xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
DOS: 4 byte disk signature and 1 byte partition xxxxxxxx-xx
Tools from util-linux use the same notation for them.
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Reviewed-by: Kyle Fortin <kyle.fortin@oracle.com>
[dianders: rebased to modern kernels]
Signed-off-by: Douglas Anderson <dianders@google.com>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
I found myself needing the PARTUUID from userspace recently and it
seems like pretty much all of the solutions involve a lot of code or
including some userspace libraries to solve this for you. This is less
than ideal when you're running from an initrd and want to keep things
simple.
Given that the kernel has PARTUUID handling already and needs to keep
track of it for using it in "root=" matching, it seems silly not to
expose it, so I wrote a patch for it.
After I wrote the 2 line patch to expose the UUID, I thought to search
the internet and found an old patch where someone had written what
amounts to the same two lines [1], so I'm grabbing the old patch and
resending as a v2. I'm keeping the Reviewed-by even though I rebased
the patch (adjusted for file moves / name changes) since it's a tiny
patch and the concept is identical to the old patch.
Crossing my fingers that this looks OK to land.
[1] https://lore.kernel.org/r/150729013610.744480.1644359289262914898.stgit@buzz
Changes in v2:
- Rebased
block/partitions/core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 5bd7a603092e..aa54c1f4eaa5 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -253,6 +253,8 @@ static int part_uevent(const struct device *dev, struct kobj_uevent_env *env)
add_uevent_var(env, "PARTN=%u", bdev_partno(part));
if (part->bd_meta_info && part->bd_meta_info->volname[0])
add_uevent_var(env, "PARTNAME=%s", part->bd_meta_info->volname);
+ if (part->bd_meta_info && part->bd_meta_info->uuid[0])
+ add_uevent_var(env, "PARTUUID=%s", part->bd_meta_info->uuid);
return 0;
}
--
2.47.0.rc0.187.ge670bccf7e-goog
On Fri, 04 Oct 2024 17:13:43 -0700, Douglas Anderson wrote: > Both most common formats have uuid in addition to partition name: > GPT: standard uuid xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx > DOS: 4 byte disk signature and 1 byte partition xxxxxxxx-xx > > Tools from util-linux use the same notation for them. > > > [...] Applied, thanks! [1/1] block: add partition uuid into uevent as "PARTUUID" commit: 74f4a8dc0dd8bf337edacb693383911b856f61e3 Best regards, -- Jens Axboe
© 2016 - 2024 Red Hat, Inc.