Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
lima-vm
GitHub Repository: lima-vm/lima
Path: blob/master/pkg/osutil/osutil_windows.go
2604 views
1
// SPDX-FileCopyrightText: Copyright The Lima Authors
2
// SPDX-License-Identifier: Apache-2.0
3
4
package osutil
5
6
import (
7
"context"
8
"errors"
9
"fmt"
10
"io/fs"
11
"os"
12
"syscall"
13
14
"golang.org/x/sys/windows"
15
)
16
17
// UnixPathMax is the value of UNIX_PATH_MAX.
18
const UnixPathMax = 108
19
20
// Stat is a selection of syscall.Stat_t.
21
type Stat struct {
22
Uid uint32
23
Gid uint32
24
}
25
26
func SysStat(_ fs.FileInfo) (Stat, bool) {
27
return Stat{Uid: 0, Gid: 0}, false
28
}
29
30
// SigInt is the value of SIGINT.
31
const SigInt = Signal(2)
32
33
// SigKill is the value of SIGKILL.
34
const SigKill = Signal(9)
35
36
type Signal int
37
38
func SysKill(pid int, _ Signal) error {
39
return windows.GenerateConsoleCtrlEvent(syscall.CTRL_BREAK_EVENT, uint32(pid))
40
}
41
42
func Dup2(_ int, _ syscall.Handle) error {
43
return errors.New("unimplemented")
44
}
45
46
func SignalName(sig os.Signal) string {
47
switch sig {
48
case syscall.SIGINT:
49
return "SIGINT"
50
case syscall.SIGTERM:
51
return "SIGTERM"
52
default:
53
return fmt.Sprintf("Signal(%d)", sig)
54
}
55
}
56
57
func Sysctl(_ context.Context, _ string) (string, error) {
58
return "", errors.New("sysctl: unimplemented on Windows")
59
}
60
61
func IsEACCES(err error) bool {
62
return errors.Is(err, syscall.ERROR_ACCESS_DENIED) || errors.Is(err, syscall.WSAEACCES)
63
}
64
65