Skip to content
Open
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
5 changes: 5 additions & 0 deletions oci2disk/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ func Write(sourceImage, destinationDevice string, compressed bool) error {

resolver := docker.NewResolver(opts)

// Check that the destination device exists before attempting to open it.
if _, err := os.Stat(destinationDevice); err != nil {
return fmt.Errorf("destination device %s does not exist", destinationDevice)
}

fileOut, err := os.OpenFile(destinationDevice, os.O_CREATE|os.O_WRONLY, 0o644)
if err != nil {
return err
Expand Down