github.com/avfs/avfs@v0.33.1-0.20240303173310-c6ba67c33eb7/vfs/osfs/osfs_other.go (about)

     1  //
     2  //  Copyright 2022 The AVFS authors
     3  //
     4  //  Licensed under the Apache License, Version 2.0 (the "License");
     5  //  you may not use this file except in compliance with the License.
     6  //  You may obtain a copy of the License at
     7  //
     8  //  	http://www.apache.org/licenses/LICENSE-2.0
     9  //
    10  //  Unless required by applicable law or agreed to in writing, software
    11  //  distributed under the License is distributed on an "AS IS" BASIS,
    12  //  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  //  See the License for the specific language governing permissions and
    14  //  limitations under the License.
    15  //
    16  
    17  //go:build !linux && !windows
    18  
    19  package osfs
    20  
    21  import (
    22  	"io/fs"
    23  	"math"
    24  
    25  	"github.com/avfs/avfs"
    26  )
    27  
    28  // Chroot changes the root to that specified in path.
    29  // If there is an error, it will be of type *PathError.
    30  func (vfs *OsFS) Chroot(path string) error {
    31  	const op = "chroot"
    32  
    33  	return &fs.PathError{Op: op, Path: path, Err: avfs.ErrOpNotPermitted}
    34  }
    35  
    36  // ToSysStat takes a value from fs.FileInfo.Sys() and returns a value that implements interface avfs.SysStater.
    37  func (vfs *OsFS) ToSysStat(info fs.FileInfo) avfs.SysStater {
    38  	return &OtherSysStat{gid: math.MaxInt, uid: math.MaxInt}
    39  }
    40  
    41  // OtherSysStat implements SysStater interface returned by fs.FileInfo.Sys() for non Linux/Windows file system.
    42  type OtherSysStat struct {
    43  	gid int
    44  	uid int
    45  }
    46  
    47  // Gid returns the group id.
    48  func (oss *OtherSysStat) Gid() int {
    49  	return oss.gid
    50  }
    51  
    52  // Uid returns the user id.
    53  func (oss *OtherSysStat) Uid() int {
    54  	return oss.uid
    55  }
    56  
    57  // Nlink returns the number of hard links.
    58  func (oss *OtherSysStat) Nlink() uint64 {
    59  	return 1
    60  }