github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/pkg/cpio/sysinfo_plan9.go (about) 1 // Copyright 2013-2017 the u-root 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 cpio 6 7 import "syscall" 8 9 func sysInfo(n string, sys *syscall.Dir) Info { 10 // Similar to how the standard library converts Plan 9 Dir to os.FileInfo: 11 // https://github.com/golang/go/blob/go1.16beta1/src/os/stat_plan9.go#L14 12 mode := sys.Mode & 0o777 13 if sys.Mode&syscall.DMDIR != 0 { 14 mode |= modeDir 15 } else { 16 mode |= modeFile 17 } 18 return Info{ 19 Mode: uint64(mode), 20 UID: 0, 21 MTime: uint64(sys.Mtime), 22 FileSize: uint64(sys.Length), 23 Name: n, 24 } 25 }