github.com/lovishpuri/go-40569/src@v0.0.0-20230519171745-f8623e7c56cf/os/stat_openbsd.go (about) 1 // Copyright 2009 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package os 6 7 import ( 8 "syscall" 9 "time" 10 ) 11 12 func fillFileStatFromSys(fs *fileStat, name string) { 13 fs.name = basename(name) 14 fs.size = fs.sys.Size 15 fs.modTime = time.Unix(fs.sys.Mtim.Unix()) 16 fs.mode = FileMode(fs.sys.Mode & 0777) 17 switch fs.sys.Mode & syscall.S_IFMT { 18 case syscall.S_IFBLK: 19 fs.mode |= ModeDevice 20 case syscall.S_IFCHR: 21 fs.mode |= ModeDevice | ModeCharDevice 22 case syscall.S_IFDIR: 23 fs.mode |= ModeDir 24 case syscall.S_IFIFO: 25 fs.mode |= ModeNamedPipe 26 case syscall.S_IFLNK: 27 fs.mode |= ModeSymlink 28 case syscall.S_IFREG: 29 // nothing to do 30 case syscall.S_IFSOCK: 31 fs.mode |= ModeSocket 32 } 33 if fs.sys.Mode&syscall.S_ISGID != 0 { 34 fs.mode |= ModeSetgid 35 } 36 if fs.sys.Mode&syscall.S_ISUID != 0 { 37 fs.mode |= ModeSetuid 38 } 39 if fs.sys.Mode&syscall.S_ISVTX != 0 { 40 fs.mode |= ModeSticky 41 } 42 } 43 44 // For testing. 45 func atime(fi FileInfo) time.Time { 46 return time.Unix(fi.Sys().(*syscall.Stat_t).Atim.Unix()) 47 }