Skip to content

Commit 20360e1

Browse files
committed
add an internal flag for dm_integrity status
mostly for testing and debugging Signed-off-by: Zen <[email protected]>
1 parent cb1df89 commit 20360e1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/ugrd/crypto/cryptsetup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from ugrd.exceptions import AutodetectError, ValidationError
1010
from zenlib.util import colorize as c_
11-
from zenlib.util import contains, unset
11+
from zenlib.util import contains, unset, pretty_print
1212

1313
_module_name = "ugrd.crypto.cryptsetup"
1414

@@ -28,6 +28,7 @@
2828
"include_header",
2929
"validate_key",
3030
"validate_header",
31+
"_dm-integrity", # Internal parameter for when dm-integrity was detected. mostly used for test automation
3132
]
3233

3334

@@ -150,6 +151,11 @@ def _get_dm_slave_info(self, device_info: dict) -> (str, dict):
150151
# For integrity backed devices, get the slave's slave
151152
if self["_vblk_info"].get(slave_source, {}).get("uuid", "").startswith("CRYPT-SUBDEV"):
152153
slave_source = self["_vblk_info"][slave_source]["slaves"][0]
154+
# Set the _dm-integrity flag on the cryptsetup configuration, if it exists
155+
if device_info.get("name") in self["cryptsetup"]:
156+
self["cryptsetup"][device_info["name"]]["_dm-integrity"] = True
157+
else:
158+
self.logger.warning(f"[{c_(device_info['name'], 'yellow')}] Unable to set _dm-integrity flag, cryptsetup configuration not found: {pretty_print(self['cryptsetup'])}")
153159
slave_name = self["_vblk_info"].get(slave_source, {}).get("name")
154160
search_paths = ["/dev/", "/dev/mapper/"]
155161

0 commit comments

Comments
 (0)