From e53e50e3fa8e73b86163806d6f8eeb9eadf28bb7 Mon Sep 17 00:00:00 2001 From: Douglas Anderson Date: Wed, 16 Oct 2024 13:51:44 -0700 Subject: [PATCH] init: Add partition_uuid to Uevent As of commit upstream Linux kernel commit 74f4a8dc0dd8 ("block: add partition uuid into uevent as "PARTUUID""), it's easy to include the partition UUID in the Uevent structure. Add it in so that other parts of the init code can make decisions based on the partition UUID. If this code is run on older kernels we'll never see the partition UUID and it will be left blank. Bug: 316324155 Test: Run w/ a newer kernel and see partition_uuid populated. Change-Id: I48a52aa006c05023f7f1cc5cc0ab5c1f1ec37455 --- init/uevent.h | 1 + init/uevent_listener.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/init/uevent.h b/init/uevent.h index dc35fd968..c8ca52aaf 100644 --- a/init/uevent.h +++ b/init/uevent.h @@ -28,6 +28,7 @@ struct Uevent { std::string subsystem; std::string firmware; std::string partition_name; + std::string partition_uuid; std::string device_name; std::string modalias; int partition_num; diff --git a/init/uevent_listener.cpp b/init/uevent_listener.cpp index 5da67777d..97f3de640 100644 --- a/init/uevent_listener.cpp +++ b/init/uevent_listener.cpp @@ -66,6 +66,9 @@ static void ParseEvent(const char* msg, Uevent* uevent) { } else if (!strncmp(msg, "PARTNAME=", 9)) { msg += 9; uevent->partition_name = msg; + } else if (!strncmp(msg, "PARTUUID=", 9)) { + msg += 9; + uevent->partition_uuid = msg; } else if (!strncmp(msg, "DEVNAME=", 8)) { msg += 8; uevent->device_name = msg; @@ -82,7 +85,7 @@ static void ParseEvent(const char* msg, Uevent* uevent) { if (LOG_UEVENTS) { LOG(INFO) << "event { '" << uevent->action << "', '" << uevent->path << "', '" << uevent->subsystem << "', '" << uevent->firmware << "', " << uevent->major - << ", " << uevent->minor << " }"; + << ", " << uevent->minor << ", " << uevent->partition_uuid << " }"; } }