local: fix mac issues in bazel (#1893)

This commit is contained in:
Adrian Stobbe 2023-06-09 10:35:52 +02:00 committed by GitHub
parent 7c345f4503
commit e0fe8e6ca0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 84 additions and 16 deletions

View file

@ -5,6 +5,8 @@ go_library(
name = "setup",
srcs = [
"interface.go",
"mount_cross.go",
"mount_linux.go",
"setup.go",
],
importpath = "github.com/edgelesssys/constellation/v2/disk-mapper/internal/setup",

View file

@ -9,7 +9,6 @@ package setup
import (
"io/fs"
"os"
"syscall"
"github.com/edgelesssys/constellation/v2/internal/cloud/metadata"
)
@ -49,16 +48,6 @@ type RecoveryDoer interface {
// DiskMounter uses the syscall package to mount disks.
type DiskMounter struct{}
// Mount performs a mount syscall.
func (m DiskMounter) Mount(source string, target string, fstype string, flags uintptr, data string) error {
return syscall.Mount(source, target, fstype, flags, data)
}
// Unmount performs an unmount syscall.
func (m DiskMounter) Unmount(target string, flags int) error {
return syscall.Unmount(target, flags)
}
// MkdirAll uses os.MkdirAll to create the directory.
func (m DiskMounter) MkdirAll(path string, perm fs.FileMode) error {
return os.MkdirAll(path, perm)

View file

@ -0,0 +1,22 @@
//go:build !linux
/*
Copyright (c) Edgeless Systems GmbH
SPDX-License-Identifier: AGPL-3.0-only
*/
package setup
import (
"errors"
)
// Mount performs a mount syscall.
func (m DiskMounter) Mount(_ string, _ string, _ string, _ uintptr, _ string) error {
return errors.New("mount not implemented on this platform")
}
// Unmount performs an unmount syscall.
func (m DiskMounter) Unmount(_ string, _ int) error {
return errors.New("mount not implemented on this platform")
}

View file

@ -0,0 +1,22 @@
//go:build linux
/*
Copyright (c) Edgeless Systems GmbH
SPDX-License-Identifier: AGPL-3.0-only
*/
package setup
import (
"syscall"
)
// Mount performs a mount syscall.
func (m DiskMounter) Mount(source string, target string, fstype string, flags uintptr, data string) error {
return syscall.Mount(source, target, fstype, flags, data)
}
// Unmount performs an unmount syscall.
func (m DiskMounter) Unmount(target string, flags int) error {
return syscall.Unmount(target, flags)
}

View file

@ -44,6 +44,7 @@ const (
stateDiskMountPath = "/var/run/state"
cryptsetupOptions = "cipher=aes-xts-plain64,integrity=hmac-sha256"
stateInfoPath = stateDiskMountPath + "/constellation/node_state.json"
msrdonly = 0x1 // same as syscall.MS_RDONLY
)
// Manager handles formatting, mapping, mounting and unmounting of state disks.
@ -95,7 +96,7 @@ func (s *Manager) PrepareExistingDisk(recover RecoveryDoer) error {
}
// we do not care about cleaning up the mount point on error, since any errors returned here should cause a boot failure
if err := s.mounter.Mount(filepath.Join("/dev/mapper/", stateDiskMappedName), stateDiskMountPath, "ext4", syscall.MS_RDONLY, ""); err != nil {
if err := s.mounter.Mount(filepath.Join("/dev/mapper/", stateDiskMappedName), stateDiskMountPath, "ext4", msrdonly, ""); err != nil {
return err
}

View file

@ -1,4 +1,4 @@
//go:build integration && cgo
//go:build integration && cgo && linux
/*
Copyright (c) Edgeless Systems GmbH