disk: new interface UniqueEntity for Entities with UUID
This is for all entities that have a uniquely identifiable via a UUID. Currently the interface only contains a single function, GenUUID(), that should generate a new UUID via a random source (`rand.Rand`). NB: Partitions are uniquely identifiable if and only if the layout is GPT. Co-Authored-By: Achilleas Koutsou <achilleas@koutsou.net>
This commit is contained in:
parent
126c23cb13
commit
b0899c5c59
5 changed files with 55 additions and 5 deletions
|
|
@ -19,6 +19,7 @@ package disk
|
|||
import (
|
||||
"encoding/hex"
|
||||
"io"
|
||||
"math/rand"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
|
@ -102,6 +103,14 @@ type VolumeContainer interface {
|
|||
CreateVolume(mountpoint string, size uint64) (Entity, error)
|
||||
}
|
||||
|
||||
// A UniqueEntity is an entity that can be uniquely identified via a UUID.
|
||||
//
|
||||
// GenUUID generates a UUID for the entity if it does not yet have one.
|
||||
type UniqueEntity interface {
|
||||
Entity
|
||||
GenUUID(rng *rand.Rand)
|
||||
}
|
||||
|
||||
// FSSpec for a filesystem (UUID and Label); the first field of fstab(5)
|
||||
type FSSpec struct {
|
||||
UUID string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue