forked from rexray/rexray
/
registry_os.go
71 lines (54 loc) · 1.34 KB
/
registry_os.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package registry
import (
"os"
"path"
"github.com/rexray/rexray/libstorage/api/types"
)
type odm struct {
types.OSDriver
types.Context
}
// NewOSDriverManager returns a new OS driver manager.
func NewOSDriverManager(
d types.OSDriver) types.OSDriver {
return &odm{OSDriver: d}
}
func (d *odm) Mounts(
ctx types.Context,
deviceName, mountPoint string,
opts types.Store) ([]*types.MountInfo, error) {
ctx = ctx.Join(d.Context)
return d.OSDriver.Mounts(ctx.Join(d.Context), deviceName, mountPoint, opts)
}
func (d *odm) Mount(
ctx types.Context,
deviceName, mountPoint string,
opts *types.DeviceMountOpts) error {
ctx = ctx.Join(d.Context)
return d.OSDriver.Mount(ctx.Join(d.Context), deviceName, mountPoint, opts)
}
func (d *odm) Unmount(
ctx types.Context,
mountPoint string,
opts types.Store) error {
return d.OSDriver.Unmount(ctx.Join(d.Context), mountPoint, opts)
}
func (d *odm) IsMounted(
ctx types.Context,
mountPoint string,
opts types.Store) (bool, error) {
return d.OSDriver.IsMounted(ctx.Join(d.Context), mountPoint, opts)
}
func (d *odm) Format(
ctx types.Context,
deviceName string,
opts *types.DeviceFormatOpts) error {
ctx = ctx.Join(d.Context)
if !path.IsAbs(deviceName) {
return nil
}
if _, err := os.Stat(deviceName); os.IsNotExist(err) {
return nil
}
return d.OSDriver.Format(ctx, deviceName, opts)
}