Skip to content

Commit

Permalink
Merge pull request #214 from pierrec/disk-close
Browse files Browse the repository at this point in the history
disk: add Disk.Close()
  • Loading branch information
deitch authored May 22, 2024
2 parents fea53b0 + aa19e60 commit 13e86ff
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions disk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,12 @@ func (d *Disk) GetFilesystem(part int) (filesystem.FileSystem, error) {
}
return nil, fmt.Errorf("unknown filesystem on partition %d", part)
}

// Close the disk. Once successfully closed, it can no longer be used.
func (d *Disk) Close() error {
if err := d.File.Close(); err != nil {
return err
}
*d = Disk{}
return nil
}

0 comments on commit 13e86ff

Please sign in to comment.