summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-mmap/stat_freebsd.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/codeberg.org/gruf/go-mmap/stat_freebsd.go')
-rw-r--r--vendor/codeberg.org/gruf/go-mmap/stat_freebsd.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/vendor/codeberg.org/gruf/go-mmap/stat_freebsd.go b/vendor/codeberg.org/gruf/go-mmap/stat_freebsd.go
new file mode 100644
index 000000000..271ca30e8
--- /dev/null
+++ b/vendor/codeberg.org/gruf/go-mmap/stat_freebsd.go
@@ -0,0 +1,49 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package mmap
+
+import (
+ "os"
+ "path"
+ "syscall"
+ "time"
+)
+
+func fillFileStatFromSys(fs *fileStat, name string) {
+ fs.name = path.Base(name)
+ fs.size = fs.sys.Size
+ fs.modTime = time.Unix(fs.sys.Mtimespec.Unix())
+ fs.mode = os.FileMode(fs.sys.Mode & 0777)
+ switch fs.sys.Mode & syscall.S_IFMT {
+ case syscall.S_IFBLK:
+ fs.mode |= os.ModeDevice
+ case syscall.S_IFCHR:
+ fs.mode |= os.ModeDevice | os.ModeCharDevice
+ case syscall.S_IFDIR:
+ fs.mode |= os.ModeDir
+ case syscall.S_IFIFO:
+ fs.mode |= os.ModeNamedPipe
+ case syscall.S_IFLNK:
+ fs.mode |= os.ModeSymlink
+ case syscall.S_IFREG:
+ // nothing to do
+ case syscall.S_IFSOCK:
+ fs.mode |= os.ModeSocket
+ }
+ if fs.sys.Mode&syscall.S_ISGID != 0 {
+ fs.mode |= os.ModeSetgid
+ }
+ if fs.sys.Mode&syscall.S_ISUID != 0 {
+ fs.mode |= os.ModeSetuid
+ }
+ if fs.sys.Mode&syscall.S_ISVTX != 0 {
+ fs.mode |= os.ModeSticky
+ }
+}
+
+// For testing.
+func atime(fi os.FileInfo) time.Time {
+ return time.Unix(fi.Sys().(*syscall.Stat_t).Atimespec.Unix())
+}