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

Fixed build on OpenBSD #215

Merged
merged 1 commit into from
Nov 1, 2024
Merged
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
38 changes: 38 additions & 0 deletions copy/copy_openbsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//go:build openbsd
// +build openbsd

package fs

import (
"io"
"os"

"github.com/pkg/errors"
"golang.org/x/sys/unix"
)

func copyFile(source, target string) error {
src, err := os.Open(source)
if err != nil {
return errors.Wrapf(err, "failed to open source %s", source)
}
defer src.Close()
tgt, err := os.Create(target)
if err != nil {
return errors.Wrapf(err, "failed to open target %s", target)
}
defer tgt.Close()

return copyFileContent(tgt, src)
}

func copyFileContent(dst, src *os.File) error {
buf := bufferPool.Get().(*[]byte)
_, err := io.CopyBuffer(dst, src, *buf)
bufferPool.Put(buf)
return err
}

func mknod(dst string, mode uint32, rDev int) error {
return unix.Mknod(dst, uint32(mode), rDev)
}
4 changes: 2 additions & 2 deletions copy/copy_unix.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build solaris || darwin || freebsd
// +build solaris darwin freebsd
//go:build solaris || darwin || freebsd || openbsd
// +build solaris darwin freebsd openbsd

package fs

Expand Down
2 changes: 1 addition & 1 deletion copy/stat_bsd.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build darwin freebsd netbsd openbsd
// +build darwin freebsd netbsd

package fs

Expand Down
17 changes: 17 additions & 0 deletions copy/stat_openbsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// +build openbsd

package fs

import (
"syscall"
)

// Returns the last-accessed time
func StatAtime(st *syscall.Stat_t) syscall.Timespec {
return st.Atim
}

// Returns the last-modified time
func StatMtime(st *syscall.Stat_t) syscall.Timespec {
return st.Mtim
}