Files
Reims-Go/internal/host/stubs_system_other.go
T
千川白浪 107a8d73e0 refactor: 收拢核心管线、强化错误处理、优化热路径与更新体积 (#200)
* refactor: 收拢核心管线、强化错误处理、优化热路径与更新体积

* fix: preserve download recovery and bound PBZX decoding

Keep VM diagnostics available during plugin initialization failures and verify settings through the unified driver lifecycle.
2026-12-05 20:54:41 +08:00

96 lines
2.8 KiB
Go

//go:build !windows
package host
import (
"context"
"errors"
"fmt"
"os"
"os/exec"
"runtime"
"strings"
"time"
)
// HideConsole does nothing: only Windows opens console windows.
func HideConsole(*exec.Cmd) {}
func probeDefenderRealtime() bool { return false }
func OpenWindowsSecurityExclusions() error {
return errors.New("Windows Security is only available on Windows")
}
// RunElevatedAction is only available on Windows.
func RunElevatedAction(_ context.Context, action, _ string) (ElevationResult, error) {
if _, ok := LookupElevationAction(action); !ok {
return ElevationResult{Action: action}, fmt.Errorf("unsupported elevation action %q", action)
}
return ElevationResult{Action: action}, fmt.Errorf("elevated actions are a Windows feature (current OS: %s)", runtime.GOOS)
}
func currentBootSession() bootSession { return bootSession{} }
func SetHypervisorBootElevated(_ context.Context, _ bool) error {
return fmt.Errorf("hypervisor boot configuration is only supported on Windows (current OS: %s)", runtime.GOOS)
}
func OpenWindowsCoreIsolation() error {
return fmt.Errorf("Windows Security Core Isolation is only available on Windows (current OS: %s)", runtime.GOOS)
}
// OpenFolder shows dir in the platform file manager (dev/preview hosts only).
func OpenFolder(dir string) error {
info, err := os.Stat(dir)
if err != nil {
return err
}
if !info.IsDir() {
return fmt.Errorf("not a directory: %s", dir)
}
opener := "xdg-open"
if runtime.GOOS == "darwin" {
opener = "open"
}
return exec.Command(opener, dir).Start()
}
// ErrOtherProcess: the PID now names a process other than the one expected.
var ErrOtherProcess = errors.New("pid belongs to another process")
// WaitProcessExit is not implemented off Windows; callers fall back to polling.
func WaitProcessExit(ctx context.Context, pid uint32, imageSuffix string) error {
return errors.ErrUnsupported
}
func ApplyQEMUASLR(_, _ string) error { return errors.New("QEMU ASLR requires Windows") }
func SyncQEMUASLR(ctx context.Context, _, _ string) error { return ctx.Err() }
// ErrElevationDeclined: the person said no at the UAC prompt.
var ErrElevationDeclined = errors.New("UAC prompt declined")
func probeProcessorScheduling() string { return "" }
func OpenPerformanceOptionsElevated() error {
return fmt.Errorf("processor scheduling is a Windows setting (current OS: %s)", runtime.GOOS)
}
func DetectHostTimezone() string {
if tz := os.Getenv("TZ"); tz != "Local" && ValidateIANATimezone(tz) {
return tz
}
if link, err := os.Readlink("/etc/localtime"); err == nil {
if _, tz, ok := strings.Cut("/"+link, "/zoneinfo/"); ok && ValidateIANATimezone(tz) {
return tz
}
}
if tz := time.Now().Location().String(); tz != "Local" && ValidateIANATimezone(tz) {
return tz
}
return ""
}
func ProcessCPUTime(pid uint32) (time.Duration, bool) { return 0, false }