Skip to content

Commit 5a2ed2f

Browse files
authored
LUKS Enhancements
This commit sets the allow-discards option for LUKS devices.
1 parent 7dbecbb commit 5a2ed2f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

utils/devices/luks/luks_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ func (d *LUKSDevice) Open(ctx context.Context, luksPassphrase string) error {
230230
}
231231

232232
output, err := d.command.ExecuteWithTimeoutAndInput(
233-
ctx, "cryptsetup", luksCommandTimeout, true, luksPassphrase, "open", device,
234-
luksDeviceName, "--type", "luks2",
233+
ctx, "cryptsetup", luksCommandTimeout, true, luksPassphrase,
234+
"open", device, luksDeviceName, "--type", "luks2", "--allow-discards", "--persistent",
235235
)
236236
if err != nil {
237237
Logc(ctx).WithFields(LogFields{

utils/devices/luks/luks_linux_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func mockCryptsetupLuksOpen(mock *mockexec.MockCommand) *gomock.Call {
4747
return mock.EXPECT().ExecuteWithTimeoutAndInput(
4848
gomock.Any(), "cryptsetup", luksCommandTimeout, true, gomock.Any(),
4949
"open", gomock.Any(), gomock.Any(), "--type", "luks2",
50+
"--allow-discards", "--persistent",
5051
)
5152
}
5253

@@ -58,8 +59,8 @@ func mockCryptsetupLuksStatusWithDevicePath(mock *mockexec.MockCommand) *gomock.
5859

5960
func mockCryptsetupLuksTestPassphrase(mock *mockexec.MockCommand) *gomock.Call {
6061
return mock.EXPECT().ExecuteWithTimeoutAndInput(
61-
gomock.Any(), "cryptsetup", luksCommandTimeout, true, gomock.Any(), "open", gomock.Any(),
62-
gomock.Any(), "--type", "luks2", "--test-passphrase",
62+
gomock.Any(), "cryptsetup", luksCommandTimeout, true, gomock.Any(),
63+
"open", gomock.Any(), gomock.Any(), "--type", "luks2", "--test-passphrase",
6364
)
6465
}
6566

0 commit comments

Comments
 (0)