Skip to content

Commit 4d98add

Browse files
committed
opal: Submit PSID reset command to R/W file descriptor.
The PSID reset erases the block device it's submitted to succesfully. By submitting the command to read-only fd previously there were partition device nodes still visible in the /dev directory because kernel does not trigger rescan after OPAL2 PSID reset. Even though all the partition were actually erased (including the partition table). We workaround the issue by submitting the PSID reset to R/W fd so that it triggers rescan event on close.
1 parent 0eaaa45 commit 4d98add

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

lib/luks2/hw_opal/hw_opal.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,11 @@ int opal_factory_reset(struct crypt_device *cd,
790790
if (password_len > OPAL_KEY_MAX)
791791
return -EINVAL;
792792

793-
fd = device_open(cd, dev, O_RDONLY);
793+
/*
794+
* Submit PSID reset on R/W file descriptor so it
795+
* triggers blkid rescan after we close it.
796+
*/
797+
fd = device_open(cd, dev, O_RDWR);
794798
if (fd < 0)
795799
return -EIO;
796800

0 commit comments

Comments
 (0)