github.com/lovishpuri/go-40569/src@v0.0.0-20230519171745-f8623e7c56cf/os/stat_solaris.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 // These constants aren't in the syscall package, which is frozen. 13 // Values taken from golang.org/x/sys/unix. 14 const ( 15 _S_IFNAM = 0x5000 16 _S_IFDOOR = 0xd000 17 _S_IFPORT = 0xe000 18 ) 19 20 func fillFileStatFromSys(fs *fileStat, name string) { 21 fs.name = basename(name) 22 fs.size = fs.sys.Size 23 fs.modTime = time.Unix(fs.sys.Mtim.Unix()) 24 fs.mode = FileMode(fs.sys.Mode & 0777) 25 switch fs.sys.Mode & syscall.S_IFMT { 26 case syscall.S_IFBLK: 27 fs.mode |= ModeDevice 28 case syscall.S_IFCHR: 29 fs.mode |= ModeDevice | ModeCharDevice 30 case syscall.S_IFDIR: 31 fs.mode |= ModeDir 32 case syscall.S_IFIFO: 33 fs.mode |= ModeNamedPipe 34 case syscall.S_IFLNK: 35 fs.mode |= ModeSymlink 36 case syscall.S_IFREG: 37 // nothing to do 38 case syscall.S_IFSOCK: 39 fs.mode |= ModeSocket 40 case _S_IFNAM, _S_IFDOOR, _S_IFPORT: 41 fs.mode |= ModeIrregular 42 } 43 if fs.sys.Mode&syscall.S_ISGID != 0 { 44 fs.mode |= ModeSetgid 45 } 46 if fs.sys.Mode&syscall.S_ISUID != 0 { 47 fs.mode |= ModeSetuid 48 } 49 if fs.sys.Mode&syscall.S_ISVTX != 0 { 50 fs.mode |= ModeSticky 51 } 52 } 53 54 // For testing. 55 func atime(fi FileInfo) time.Time { 56 return time.Unix(fi.Sys().(*syscall.Stat_t).Atim.Unix()) 57 }