Debian Codegraph @

mount_unsupported.go

raw
1 //go:build !linux && !windows
2
3 /*
4 Copyright 2014 The Kubernetes Authors.
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 */
18
19 package mount
20
21 import (
22 "errors"
23 )
24
25 // Mounter implements mount.Interface for unsupported platforms
26 type Mounter struct {
27 mounterPath string
28 }
29
30 var errUnsupported = errors.New("util/mount on this platform is not supported")
31
32 // New returns a mount.Interface for the current system.
33 // It provides options to override the default mounter behavior.
34 // mounterPath allows using an alternative to `/bin/mount` for mounting.
35 func New(mounterPath string) Interface {
36 return &Mounter{
37 mounterPath: mounterPath,
38 }
39 }
40
41 // Mount always returns an error on unsupported platforms
42 func (mounter *Mounter) Mount(source string, target string, fstype string, options []string) error {
43 return errUnsupported
44 }
45
46 // MountSensitive always returns an error on unsupported platforms
47 func (mounter *Mounter) MountSensitive(source string, target string, fstype string, options []string, sensitiveOptions []string) error {
48 return errUnsupported
49 }
50
51 // MountSensitiveWithoutSystemd always returns an error on unsupported platforms
52 func (mounter *Mounter) MountSensitiveWithoutSystemd(source string, target string, fstype string, options []string, sensitiveOptions []string) error {
53 return errUnsupported
54 }
55
56 // MountSensitiveWithoutSystemdWithMountFlags always returns an error on unsupported platforms
57 func (mounter *Mounter) MountSensitiveWithoutSystemdWithMountFlags(source string, target string, fstype string, options []string, sensitiveOptions []string, mountFlags []string) error {
58 return errUnsupported
59 }
60
61 // Unmount always returns an error on unsupported platforms
62 func (mounter *Mounter) Unmount(target string) error {
63 return errUnsupported
64 }
65
66 // List always returns an error on unsupported platforms
67 func (mounter *Mounter) List() ([]MountPoint, error) {
68 return []MountPoint{}, errUnsupported
69 }
70
71 // IsLikelyNotMountPoint always returns an error on unsupported platforms
72 func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) {
73 return true, errUnsupported
74 }
75
76 // CanSafelySkipMountPointCheck always returns false on unsupported platforms
77 func (mounter *Mounter) CanSafelySkipMountPointCheck() bool {
78 return false
79 }
80
81 // IsMountPoint determines if a directory is a mountpoint.
82 // It always returns an error on unsupported platforms.
83 func (mounter *Mounter) IsMountPoint(file string) (bool, error) {
84 return false, errUnsupported
85 }
86
87 // GetMountRefs always returns an error on unsupported platforms
88 func (mounter *Mounter) GetMountRefs(pathname string) ([]string, error) {
89 return nil, errUnsupported
90 }
91
92 func (mounter *SafeFormatAndMount) formatAndMountSensitive(source string, target string, fstype string, options []string, sensitiveOptions []string, formatOptions []string) error {
93 return mounter.Interface.Mount(source, target, fstype, options)
94 }
95
96 func (mounter *SafeFormatAndMount) diskLooksUnformatted(disk string) (bool, error) {
97 return true, errUnsupported
98 }
99
100 // IsMountPoint determines if a directory is a mountpoint.
101 // It always returns an error on unsupported platforms.
102 func (mounter *SafeFormatAndMount) IsMountPoint(file string) (bool, error) {
103 return false, errUnsupported
104 }