Update mount creation to only use btrfs subvolume id

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan
2017-08-16 10:12:16 -07:00
parent 4703b99ac0
commit 0e28f2c76e
3 changed files with 18 additions and 11 deletions

View File

@@ -3,8 +3,6 @@ package btrfs
import "sort"
/*
#cgo LDFLAGS: -lbtrfs
#include <stddef.h>
#include <btrfs/ioctl.h>
#include "btrfs.h"
@@ -20,7 +18,6 @@ static char* get_name_btrfs_ioctl_vol_args_v2(struct btrfs_ioctl_vol_args_v2* bt
import "C"
import (
"fmt"
"os"
"path/filepath"
"syscall"
@@ -49,6 +46,17 @@ func IsSubvolume(path string) error {
return isStatfsSubvol(&statfs)
}
// SubvolID returns the subvolume ID for the provided path
func SubvolID(path string) (uint64, error) {
fp, err := openSubvolDir(path)
if err != nil {
return 0, err
}
defer fp.Close()
return subvolID(fp.Fd())
}
// SubvolInfo returns information about the subvolume at the provided path.
func SubvolInfo(path string) (info Info, err error) {
path, err = filepath.EvalSymlinks(path)
@@ -301,7 +309,6 @@ func SubvolSnapshot(dst, src string, readonly bool) error {
// SubvolDelete deletes the subvolumes under the given path.
func SubvolDelete(path string) error {
fmt.Println("delete", path)
dir, name := filepath.Split(path)
fp, err := openSubvolDir(dir)
if err != nil {