summaryrefslogtreecommitdiffstats
path: root/plugins/sed
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 08:38:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 08:38:39 +0000
commit80b126032c7e73d273bc883e973b5f1a94aac581 (patch)
treee7d13cf4f02585c239665a6c5465735ffde429c8 /plugins/sed
parentReleasing debian version 2.9.1-3. (diff)
downloadnvme-cli-80b126032c7e73d273bc883e973b5f1a94aac581.tar.xz
nvme-cli-80b126032c7e73d273bc883e973b5f1a94aac581.zip
Merging upstream version 2.10.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plugins/sed')
-rw-r--r--plugins/sed/sedopal_cmd.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/plugins/sed/sedopal_cmd.c b/plugins/sed/sedopal_cmd.c
index 21ebd36..d9a789c 100644
--- a/plugins/sed/sedopal_cmd.c
+++ b/plugins/sed/sedopal_cmd.c
@@ -251,8 +251,21 @@ int sedopal_cmd_lock(int fd)
*/
int sedopal_cmd_unlock(int fd)
{
+ int rc;
+
+ rc = sedopal_lock_unlock(fd, OPAL_RW);
- return sedopal_lock_unlock(fd, OPAL_RW);
+ /*
+ * If the unlock was successful, force a re-read of the
+ * partition table. Return rc of unlock operation.
+ */
+ if (rc == 0) {
+ if (ioctl(fd, BLKRRPART, 0) != 0)
+ fprintf(stderr,
+ "Warning: failed re-reading partition\n");
+ }
+
+ return rc;
}
/*
@@ -275,18 +288,6 @@ int sedopal_lock_unlock(int fd, int lock_state)
if (rc != 0)
fprintf(stderr,
"Error: failed locking or unlocking - %d\n", rc);
-
- /*
- * If the unlock was successful, force a re-read of the
- * partition table.
- */
- if (rc == 0) {
- rc = ioctl(fd, BLKRRPART, 0);
- if (rc != 0)
- fprintf(stderr,
- "Error: failed re-reading partition\n");
- }
-
return rc;
}
@@ -397,6 +398,14 @@ int sedopal_cmd_revert(int fd)
revert_lsp.__pad = 0;
rc = ioctl(fd, IOC_OPAL_REVERT_LSP, &revert_lsp);
+ if (rc == 0) {
+ /*
+ * TPER must also be reverted.
+ */
+ rc = ioctl(fd, IOC_OPAL_REVERT_TPR, &revert_lsp.key);
+ if (rc != 0)
+ fprintf(stderr, "Error: revert TPR - %d\n", rc);
+ }
#else
rc = -EOPNOTSUPP;
#endif
@@ -465,7 +474,7 @@ void sedopal_print_locking_features(uint8_t features)
int sedopal_cmd_discover(int fd)
{
#ifdef IOC_OPAL_DISCOVERY
- int rc;
+ int rc, feat_length;
bool sedopal_locking_supported = false;
struct opal_discovery discover;
struct level_0_discovery_header *dh;
@@ -500,6 +509,7 @@ int sedopal_cmd_discover(int fd)
*/
while (feat < feat_end) {
code = be16toh(feat->code);
+ feat_length = feat->length + 4 /* hdr */;
switch (code) {
case OPAL_FEATURE_CODE_LOCKING:
locking_flags = feat->feature;
@@ -511,7 +521,7 @@ int sedopal_cmd_discover(int fd)
break;
}
- feat++;
+ feat = (struct level_0_discovery_features *)((char *)feat + feat_length);
}
rc = 0;