@@ -350,14 +350,14 @@ func findPartition(mountIdType imagecustomizerapi.MountIdentifierType, mountId s
350
350
func findExtendedPartition (mountIdType ExtendedMountIdentifierType , mountId string ,
351
351
partitions []diskutils.PartitionInfo , buildDir string ,
352
352
) (diskutils.PartitionInfo , int , error ) {
353
- var devUuid string
353
+ var devPartUuid string
354
354
if mountIdType == ExtendedMountIdentifierTypeDev {
355
355
var err error
356
- devUuid , err = convertDevToUuid (partitions , buildDir )
356
+ devPartUuid , err = convertDevToPartUuid (partitions , buildDir )
357
357
if err != nil {
358
358
return diskutils.PartitionInfo {}, 0 , err
359
359
}
360
- mountId = devUuid
360
+ mountId = devPartUuid
361
361
mountIdType = ExtendedMountIdentifierTypePartUuid
362
362
}
363
363
@@ -392,7 +392,7 @@ func findExtendedPartition(mountIdType ExtendedMountIdentifierType, mountId stri
392
392
return partition , partitionIndex , nil
393
393
}
394
394
395
- func convertDevToUuid (partitions []diskutils.PartitionInfo , buildDir string ) (string , error ) {
395
+ func convertDevToPartUuid (partitions []diskutils.PartitionInfo , buildDir string ) (string , error ) {
396
396
for _ , partition := range partitions {
397
397
matches , err := checkExtendedDevPartition (partition , partitions , buildDir )
398
398
if err != nil {
@@ -413,12 +413,21 @@ func checkExtendedDevPartition(partition diskutils.PartitionInfo, partitions []d
413
413
return false , err
414
414
}
415
415
416
- verityPartUUID , err := extractVerityRootPartUUID (cmdline )
416
+ mountIdType , verityPartitionId , err := extractVerityRootPartitionId (cmdline )
417
417
if err != nil {
418
418
return false , err
419
419
}
420
420
421
- return partition .PartUuid == verityPartUUID , nil
421
+ switch mountIdType {
422
+ case ExtendedMountIdentifierTypePartUuid :
423
+ return partition .PartUuid == verityPartitionId , nil
424
+ case ExtendedMountIdentifierTypePartLabel :
425
+ return partition .PartLabel == verityPartitionId , nil
426
+ case ExtendedMountIdentifierTypeUuid :
427
+ return partition .Uuid == verityPartitionId , nil
428
+ default :
429
+ return false , fmt .Errorf ("unsupported mount identifier type: (%s)" , mountIdType )
430
+ }
422
431
}
423
432
424
433
func extractKernelCmdline (partitions []diskutils.PartitionInfo , buildDir string ) (string , error ) {
@@ -459,7 +468,7 @@ func extractKernelCmdline(partitions []diskutils.PartitionInfo, buildDir string)
459
468
460
469
err = espPartitionMount .CleanClose ()
461
470
if err != nil {
462
- return "" , fmt .Errorf ("failed to close bootPartitionMount :\n %w" , err )
471
+ return "" , fmt .Errorf ("failed to close espPartitionMount :\n %w" , err )
463
472
}
464
473
465
474
return string (cmdlineContent ), nil
@@ -490,20 +499,36 @@ func extractKernelCmdline(partitions []diskutils.PartitionInfo, buildDir string)
490
499
491
500
err = espPartitionMount .CleanClose ()
492
501
if err != nil {
493
- return "" , fmt .Errorf ("failed to close bootPartitionMount :\n %w" , err )
502
+ return "" , fmt .Errorf ("failed to close espPartitionMount :\n %w" , err )
494
503
}
495
504
496
505
return strings .Join (combinedArgs , " " ), nil
497
506
}
498
507
499
- func extractVerityRootPartUUID (cmdline string ) (string , error ) {
508
+ func extractVerityRootPartitionId (cmdline string ) (ExtendedMountIdentifierType , string , error ) {
500
509
argsParts := strings .Split (cmdline , " " )
501
510
for _ , part := range argsParts {
502
- if strings .HasPrefix (part , "systemd.verity_root_data=PARTUUID=" ) {
503
- return strings .TrimPrefix (part , "systemd.verity_root_data=PARTUUID=" ), nil
511
+ if strings .HasPrefix (part , "systemd.verity_root_data=" ) {
512
+ identifier := strings .TrimPrefix (part , "systemd.verity_root_data=" )
513
+
514
+ key , value , found := strings .Cut (identifier , "=" )
515
+ if ! found {
516
+ return ExtendedMountIdentifierTypeDefault , "" , fmt .Errorf ("invalid identifier format in kernel cmdline: %s" , identifier )
517
+ }
518
+
519
+ switch key {
520
+ case "PARTUUID" :
521
+ return ExtendedMountIdentifierTypePartUuid , value , nil
522
+ case "PARTLABEL" :
523
+ return ExtendedMountIdentifierTypePartLabel , value , nil
524
+ case "UUID" :
525
+ return ExtendedMountIdentifierTypeUuid , value , nil
526
+ default :
527
+ return ExtendedMountIdentifierTypeDefault , "" , fmt .Errorf ("unsupported identifier type in kernel cmdline: %s" , identifier )
528
+ }
504
529
}
505
530
}
506
- return "" , fmt .Errorf ("no verity root PARTUUID found in kernel command-line" )
531
+ return ExtendedMountIdentifierTypeDefault , "" , fmt .Errorf ("no verity root identifier found in kernel command-line" )
507
532
}
508
533
509
534
func parseSourcePartition (source string ) (imagecustomizerapi.MountIdentifierType , string , error ) {
0 commit comments