forked from moby/moby
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New 'dummy' driver uses plain directories and regular copy
- Loading branch information
Solomon Hykes
committed
Nov 8, 2013
1 parent
0a9df6b
commit 81674fb
Showing
3 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ var ( | |
priority = []string{ | ||
"aufs", | ||
"devicemapper", | ||
"dummy", | ||
} | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package dummy | ||
|
||
import ( | ||
"github.com/dotcloud/docker/archive" | ||
"github.com/dotcloud/docker/graphdriver" | ||
"os" | ||
"path" | ||
"fmt" | ||
) | ||
|
||
func init() { | ||
graphdriver.Register("dummy", Init) | ||
} | ||
|
||
func Init(home string) (graphdriver.Driver, error) { | ||
d := &Driver{ | ||
home: home, | ||
} | ||
return d, nil | ||
} | ||
|
||
type Driver struct { | ||
home string | ||
} | ||
|
||
func (d *Driver) Cleanup() error { | ||
return nil | ||
} | ||
|
||
func (d *Driver) Create(id string, parent string) error { | ||
dir := d.dir(id) | ||
if err := os.MkdirAll(path.Dir(dir), 0700); err != nil { | ||
return err | ||
} | ||
if err := os.Mkdir(dir, 0700); err != nil { | ||
return err | ||
} | ||
if parent == "" { | ||
return nil | ||
} | ||
parentDir, err := d.Get(parent) | ||
if err != nil { | ||
return fmt.Errorf("%s: %s", parent, err) | ||
} | ||
if err := archive.CopyWithTar(parentDir, dir); err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func (d *Driver) dir(id string) string { | ||
return path.Join(d.home, "dir", path.Base(id)) | ||
} | ||
|
||
|
||
func (d *Driver) Remove(id string) error { | ||
if _, err := os.Stat(d.dir(id)); err != nil { | ||
return err | ||
} | ||
return os.RemoveAll(d.dir(id)) | ||
} | ||
|
||
func (d *Driver) Get(id string) (string, error) { | ||
dir := d.dir(id) | ||
if st, err := os.Stat(dir); err != nil { | ||
return "", err | ||
} else if !st.IsDir() { | ||
return "", fmt.Errorf("%s: not a directory", dir) | ||
} | ||
return dir, nil | ||
} | ||
|
||
func (d *Driver) Diff(id string) (archive.Archive, error) { | ||
return nil, fmt.Errorf("Not implemented") | ||
} | ||
|
||
func (d *Driver) DiffSize(id string) (int64, error) { | ||
return -1, fmt.Errorf("Not implemented") | ||
} | ||
|
||
func (d *Driver) Changes(id string) ([]archive.Change, error) { | ||
return nil, fmt.Errorf("Not implemented") | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters