Skip to content

Commit

Permalink
Merge pull request #583 from rgooch/master
Browse files Browse the repository at this point in the history
More Windoze compile fixes for lib/wsyscall.
  • Loading branch information
rgooch committed Apr 4, 2019
2 parents feb4dc0 + a17e85a commit 74ae41b
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 56 deletions.
15 changes: 0 additions & 15 deletions lib/wsyscall/common.go

This file was deleted.

50 changes: 31 additions & 19 deletions lib/wsyscall/wrappers_darwin.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package wsyscall

import "syscall"
import (
"os"
"syscall"
)

func convertStat(dest *Stat_t, source *syscall.Stat_t) {
dest.Dev = uint64(source.Dev)
Expand All @@ -18,24 +21,6 @@ func convertStat(dest *Stat_t, source *syscall.Stat_t) {
dest.Ctim = source.Ctimespec
}

func fallocate(fd int, mode uint32, off int64, len int64) error {
return syscall.ENOTSUP
}

func lstat(path string, statbuf *Stat_t) error {
var rawStatbuf syscall.Stat_t
if err := syscall.Lstat(path, &rawStatbuf); err != nil {
return err
}
convertStat(statbuf, &rawStatbuf)
return nil
}

func mount(source string, target string, fstype string, flags uintptr,
data string) error {
return syscall.ENOTSUP
}

func getrusage(who int, rusage *Rusage) error {
switch who {
case RUSAGE_CHILDREN:
Expand Down Expand Up @@ -69,6 +54,33 @@ func getrusage(who int, rusage *Rusage) error {
return nil
}

func fallocate(fd int, mode uint32, off int64, len int64) error {
return syscall.ENOTSUP
}

func ioctl(fd int, request, argp uintptr) error {
_, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), request,
argp)
if errno != 0 {
return os.NewSyscallError("ioctl", errno)
}
return nil
}

func lstat(path string, statbuf *Stat_t) error {
var rawStatbuf syscall.Stat_t
if err := syscall.Lstat(path, &rawStatbuf); err != nil {
return err
}
convertStat(statbuf, &rawStatbuf)
return nil
}

func mount(source string, target string, fstype string, flags uintptr,
data string) error {
return syscall.ENOTSUP
}

func setAllGid(gid int) error {
return syscall.Setregid(gid, gid)
}
Expand Down
45 changes: 27 additions & 18 deletions lib/wsyscall/wrappers_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,6 @@ func fallocate(fd int, mode uint32, off int64, len int64) error {
return syscall.Fallocate(fd, mode, off, len)
}

func lstat(path string, statbuf *Stat_t) error {
var rawStatbuf syscall.Stat_t
if err := syscall.Lstat(path, &rawStatbuf); err != nil {
return err
}
convertStat(statbuf, &rawStatbuf)
return nil
}

func mount(source string, target string, fstype string, flags uintptr,
data string) error {
var linuxFlags uintptr
if flags&MS_BIND != 0 {
linuxFlags |= syscall.MS_BIND
}
return syscall.Mount(source, target, fstype, linuxFlags, data)
}

func getrusage(who int, rusage *Rusage) error {
switch who {
case RUSAGE_CHILDREN:
Expand Down Expand Up @@ -83,6 +65,33 @@ func getrusage(who int, rusage *Rusage) error {
return nil
}

func ioctl(fd int, request, argp uintptr) error {
_, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), request,
argp)
if errno != 0 {
return os.NewSyscallError("ioctl", errno)
}
return nil
}

func lstat(path string, statbuf *Stat_t) error {
var rawStatbuf syscall.Stat_t
if err := syscall.Lstat(path, &rawStatbuf); err != nil {
return err
}
convertStat(statbuf, &rawStatbuf)
return nil
}

func mount(source string, target string, fstype string, flags uintptr,
data string) error {
var linuxFlags uintptr
if flags&MS_BIND != 0 {
linuxFlags |= syscall.MS_BIND
}
return syscall.Mount(source, target, fstype, linuxFlags, data)
}

func setAllGid(gid int) error {
return syscall.Setresgid(gid, gid, gid)
}
Expand Down
12 changes: 8 additions & 4 deletions lib/wsyscall/wrappers_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ func fallocate(fd int, mode uint32, off int64, len int64) error {
return syscall.ENOTSUP
}

func lstat(path string, statbuf *Stat_t) error {
func getrusage(who int, rusage *Rusage) error {
return syscall.ENOTSUP
}

func mount(source string, target string, fstype string, flags uintptr,
data string) error {
func ioctl(fd int, request, argp uintptr) error {
return syscall.ENOTSUP
}

func getrusage(who int, rusage *Rusage) error {
func lstat(path string, statbuf *Stat_t) error {
return syscall.ENOTSUP
}

func mount(source string, target string, fstype string, flags uintptr,
data string) error {
return syscall.ENOTSUP
}

Expand Down

0 comments on commit 74ae41b

Please sign in to comment.