File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -19,9 +19,15 @@ package btrfs
19
19
import (
20
20
"os/exec"
21
21
22
+ "github.com/openebs/lib-csi/pkg/common/errors"
22
23
"k8s.io/klog"
23
24
)
24
25
26
+ const (
27
+ // BTRFS is a command line utility of btrfs filesystem
28
+ BTRFS = "btrfs"
29
+ )
30
+
25
31
/*
26
32
* We have to generate a new UUID for the cloned volumes with btrfs filesystem
27
33
* otherwise system will mount the same volume if UUID is same. Here, since cloned
@@ -41,3 +47,22 @@ func GenerateUUID(device string) error {
41
47
klog .Infof ("btrfs: generated UUID for the device %s \n %v" , device , string (out ))
42
48
return nil
43
49
}
50
+
51
+ // ResizeBTRFS will expand btrfs filesystem at given mount point
52
+ func ResizeBTRFS (mountPoint string ) error {
53
+ args := []string {"filesystem" , "resize" , "max" , mountPoint }
54
+ cmd := exec .Command (BTRFS , args ... )
55
+
56
+ out , err := cmd .CombinedOutput ()
57
+ if err != nil {
58
+ klog .Errorf (
59
+ "btrfs utility could not expand btrfs filesystem " +
60
+ "on mount point: %s cmd: %v error: %s" ,
61
+ mountPoint ,
62
+ args ,
63
+ string (out ),
64
+ )
65
+ return errors .Wrap (err , string (out ))
66
+ }
67
+ return nil
68
+ }
You can’t perform that action at this time.
0 commit comments