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
This commit is contained in:
Douglas Anderson 2024-10-16 13:51:44 -07:00
parent 519d3f8b36
commit e53e50e3fa
2 changed files with 5 additions and 1 deletions

View file

@ -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;

View file

@ -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 << " }";
}
}