Merge pull request #1168 from dmcgowan/fix-btrfs-load
Create btrfs directory if it does not exist
This commit is contained in:
commit
a38bce0502
@ -39,13 +39,23 @@ type snapshotter struct {
|
|||||||
// a file in the provided root.
|
// a file in the provided root.
|
||||||
// root needs to be a mount point of btrfs.
|
// root needs to be a mount point of btrfs.
|
||||||
func NewSnapshotter(root string) (snapshot.Snapshotter, error) {
|
func NewSnapshotter(root string) (snapshot.Snapshotter, error) {
|
||||||
mnt, err := mount.Lookup(root)
|
// If directory does not exist, create it
|
||||||
if mnt.FSType != "btrfs" {
|
if _, err := os.Stat(root); err != nil {
|
||||||
return nil, fmt.Errorf("expected btrfs, got %s", mnt.FSType)
|
if !os.IsNotExist(err) {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := os.Mkdir(root, 0755); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mnt, err := mount.Lookup(root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if mnt.FSType != "btrfs" {
|
||||||
|
return nil, fmt.Errorf("expected btrfs, got %s", mnt.FSType)
|
||||||
|
}
|
||||||
var (
|
var (
|
||||||
active = filepath.Join(root, "active")
|
active = filepath.Join(root, "active")
|
||||||
snapshots = filepath.Join(root, "snapshots")
|
snapshots = filepath.Join(root, "snapshots")
|
||||||
|
Loading…
Reference in New Issue
Block a user