feat(aa): add implementation of the new rule methods.
This commit is contained in:
parent
8b24f3521d
commit
0e0f87611a
19 changed files with 380 additions and 2 deletions
|
|
@ -73,6 +73,21 @@ func (m *MountConditions) Merge(other MountConditions) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (m MountConditions) getLenFsType() int {
|
||||
return length("fstype=", m.FsType)
|
||||
}
|
||||
|
||||
func (m MountConditions) getLenOptions() int {
|
||||
return length("options=", m.Options)
|
||||
}
|
||||
|
||||
func (m MountConditions) setPaddings(max []int) []string {
|
||||
return setPaddings(max,
|
||||
[]string{"fstype=", "options="},
|
||||
[]any{m.FsType, m.Options},
|
||||
)
|
||||
}
|
||||
|
||||
type Mount struct {
|
||||
Base
|
||||
Qualifier
|
||||
|
|
@ -168,6 +183,24 @@ func (r *Mount) Merge(other Rule) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (r *Mount) Lengths() []int {
|
||||
return []int{
|
||||
r.Qualifier.getLenAudit(),
|
||||
r.Qualifier.getLenAccess(),
|
||||
r.MountConditions.getLenFsType(),
|
||||
r.MountConditions.getLenOptions(),
|
||||
length("", r.Source),
|
||||
length("", r.MountPoint),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Mount) setPaddings(max []int) {
|
||||
r.Paddings = append(r.Qualifier.setPaddings(max[:2]), r.MountConditions.setPaddings(max[2:4])...)
|
||||
r.Paddings = append(r.Paddings,
|
||||
setPaddings(max[4:], []string{"", ""}, []any{r.Source, r.MountPoint})...,
|
||||
)
|
||||
}
|
||||
|
||||
type Umount struct {
|
||||
Base
|
||||
Qualifier
|
||||
|
|
@ -246,6 +279,23 @@ func (r *Umount) Merge(other Rule) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (r *Umount) Lengths() []int {
|
||||
return []int{
|
||||
r.Qualifier.getLenAudit(),
|
||||
r.Qualifier.getLenAccess(),
|
||||
r.MountConditions.getLenFsType(),
|
||||
r.MountConditions.getLenOptions(),
|
||||
length("", r.MountPoint),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Umount) setPaddings(max []int) {
|
||||
r.Paddings = append(r.Qualifier.setPaddings(max[:2]), r.MountConditions.setPaddings(max[2:4])...)
|
||||
r.Paddings = append(r.Paddings,
|
||||
setPaddings(max[4:], []string{""}, []any{r.MountPoint})...,
|
||||
)
|
||||
}
|
||||
|
||||
type Remount struct {
|
||||
Base
|
||||
Qualifier
|
||||
|
|
@ -324,3 +374,20 @@ func (r *Remount) Merge(other Rule) bool {
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (r *Remount) Lengths() []int {
|
||||
return []int{
|
||||
r.Qualifier.getLenAudit(),
|
||||
r.Qualifier.getLenAccess(),
|
||||
r.MountConditions.getLenFsType(),
|
||||
r.MountConditions.getLenOptions(),
|
||||
length("", r.MountPoint),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Remount) setPaddings(max []int) {
|
||||
r.Paddings = append(r.Qualifier.setPaddings(max[:2]), r.MountConditions.setPaddings(max[2:4])...)
|
||||
r.Paddings = append(r.Paddings,
|
||||
setPaddings(max[4:], []string{""}, []any{r.MountPoint})...,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue