1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

devmapper: renamed DMBackend to Driver

This commit is contained in:
Solomon Hykes 2013-11-04 17:22:43 +00:00
parent d23b9e8734
commit b77c5c5984

View file

@ -24,27 +24,27 @@ type Change interface {
type DMBackend struct { type Driver struct {
*DeviceSet *DeviceSet
home string home string
} }
func Init(home string) (*DMBackend, error) { func Init(home string) (*Driver, error) {
b := &DMBackend{ d := &Driver{
DeviceSet: NewDeviceSet(home), DeviceSet: NewDeviceSet(home),
home: home, home: home,
} }
if err := b.DeviceSet.ensureInit(); err != nil { if err := d.DeviceSet.ensureInit(); err != nil {
return nil, err return nil, err
} }
return b, nil return d, nil
} }
func (b *DMBackend) Cleanup() error { func (d *Driver) Cleanup() error {
return b.DeviceSet.Shutdown() return d.DeviceSet.Shutdown()
} }
func (b *DMBackend) OnCreate(img Image, layer archive.Archive) error { func (d *Driver) OnCreate(img Image, layer archive.Archive) error {
// Determine the source of the snapshot (parent id or init device) // Determine the source of the snapshot (parent id or init device)
var parentID string var parentID string
if parent, err := img.Parent(); err != nil { if parent, err := img.Parent(); err != nil {
@ -53,15 +53,15 @@ func (b *DMBackend) OnCreate(img Image, layer archive.Archive) error {
parentID = parent.ID() parentID = parent.ID()
} }
// Create the device for this image by snapshotting source // Create the device for this image by snapshotting source
if err := b.DeviceSet.AddDevice(img.ID(), parentID); err != nil { if err := d.DeviceSet.AddDevice(img.ID(), parentID); err != nil {
return err return err
} }
// Mount the device in rootfs // Mount the device in rootfs
mp := b.mountpoint(img.ID()) mp := d.mountpoint(img.ID())
if err := os.MkdirAll(mp, 0700); err != nil { if err := os.MkdirAll(mp, 0700); err != nil {
return err return err
} }
if err := b.DeviceSet.MountDevice(img.ID(), mp, false); err != nil { if err := d.DeviceSet.MountDevice(img.ID(), mp, false); err != nil {
return err return err
} }
// Apply the layer as a diff // Apply the layer as a diff
@ -73,25 +73,25 @@ func (b *DMBackend) OnCreate(img Image, layer archive.Archive) error {
return nil return nil
} }
func (b *DMBackend) OnRemove(img Image) error { func (d *Driver) OnRemove(img Image) error {
id := img.ID() id := img.ID()
if err := b.DeviceSet.RemoveDevice(id); err != nil { if err := d.DeviceSet.RemoveDevice(id); err != nil {
return fmt.Errorf("Unable to remove device for %v: %v", id, err) return fmt.Errorf("Unable to remove device for %v: %v", id, err)
} }
return nil return nil
} }
func (b *DMBackend) mountpoint(id string) string { func (d *Driver) mountpoint(id string) string {
if b.home == "" { if d.home == "" {
return "" return ""
} }
return path.Join(b.home, "mnt", id) return path.Join(d.home, "mnt", id)
} }
func (b *DMBackend) Changes(img *Image, dest string) ([]Change, error) { func (d *Driver) Changes(img *Image, dest string) ([]Change, error) {
return nil, fmt.Errorf("Not implemented") return nil, fmt.Errorf("Not implemented")
} }
func (b *DMBackend) Layer(img *Image, dest string) (archive.Archive, error) { func (d *Driver) Layer(img *Image, dest string) (archive.Archive, error) {
return nil, fmt.Errorf("Not implemented") return nil, fmt.Errorf("Not implemented")
} }