]> Cypherpunks repositories - gostls13.git/commitdiff
os: add support for openbsd
authorJoel Sing <jsing@google.com>
Mon, 8 Aug 2011 13:56:36 +0000 (09:56 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 8 Aug 2011 13:56:36 +0000 (09:56 -0400)
R=rsc
CC=golang-dev
https://golang.org/cl/4798061

src/pkg/os/Makefile
src/pkg/os/stat_openbsd.go [new file with mode: 0644]

index 354e1e8db5977e48ccd237cb451c8cf254ea8033..8923a8b480237c8ccfae794b1da40c8a8952fa1c 100644 (file)
@@ -53,6 +53,18 @@ GOFILES_linux=\
        exec_unix.go\
        signal_unix.go\
 
+GOFILES_openbsd=\
+       dir_unix.go\
+       error_posix.go\
+       env_unix.go\
+       file_posix.go\
+       file_unix.go\
+       path_unix.go\
+       sys_bsd.go\
+       exec_posix.go\
+       exec_unix.go\
+       signal_unix.go\
+
 GOFILES_windows=\
        dir_windows.go\
        error_posix.go\
diff --git a/src/pkg/os/stat_openbsd.go b/src/pkg/os/stat_openbsd.go
new file mode 100644 (file)
index 0000000..6d3a381
--- /dev/null
@@ -0,0 +1,32 @@
+// 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 os
+
+import "syscall"
+
+func isSymlink(stat *syscall.Stat_t) bool {
+       return stat.Mode&syscall.S_IFMT == syscall.S_IFLNK
+}
+
+func fileInfoFromStat(name string, fi *FileInfo, lstat, stat *syscall.Stat_t) *FileInfo {
+       fi.Dev = uint64(stat.Dev)
+       fi.Ino = uint64(stat.Ino)
+       fi.Nlink = uint64(stat.Nlink)
+       fi.Mode = uint32(stat.Mode)
+       fi.Uid = int(stat.Uid)
+       fi.Gid = int(stat.Gid)
+       fi.Rdev = uint64(stat.Rdev)
+       fi.Size = int64(stat.Size)
+       fi.Blksize = int64(stat.Blksize)
+       fi.Blocks = stat.Blocks
+       fi.Atime_ns = syscall.TimespecToNsec(stat.Atim)
+       fi.Mtime_ns = syscall.TimespecToNsec(stat.Mtim)
+       fi.Ctime_ns = syscall.TimespecToNsec(stat.Ctim)
+       fi.Name = basename(name)
+       if isSymlink(lstat) && !isSymlink(stat) {
+               fi.FollowedSymlink = true
+       }
+       return fi
+}