From aa19e60ea64a8e54b18fdd10a46332d500addbba Mon Sep 17 00:00:00 2001 From: pierre Date: Tue, 21 May 2024 14:08:12 +0200 Subject: [PATCH] disk: add Disk.Close() Fixes #150. --- disk/disk.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/disk/disk.go b/disk/disk.go index 08c7dfe1..ad16e068 100644 --- a/disk/disk.go +++ b/disk/disk.go @@ -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 +}