nsenter_mount_unsupported.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. // +build !linux
  2. /*
  3. Copyright 2014 The Kubernetes Authors.
  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. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. */
  14. package nsenter
  15. import (
  16. "errors"
  17. "os"
  18. "k8s.io/utils/nsenter"
  19. "k8s.io/kubernetes/pkg/util/mount"
  20. )
  21. // Mounter provides the mount.Interface implementation for unsupported
  22. // platforms.
  23. type Mounter struct{}
  24. // NewMounter returns a new Mounter for the current system
  25. func NewMounter(rootDir string, ne *nsenter.Nsenter) *Mounter {
  26. return &Mounter{}
  27. }
  28. var _ = mount.Interface(&Mounter{})
  29. // Mount mounts the source to the target. It is a noop for unsupported systems
  30. func (*Mounter) Mount(source string, target string, fstype string, options []string) error {
  31. return nil
  32. }
  33. // Unmount unmounts the target path from the system. it is a noop for unsupported
  34. // systems
  35. func (*Mounter) Unmount(target string) error {
  36. return nil
  37. }
  38. // List returns a list of all mounted filesystems. It is a noop for unsupported systems
  39. func (*Mounter) List() ([]mount.MountPoint, error) {
  40. return []mount.MountPoint{}, nil
  41. }
  42. // IsMountPointMatch tests if dir and mp are the same path
  43. func (*Mounter) IsMountPointMatch(mp mount.MountPoint, dir string) bool {
  44. return (mp.Path == dir)
  45. }
  46. // IsLikelyNotMountPoint determines if a directory is not a mountpoint.
  47. // It is a noop on unsupported systems
  48. func (*Mounter) IsLikelyNotMountPoint(file string) (bool, error) {
  49. return true, nil
  50. }
  51. // DeviceOpened checks if block device in use. I tis a noop for unsupported systems
  52. func (*Mounter) DeviceOpened(pathname string) (bool, error) {
  53. return false, nil
  54. }
  55. // PathIsDevice checks if pathname refers to a device. It is a noop for unsupported
  56. // systems
  57. func (*Mounter) PathIsDevice(pathname string) (bool, error) {
  58. return true, nil
  59. }
  60. // GetDeviceNameFromMount finds the device name from its global mount point using the
  61. // given mountpath and plugin location. It is a noop of unsupported platforms
  62. func (*Mounter) GetDeviceNameFromMount(mountPath, pluginMountDir string) (string, error) {
  63. return "", nil
  64. }
  65. // MakeRShared checks if path is shared and bind-mounts it as rshared if needed.
  66. // It is a noop on unsupported platforms
  67. func (*Mounter) MakeRShared(path string) error {
  68. return nil
  69. }
  70. // GetFileType checks for file/directory/socket/block/character devices.
  71. // Always returns an error and "fake" filetype on unsupported platforms
  72. func (*Mounter) GetFileType(_ string) (mount.FileType, error) {
  73. return mount.FileType("fake"), errors.New("not implemented")
  74. }
  75. // MakeDir creates a new directory. Noop on unsupported platforms
  76. func (*Mounter) MakeDir(pathname string) error {
  77. return nil
  78. }
  79. // MakeFile creats an empty file. Noop on unsupported platforms
  80. func (*Mounter) MakeFile(pathname string) error {
  81. return nil
  82. }
  83. // ExistsPath checks if pathname exists. Always returns an error on unsupported
  84. // platforms
  85. func (*Mounter) ExistsPath(pathname string) (bool, error) {
  86. return true, errors.New("not implemented")
  87. }
  88. // EvalHostSymlinks returns the path name after evaluating symlinks. Always
  89. // returns an error on unsupported platforms
  90. func (*Mounter) EvalHostSymlinks(pathname string) (string, error) {
  91. return "", errors.New("not implemented")
  92. }
  93. // GetMountRefs finds all mount references to the path, returns a
  94. // list of paths. Always returns an error on unsupported platforms
  95. func (*Mounter) GetMountRefs(pathname string) ([]string, error) {
  96. return nil, errors.New("not implemented")
  97. }
  98. // GetFSGroup returns FSGroup of pathname. Always returns an error on unsupported platforms
  99. func (*Mounter) GetFSGroup(pathname string) (int64, error) {
  100. return -1, errors.New("not implemented")
  101. }
  102. // GetSELinuxSupport tests if pathname is on a mount that supports SELinux.
  103. // Always returns an error on unsupported platforms
  104. func (*Mounter) GetSELinuxSupport(pathname string) (bool, error) {
  105. return false, errors.New("not implemented")
  106. }
  107. // GetMode returns permissions of pathname. Always returns an error on unsupported platforms
  108. func (*Mounter) GetMode(pathname string) (os.FileMode, error) {
  109. return 0, errors.New("not implemented")
  110. }