diff --git a/copy/copy_openbsd.go b/copy/copy_openbsd.go new file mode 100644 index 00000000..18cd438f --- /dev/null +++ b/copy/copy_openbsd.go @@ -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) +} diff --git a/copy/copy_unix.go b/copy/copy_unix.go index e90a41d3..cb41247a 100644 --- a/copy/copy_unix.go +++ b/copy/copy_unix.go @@ -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 diff --git a/copy/stat_bsd.go b/copy/stat_bsd.go index 362142de..439574c0 100644 --- a/copy/stat_bsd.go +++ b/copy/stat_bsd.go @@ -1,4 +1,4 @@ -// +build darwin freebsd netbsd openbsd +// +build darwin freebsd netbsd package fs diff --git a/copy/stat_openbsd.go b/copy/stat_openbsd.go new file mode 100644 index 00000000..bfdf837e --- /dev/null +++ b/copy/stat_openbsd.go @@ -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 +}