Add symlink follow into unmount util.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
@@ -40,18 +40,19 @@ type CalledDetail struct {
|
||||
// of the real call.
|
||||
type FakeOS struct {
|
||||
sync.Mutex
|
||||
MkdirAllFn func(string, os.FileMode) error
|
||||
RemoveAllFn func(string) error
|
||||
OpenFifoFn func(context.Context, string, int, os.FileMode) (io.ReadWriteCloser, error)
|
||||
StatFn func(string) (os.FileInfo, error)
|
||||
ResolveSymbolicLinkFn func(string) (string, error)
|
||||
CopyFileFn func(string, string, os.FileMode) error
|
||||
WriteFileFn func(string, []byte, os.FileMode) error
|
||||
MountFn func(source string, target string, fstype string, flags uintptr, data string) error
|
||||
UnmountFn func(target string, flags int) error
|
||||
LookupMountFn func(path string) (containerdmount.Info, error)
|
||||
calls []CalledDetail
|
||||
errors map[string]error
|
||||
MkdirAllFn func(string, os.FileMode) error
|
||||
RemoveAllFn func(string) error
|
||||
OpenFifoFn func(context.Context, string, int, os.FileMode) (io.ReadWriteCloser, error)
|
||||
StatFn func(string) (os.FileInfo, error)
|
||||
ResolveSymbolicLinkFn func(string) (string, error)
|
||||
FollowSymlinkInScopeFn func(string, string) (string, error)
|
||||
CopyFileFn func(string, string, os.FileMode) error
|
||||
WriteFileFn func(string, []byte, os.FileMode) error
|
||||
MountFn func(source string, target string, fstype string, flags uintptr, data string) error
|
||||
UnmountFn func(target string, flags int) error
|
||||
LookupMountFn func(path string) (containerdmount.Info, error)
|
||||
calls []CalledDetail
|
||||
errors map[string]error
|
||||
}
|
||||
|
||||
var _ osInterface.OS = &FakeOS{}
|
||||
@@ -176,6 +177,19 @@ func (f *FakeOS) ResolveSymbolicLink(path string) (string, error) {
|
||||
return path, nil
|
||||
}
|
||||
|
||||
// FollowSymlinkInScope is a fake call that invokes FollowSymlinkInScope or returns its input
|
||||
func (f *FakeOS) FollowSymlinkInScope(path, scope string) (string, error) {
|
||||
f.appendCalls("FollowSymlinkInScope", path, scope)
|
||||
if err := f.getError("FollowSymlinkInScope"); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if f.FollowSymlinkInScopeFn != nil {
|
||||
return f.FollowSymlinkInScopeFn(path, scope)
|
||||
}
|
||||
return path, nil
|
||||
}
|
||||
|
||||
// CopyFile is a fake call that invokes CopyFileFn or just return nil.
|
||||
func (f *FakeOS) CopyFile(src, dest string, perm os.FileMode) error {
|
||||
f.appendCalls("CopyFile", src, dest, perm)
|
||||
|
||||
Reference in New Issue
Block a user