Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows support #4359

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions pkg/osutil/osutil_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,56 @@ package osutil

import (
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"strconv"
"syscall"
)

// ProcessTempDir creates a new temp dir in where and returns its path and an unique index.
// It also cleans up old, unused temp dirs after dead processes.
func ProcessTempDir(where string) (string, error) {
for i := 0; i < 1e3; i++ {
path := filepath.Join(where, fmt.Sprintf("instance-%v", i))
pidfile := filepath.Join(path, ".pid")
err := os.Mkdir(path, DefaultDirPerm)
if os.IsExist(err) {
// Try to clean up.
if cleanupTempDir(path, pidfile) {
i--
}
continue
}
if err != nil {
return "", err
}
if err := WriteFile(pidfile, []byte(strconv.Itoa(syscall.Getpid()))); err != nil {
return "", err
}
return path, nil
}
return "", fmt.Errorf("too many live instances")
}

func cleanupTempDir(path, pidfile string) bool {
data, err := os.ReadFile(pidfile)
if err == nil && len(data) > 0 {
pid, err := strconv.Atoi(string(data))
if err == nil && pid > 1 {
err := exec.Command("taskkill", "/f", "/pid", strconv.Itoa(pid)).Run()
if err == nil {
if os.Remove(pidfile) == nil {
return os.RemoveAll(path) == nil
}
}
}
}
// If err != nil, assume that the pid file is not created yet.
return false
}

func HandleInterrupts(shutdown chan struct{}) {
}

Expand All @@ -32,6 +77,10 @@ func CloseMemMappedFile(f *os.File, mem []byte) error {
return fmt.Errorf("CloseMemMappedFile is not implemented")
}

func LongPipe() (io.ReadCloser, io.WriteCloser, error) {
return nil, nil, fmt.Errorf("LongPipe is not implemented")
}

func ProcessExitStatus(ps *os.ProcessState) int {
return ps.Sys().(syscall.WaitStatus).ExitStatus()
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ var ctors = map[string]fn{
targets.NetBSD: ctorNetbsd,
targets.OpenBSD: ctorOpenbsd,
targets.Fuchsia: ctorFuchsia,
targets.Windows: ctorStub,
targets.Windows: ctorWindows,
}

type config struct {
Expand Down
30 changes: 30 additions & 0 deletions pkg/report/windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2017 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

package report

type windows struct {
*config
}

func ctorWindows(cfg *config) (reporterImpl, []string, error) {
ctx := &windows{
config: cfg,
}
return ctx, nil, nil
}

func (ctx *windows) ContainsCrash(output []byte) bool {
// panic("not implemented")
return false
}

func (ctx *windows) Parse(output []byte) *Report {
// panic("not implemented")
return nil
}

func (ctx *windows) Symbolize(rep *Report) error {
// panic("not implemented")
return nil
}
4 changes: 3 additions & 1 deletion vm/gvisor/gvisor.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
//go:build !windows

Check failure on line 1 in vm/gvisor/gvisor.go

View workflow job for this annotation

GitHub Actions / aux

The file is not formatted/regenerated. Run 'make generate' and include it into the commit.

// Copyright 2018 syzkaller project authors. All rights reserved.

Check failure on line 3 in vm/gvisor/gvisor.go

View workflow job for this annotation

GitHub Actions / build

ST1000: package comment should be of the form "Package gvisor ..."
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

// Package gvisor provides support for gVisor, user-space kernel, testing.
// See https://github.com/google/gvisor
//

Check failure on line 7 in vm/gvisor/gvisor.go

View workflow job for this annotation

GitHub Actions / build

File is not `gofmt`-ed with `-s`
package gvisor

import (
Expand Down
8 changes: 8 additions & 0 deletions vm/gvisor/gvisor_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:build windows

Check failure on line 1 in vm/gvisor/gvisor_windows.go

View workflow job for this annotation

GitHub Actions / aux

The file is not formatted/regenerated. Run 'make generate' and include it into the commit.

// Copyright 2018 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// Package gvisor provides support for gVisor, user-space kernel, testing.
// See https://github.com/google/gvisor
//
package gvisor
Loading
Loading