Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

actions: image-partition: enable creation of FAT{12|16|32} partitions #491

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions actions/image_partition_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,21 @@ func (i ImagePartitionAction) formatPartition(p *Partition, context debos.DebosC

cmdline := []string{}
switch p.FS {
case "vfat":
cmdline = append(cmdline, "mkfs.vfat", "-F32", "-n", p.Name)
case "fat", "fat12", "fat16", "fat32", "msdos", "vfat":
cmdline = append(cmdline, "mkfs.vfat", "-n", p.Name)

switch p.FS {
case "fat12":
cmdline = append(cmdline, "-F12")
case "fat16":
cmdline = append(cmdline, "-F16")
case "fat32", "msdos", "vfat":
cmdline = append(cmdline, "-F32")
default:
/* let mkfs.vfat autodetermine FAT type */
break
}

if len(p.FSUUID) > 0 {
cmdline = append(cmdline, "-i", p.FSUUID)
}
Expand Down Expand Up @@ -498,7 +511,11 @@ func (i ImagePartitionAction) Run(context *debos.DebosContext) error {

command := []string{"parted", "-a", "none", "-s", "--", context.Image, "mkpart", name}
switch p.FS {
case "vfat":
case "fat16":
command = append(command, "fat16")
case "fat", "fat12", "fat32", "msdos", "vfat":
/* TODO: Not sure if this is correct. Perhaps
fat12 should be treated the same as fat16 ? */
sjoerdsimons marked this conversation as resolved.
Show resolved Hide resolved
command = append(command, "fat32")
case "hfsplus":
command = append(command, "hfs+")
Expand Down Expand Up @@ -753,7 +770,7 @@ func (i *ImagePartitionAction) Verify(context *debos.DebosContext) error {
if err != nil {
return fmt.Errorf("Incorrect UUID %s", p.FSUUID)
}
case "vfat", "fat32":
case "fat", "fat12", "fat16", "fat32", "msdos", "vfat":
_, err := hex.DecodeString(p.FSUUID)
if err != nil || len(p.FSUUID) != 8 {
return fmt.Errorf("Incorrect UUID %s, should be 32-bit hexadecimal number", p.FSUUID)
Expand Down Expand Up @@ -799,10 +816,7 @@ func (i *ImagePartitionAction) Verify(context *debos.DebosContext) error {
return fmt.Errorf("Partition %s missing end", p.Name)
}

switch p.FS {
case "fat32":
p.FS = "vfat"
case "":
if p.FS == "" {
return fmt.Errorf("Partition %s missing fs type", p.Name)
}
}
Expand Down