This brings a lot of new stuff, among others: - Internal image types for RHEL-10 (COMPOSER-2357) - Support for Swap partitions in DiskCustomizations (COMPOSER-2400) - Support for new partitioning customizations for CS and RHEL - Fix for RHEL 8 and 9 AMI boot mode (RHEL-69628) Signed-off-by: Tomáš Hozza <thozza@redhat.com>
77 lines
1.3 KiB
Go
77 lines
1.3 KiB
Go
package disk
|
|
|
|
import (
|
|
"math/rand"
|
|
"reflect"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// Swap defines the payload for a swap partition. It's similar to a
|
|
// [Filesystem] but with fewer fields. It is a [PayloadEntity] and also a
|
|
// [FSTabEntity].
|
|
type Swap struct {
|
|
UUID string
|
|
Label string
|
|
|
|
// The fourth field of fstab(5); fs_mntops
|
|
FSTabOptions string
|
|
}
|
|
|
|
func init() {
|
|
payloadEntityMap["swap"] = reflect.TypeOf(Swap{})
|
|
}
|
|
|
|
func (s *Swap) EntityName() string {
|
|
return "swap"
|
|
}
|
|
|
|
func (s *Swap) Clone() Entity {
|
|
if s == nil {
|
|
return nil
|
|
}
|
|
|
|
return &Swap{
|
|
UUID: s.UUID,
|
|
Label: s.Label,
|
|
FSTabOptions: s.FSTabOptions,
|
|
}
|
|
}
|
|
|
|
// For swap, the fs_file entry in the fstab is always "none".
|
|
func (s *Swap) GetFSFile() string {
|
|
return "none"
|
|
}
|
|
|
|
// For swap, the fs_vfstype entry in the fstab is always "swap".
|
|
func (s *Swap) GetFSType() string {
|
|
return "swap"
|
|
}
|
|
|
|
func (s *Swap) GetFSSpec() FSSpec {
|
|
if s == nil {
|
|
return FSSpec{}
|
|
}
|
|
return FSSpec{
|
|
UUID: s.UUID,
|
|
Label: s.Label,
|
|
}
|
|
}
|
|
|
|
// For swap, the Freq and PassNo are always 0.
|
|
func (s *Swap) GetFSTabOptions() (FSTabOptions, error) {
|
|
if s == nil {
|
|
return FSTabOptions{}, nil
|
|
}
|
|
return FSTabOptions{
|
|
MntOps: s.FSTabOptions,
|
|
Freq: 0,
|
|
PassNo: 0,
|
|
}, nil
|
|
}
|
|
|
|
func (s *Swap) GenUUID(rng *rand.Rand) {
|
|
if s.UUID == "" {
|
|
s.UUID = uuid.Must(newRandomUUIDFromReader(rng)).String()
|
|
}
|
|
}
|