Detect DAX devices and and warn in LUKS format.

DAX / persistent memory devices do not provide atomic sector updates,
any single modification can corrupt the whole encryption block.
This commit is contained in:
Milan Broz
2023-03-18 13:45:25 +01:00
parent 2a2027ee3e
commit e4c2aa64b5
4 changed files with 34 additions and 0 deletions

View File

@@ -985,6 +985,22 @@ int device_is_rotational(struct device *device)
return crypt_dev_is_rotational(major(st.st_rdev), minor(st.st_rdev));
}
int device_is_dax(struct device *device)
{
struct stat st;
if (!device)
return -EINVAL;
if (stat(device_path(device), &st) < 0)
return -EINVAL;
if (!S_ISBLK(st.st_mode))
return 0;
return crypt_dev_is_dax(major(st.st_rdev), minor(st.st_rdev));
}
size_t device_alignment(struct device *device)
{
int devfd;