2015-05-05 15:07:15 +00:00
|
|
|
// +build !linux
|
|
|
|
|
|
|
|
/*
|
2016-06-03 00:25:58 +00:00
|
|
|
Copyright 2014 The Kubernetes Authors.
|
2015-05-05 15:07:15 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2019-04-02 19:19:27 +00:00
|
|
|
package nsenter
|
2015-05-05 15:07:15 +00:00
|
|
|
|
2017-09-08 10:15:03 +00:00
|
|
|
import (
|
|
|
|
"errors"
|
2018-03-05 08:14:44 +00:00
|
|
|
"os"
|
2018-05-22 10:56:26 +00:00
|
|
|
|
2019-01-24 02:32:26 +00:00
|
|
|
"k8s.io/utils/nsenter"
|
2019-04-02 19:19:27 +00:00
|
|
|
|
|
|
|
"k8s.io/kubernetes/pkg/util/mount"
|
2017-09-08 10:15:03 +00:00
|
|
|
)
|
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// Mounter provides the mount.Interface implementation for unsupported
|
|
|
|
// platforms.
|
|
|
|
type Mounter struct{}
|
2015-05-05 15:07:15 +00:00
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// NewMounter returns a new Mounter for the current system
|
|
|
|
func NewMounter(rootDir string, ne *nsenter.Nsenter) *Mounter {
|
|
|
|
return &Mounter{}
|
2015-06-17 20:53:04 +00:00
|
|
|
}
|
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
var _ = mount.Interface(&Mounter{})
|
2015-05-05 15:07:15 +00:00
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// Mount mounts the source to the target. It is a noop for unsupported systems
|
|
|
|
func (*Mounter) Mount(source string, target string, fstype string, options []string) error {
|
2015-05-05 15:07:15 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// Unmount unmounts the target path from the system. it is a noop for unsupported
|
|
|
|
// systems
|
|
|
|
func (*Mounter) Unmount(target string) error {
|
2015-05-05 15:07:15 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// List returns a list of all mounted filesystems. It is a noop for unsupported systems
|
|
|
|
func (*Mounter) List() ([]mount.MountPoint, error) {
|
2019-04-02 19:19:27 +00:00
|
|
|
return []mount.MountPoint{}, nil
|
2017-07-01 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// IsMountPointMatch tests if dir and mp are the same path
|
|
|
|
func (*Mounter) IsMountPointMatch(mp mount.MountPoint, dir string) bool {
|
2017-07-01 20:51:28 +00:00
|
|
|
return (mp.Path == dir)
|
|
|
|
}
|
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// IsLikelyNotMountPoint determines if a directory is not a mountpoint.
|
|
|
|
// It is a noop on unsupported systems
|
|
|
|
func (*Mounter) IsLikelyNotMountPoint(file string) (bool, error) {
|
2015-04-16 23:49:53 +00:00
|
|
|
return true, nil
|
2015-05-05 15:07:15 +00:00
|
|
|
}
|
2016-07-06 17:42:56 +00:00
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// DeviceOpened checks if block device in use. I tis a noop for unsupported systems
|
|
|
|
func (*Mounter) DeviceOpened(pathname string) (bool, error) {
|
2016-07-06 17:42:56 +00:00
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// PathIsDevice checks if pathname refers to a device. It is a noop for unsupported
|
|
|
|
// systems
|
|
|
|
func (*Mounter) PathIsDevice(pathname string) (bool, error) {
|
2016-07-06 17:42:56 +00:00
|
|
|
return true, nil
|
|
|
|
}
|
2016-06-23 19:46:21 +00:00
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// GetDeviceNameFromMount finds the device name from its global mount point using the
|
|
|
|
// given mountpath and plugin location. It is a noop of unsupported platforms
|
|
|
|
func (*Mounter) GetDeviceNameFromMount(mountPath, pluginDir string) (string, error) {
|
2016-06-23 19:46:21 +00:00
|
|
|
return "", nil
|
|
|
|
}
|
2017-08-30 14:45:04 +00:00
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// MakeRShared checks if path is shared and bind-mounts it as rshared if needed.
|
|
|
|
// It is a noop on unsupported platforms
|
|
|
|
func (*Mounter) MakeRShared(path string) error {
|
2017-08-30 14:45:04 +00:00
|
|
|
return nil
|
|
|
|
}
|
2017-09-08 10:15:03 +00:00
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// GetFileType checks for file/directory/socket/block/character devices.
|
|
|
|
// Always returns an error and "fake" filetype on unsupported platforms
|
|
|
|
func (*Mounter) GetFileType(_ string) (mount.FileType, error) {
|
2019-04-02 19:19:27 +00:00
|
|
|
return mount.FileType("fake"), errors.New("not implemented")
|
2017-09-08 10:15:03 +00:00
|
|
|
}
|
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// MakeDir creates a new directory. Noop on unsupported platforms
|
|
|
|
func (*Mounter) MakeDir(pathname string) error {
|
2017-09-08 10:15:03 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// MakeFile creats an empty file. Noop on unsupported platforms
|
|
|
|
func (*Mounter) MakeFile(pathname string) error {
|
2017-09-08 10:15:03 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// ExistsPath checks if pathname exists. Always returns an error on unsupported
|
|
|
|
// platforms
|
|
|
|
func (*Mounter) ExistsPath(pathname string) (bool, error) {
|
2018-05-22 10:56:25 +00:00
|
|
|
return true, errors.New("not implemented")
|
2017-09-08 10:15:03 +00:00
|
|
|
}
|
2018-03-05 08:14:44 +00:00
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// EvalHostSymlinks returns the path name after evaluating symlinks. Always
|
|
|
|
// returns an error on unsupported platforms
|
|
|
|
func (*Mounter) EvalHostSymlinks(pathname string) (string, error) {
|
2018-06-26 15:57:34 +00:00
|
|
|
return "", errors.New("not implemented")
|
|
|
|
}
|
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// GetMountRefs finds all mount references to the path, returns a
|
|
|
|
// list of paths. Always returns an error on unsupported platforms
|
|
|
|
func (*Mounter) GetMountRefs(pathname string) ([]string, error) {
|
2018-04-20 07:26:31 +00:00
|
|
|
return nil, errors.New("not implemented")
|
|
|
|
}
|
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// GetFSGroup returns FSGroup of pathname. Always returns an error on unsupported platforms
|
|
|
|
func (*Mounter) GetFSGroup(pathname string) (int64, error) {
|
2018-04-20 07:26:31 +00:00
|
|
|
return -1, errors.New("not implemented")
|
|
|
|
}
|
2018-05-17 11:36:37 +00:00
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// GetSELinuxSupport tests if pathname is on a mount that supports SELinux.
|
|
|
|
// Always returns an error on unsupported platforms
|
|
|
|
func (*Mounter) GetSELinuxSupport(pathname string) (bool, error) {
|
2018-05-17 11:36:37 +00:00
|
|
|
return false, errors.New("not implemented")
|
|
|
|
}
|
2018-05-23 08:17:59 +00:00
|
|
|
|
2019-04-08 16:43:54 +00:00
|
|
|
// GetMode returns permissions of pathname. Always returns an error on unsupported platforms
|
|
|
|
func (*Mounter) GetMode(pathname string) (os.FileMode, error) {
|
2018-05-23 08:17:59 +00:00
|
|
|
return 0, errors.New("not implemented")
|
|
|
|
}
|