1 //go:build !windows 2 // +build !windows 3 4 /* 5 Copyright The containerd Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 */ 19 20 package continuity 21 22 import ( 23 "fmt" 24 "os" 25 "syscall" 26 ) 27 28 // newBaseResource returns a *resource, populated with data from p and fi, 29 // where p will be populated directly. 30 func newBaseResource(p string, fi os.FileInfo) (*resource, error) { 31 // TODO(stevvooe): This need to be resolved for the container's root, 32 // where here we are really getting the host OS's value. We need to allow 33 // this be passed in and fixed up to make these uid/gid mappings portable. 34 // Either this can be part of the driver or we can achieve it through some 35 // other mechanism. 36 sys, ok := fi.Sys().(*syscall.Stat_t) 37 if !ok { 38 // TODO(stevvooe): This may not be a hard error for all platforms. We 39 // may want to move this to the driver. 40 return nil, fmt.Errorf("unable to resolve syscall.Stat_t from (os.FileInfo).Sys(): %#v", fi) 41 } 42 43 return &resource{ 44 paths: []string{p}, 45 mode: fi.Mode(), 46 47 uid: int64(sys.Uid), 48 gid: int64(sys.Gid), 49 50 // NOTE(stevvooe): Population of shared xattrs field is deferred to 51 // the resource types that populate it. Since they are a property of 52 // the context, they must set there. 53 }, nil 54 } 55