Add shim to choose next entry to boot from (#230)

This commit is contained in:
Itxaka
2024-02-21 10:44:32 +01:00
committed by GitHub
parent cce432133e
commit 2e9c85e63a
13 changed files with 775 additions and 19 deletions

View File

@@ -23,6 +23,7 @@ import (
type SyscallInterface interface {
Chroot(string) error
Chdir(string) error
Mount(string, string, string, uintptr, string) error
}
type RealSyscall struct{}
@@ -34,3 +35,6 @@ func (r *RealSyscall) Chroot(path string) error {
func (r *RealSyscall) Chdir(path string) error {
return syscall.Chdir(path)
}
func (r *RealSyscall) Mount(source string, target string, fstype string, flags uintptr, data string) error {
return syscall.Mount(source, target, fstype, flags, data)
}

View File

@@ -44,4 +44,14 @@ var _ = Describe("Syscall", Label("types", "syscall"), func() {
// We need elevated privs to chroot so this should fail
Expect(err).To(BeNil())
})
It("Calling mount on the fake syscall should not fail", func() {
r := v1mock.FakeSyscall{}
err := r.Mount("source", "target", "fstype", 0, "data")
Expect(err).To(BeNil())
})
It("Calling mount on the real syscall fail (wrong args)", func() {
r := v1.RealSyscall{}
err := r.Mount("source", "target", "fstype", 0, "data")
Expect(err).To(HaveOccurred())
})
})