Skip to content

Commit

Permalink
fix: make Talos work on Rockpi 4c boards again
Browse files Browse the repository at this point in the history
Suppress `efivars` `ENODEV` errors: skip mount and proceed with boot
sequence.

Signed-off-by: Artem Chernyshev <artem.chernyshev@talos-systems.com>
(cherry picked from commit ffa5e05)
  • Loading branch information
Unix4ever authored and smira committed Nov 8, 2023
1 parent 6fd9a71 commit 61413ed
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions internal/pkg/mount/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package mount
import (
"bufio"
"context"
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -67,6 +68,14 @@ func mountMountpoint(mountpoint *Point) (skipMount bool, err error) {

if !skipMount {
if err = mountpoint.Mount(); err != nil {
if mountpoint.MountFlags.Check(SkipIfNoDevice) && errors.Is(err, unix.ENODEV) {
if mountpoint.Logger != nil {
mountpoint.Logger.Printf("error mounting: %q: %s", mountpoint.Source(), err)
}

return true, nil
}

return false, fmt.Errorf("error mounting: %w", err)
}
}
Expand Down
2 changes: 2 additions & 0 deletions internal/pkg/mount/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const (
SkipIfMounted
// SkipIfNoFilesystem is a flag for skipping formatting and mounting if the mountpoint has not filesystem.
SkipIfNoFilesystem
// SkipIfNoDevice is a flag for skipping errors when the device is not found.
SkipIfNoDevice
)

// Flags is the mount flags.
Expand Down
4 changes: 3 additions & 1 deletion internal/pkg/mount/pseudo.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ func PseudoSubMountPoints() (mountpoints *Points, err error) {

if _, err := os.Stat(constants.EFIVarsMountPoint); err == nil {
// mount EFI vars if they exist
pseudo.Set("efivars", NewMountPoint("efivarfs", constants.EFIVarsMountPoint, "efivarfs", unix.MS_NOSUID|unix.MS_NOEXEC|unix.MS_NODEV|unix.MS_RELATIME|unix.MS_RDONLY, ""))
pseudo.Set("efivars", NewMountPoint("efivarfs", constants.EFIVarsMountPoint, "efivarfs", unix.MS_NOSUID|unix.MS_NOEXEC|unix.MS_NODEV|unix.MS_RELATIME|unix.MS_RDONLY, "",
WithFlags(SkipIfNoDevice),
))
}

return pseudo, nil
Expand Down

0 comments on commit 61413ed

Please sign in to comment.