Skip to content

Commit

Permalink
Merge pull request #1717 from katiewasnothere/kabaldau/add_back_ext4_…
Browse files Browse the repository at this point in the history
…formatting

Add code to format disk as ext4 in guest
  • Loading branch information
katiewasnothere committed Apr 19, 2023
2 parents 792a588 + daa723f commit 1143934
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions internal/guest/storage/ext4/format.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//go:build linux
// +build linux

package ext4

import (
"context"
"fmt"
"os/exec"
)

// mkfsExt4Command runs mkfs.ext4 with the provided arguments
func mkfsExt4Command(args []string) error {
cmd := exec.Command("mkfs.ext4", args...)
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("failed to execute mkfs.ext4: %s: %w", string(output), err)
}
return nil
}
func FormatExt4(ctx context.Context, source string) error {
// Format source as ext4
if err := mkfsExt4Command([]string{source}); err != nil {
return fmt.Errorf("mkfs.ext4 failed to format %s: %w", source, err)
}
return nil
}

0 comments on commit 1143934

Please sign in to comment.