1
0
mirror of https://github.com/ceph/ceph-csi.git synced 2024-12-19 03:20:20 +00:00

util: add helper functions for resize of encrypted volume

such as:
ResizeEncryptedVolume() and LuksResize()

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
This commit is contained in:
Prasanna Kumar Kalever 2021-07-06 13:01:08 +05:30 committed by mergify[bot]
parent 572f39d656
commit 4fa05cb3a1
2 changed files with 16 additions and 0 deletions

View File

@ -261,6 +261,17 @@ func OpenEncryptedVolume(ctx context.Context, devicePath, mapperFile, passphrase
return err
}
// ResizeEncryptedVolume resizes encrypted volume so that it can be used by the client.
func ResizeEncryptedVolume(ctx context.Context, mapperFile string) error {
DebugLog(ctx, "Resizing LUKS device %s", mapperFile)
_, stderr, err := LuksResize(mapperFile)
if err != nil {
ErrorLog(ctx, "failed to resize LUKS device %s: %s", mapperFile, stderr)
}
return err
}
// CloseEncryptedVolume closes encrypted volume so it can be detached.
func CloseEncryptedVolume(ctx context.Context, mapperFile string) error {
DebugLog(ctx, "Closing LUKS device %s", mapperFile)

View File

@ -43,6 +43,11 @@ func LuksOpen(devicePath, mapperFile, passphrase string) (stdout, stderr []byte,
return execCryptsetupCommand(&passphrase, "luksOpen", devicePath, mapperFile, "-d", "/dev/stdin")
}
// LuksResize resizes LUKS encrypted partition.
func LuksResize(mapperFile string) (stdout, stderr []byte, err error) {
return execCryptsetupCommand(nil, "resize", mapperFile)
}
// LuksClose removes existing mapping.
func LuksClose(mapperFile string) (stdout, stderr []byte, err error) {
return execCryptsetupCommand(nil, "luksClose", mapperFile)