Skip to content

Commit

Permalink
actions/image-partition: check label length in verify stage
Browse files Browse the repository at this point in the history
The partition name (label) can be up to 11 characters long for vfat and 16 characters long for ext3/4.

When partition label length is longer than 11 characters for vfat, it fails with below message,
==== image-partition ====
2021/07/23 06:14:35 cmdline: [mkfs.vfat -F32 -n efi456789012 /dev/vda1]
2021/07/23 06:14:35 Formatting partition 1 | mkfs.vfat: Label can be no longer than 11 characters
2021/07/23 06:14:35 Formatting partition 1 | mkfs.fat 4.2 (2021-01-31)
2021/07/23 06:14:35 Action `image-partition` failed at stage Run, error: exit status 1

When partition label length is longer than 11 characters for ext3/4, it shows the below warning message,
2021/07/23 06:05:49 cmdline: [mkfs.ext4 -L root567890123456789 /dev/vda2]
2021/07/23 06:05:49 Formatting partition 2 | Warning: label too long; will be truncated to 'root567890123456'

This commit checks the label length for all partition types in verify action and exits if it is longer than
the above values.

Signed-off-by: Vignesh Raman <[email protected]>
  • Loading branch information
vigneshraman committed Jul 23, 2021
1 parent c66a48d commit 3e00257
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions actions/image_partition_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,20 @@ func (i *ImagePartitionAction) Verify(context *debos.DebosContext) error {

for pidx, _ := range i.Partitions {
p := &i.Partitions[pidx]
var partNameLen int

if m.Partition == p.Name {
switch p.FS {
case "vfat":
partNameLen = 11
case "ext3", "ext4":
partNameLen = 16
}

if len(p.Name) > partNameLen {
return fmt.Errorf("incorrect partition name '%s', should be less than %d characters for '%s'", p.Name, partNameLen, p.FS)
}

m.part = p
break
}
Expand Down

0 comments on commit 3e00257

Please sign in to comment.