github.com/opencontainers/umoci@v0.4.8-0.20240508124516-656e4836fb0d/pkg/fseval/fseval.go (about)

     1  /*
     2   * umoci: Umoci Modifies Open Containers' Images
     3   * Copyright (C) 2016-2020 SUSE LLC
     4   *
     5   * Licensed under the Apache License, Version 2.0 (the "License");
     6   * you may not use this file except in compliance with the License.
     7   * You may obtain a copy of the License at
     8   *
     9   *    http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  
    18  package fseval
    19  
    20  import (
    21  	"os"
    22  	"path/filepath"
    23  	"time"
    24  
    25  	"github.com/vbatts/go-mtree"
    26  	"golang.org/x/sys/unix"
    27  )
    28  
    29  // FsEval is a super-interface that implements everything required for
    30  // mtree.FsEval as well as including all of the imporant os.* wrapper functions
    31  // needed for "oci/layers".tarExtractor.
    32  type FsEval interface {
    33  	// We inherit all of the base methods from mtree.FsEval.
    34  	mtree.FsEval
    35  
    36  	// Create is equivalent to os.Create.
    37  	Create(path string) (*os.File, error)
    38  
    39  	// Lstatx is equivalent to unix.Lstat.
    40  	Lstatx(path string) (unix.Stat_t, error)
    41  
    42  	// Readlink is equivalent to os.Readlink.
    43  	Readlink(path string) (string, error)
    44  
    45  	// Symlink is equivalent to os.Symlink.
    46  	Symlink(linkname, path string) error
    47  
    48  	// Link is equivalent to os.Link.
    49  	Link(linkname, path string) error
    50  
    51  	// Chmod is equivalent to os.Chmod.
    52  	Chmod(path string, mode os.FileMode) error
    53  
    54  	// Lutimes is equivalent to os.Lutimes.
    55  	Lutimes(path string, atime, mtime time.Time) error
    56  
    57  	// RemoveAll is equivalent to os.RemoveAll.
    58  	RemoveAll(path string) error
    59  
    60  	// MkdirAll is equivalent to os.MkdirAll.
    61  	MkdirAll(path string, perm os.FileMode) error
    62  
    63  	// Mknod is equivalent to unix.Mknod.
    64  	Mknod(path string, mode os.FileMode, dev uint64) error
    65  
    66  	// Llistxattr is equivalent to system.Llistxattr
    67  	Llistxattr(path string) ([]string, error)
    68  
    69  	// Lremovexattr is equivalent to system.Lremovexattr
    70  	Lremovexattr(path, name string) error
    71  
    72  	// Lsetxattr is equivalent to system.Lsetxattr
    73  	Lsetxattr(path, name string, value []byte, flags int) error
    74  
    75  	// Lgetxattr is equivalent to system.Lgetxattr
    76  	Lgetxattr(path string, name string) ([]byte, error)
    77  
    78  	// Lclearxattrs is equivalent to system.Lclearxattrs
    79  	Lclearxattrs(path string, except map[string]struct{}) error
    80  
    81  	// Walk is equivalent to filepath.Walk.
    82  	Walk(root string, fn filepath.WalkFunc) error
    83  }