ditro/rhel86: set volid like in rhel9.0

This is only required in RHEL9.0, but best practice is to always pin these things
down. Also increases uniformity between distros.

Simplify a bit the volid generator by making it require `rand.Rand` rather than
`io.Reader`, and hence eliminating the need for error handling.
This commit is contained in:
Tom Gundersen 2022-02-27 18:20:15 +00:00
parent 154e966cda
commit 973b5141b3
7 changed files with 18 additions and 22 deletions

View file

@ -151,10 +151,13 @@ func newRandomUUIDFromReader(r io.Reader) (uuid.UUID, error) {
return id, nil
}
// NewRandomVolIDFromReader creates a random 32 bit hex string to use as a
// NewVolIDFromRand creates a random 32 bit hex string to use as a
// volume ID for FAT filesystems
func NewRandomVolIDFromReader(r io.Reader) (string, error) {
func NewVolIDFromRand(r *rand.Rand) string {
volid := make([]byte, 4)
_, err := r.Read(volid)
return hex.EncodeToString(volid), err
len, _ := r.Read(volid)
if len != 4 {
panic("expected four random bytes")
}
return hex.EncodeToString(volid)
}