OPT_END()
};
+OPT_ARGS(lock_opts) = {
+ OPT_FLAG("read-only", 'r', &sedopal_lock_ro,
+ "Set locking range to read-only"),
+ OPT_FLAG("ask-key", 'k', &sedopal_ask_key,
+ "prompt for SED authentication key"),
+ OPT_END()
+};
/*
* Open the NVMe device specified on the command line. It must be the
const char *desc = "Lock a SED device";
struct nvme_dev *dev;
- err = sed_opal_open_device(&dev, argc, argv, desc, key_opts);
+ err = sed_opal_open_device(&dev, argc, argv, desc, lock_opts);
if (err)
return err;
const char *desc = "Unlock a SED device";
struct nvme_dev *dev;
- err = sed_opal_open_device(&dev, argc, argv, desc, key_opts);
+ err = sed_opal_open_device(&dev, argc, argv, desc, lock_opts);
if (err)
return err;
*/
int sedopal_cmd_lock(int fd)
{
+ int lock_state = OPAL_LK;
- return sedopal_lock_unlock(fd, OPAL_LK);
+ if (sedopal_lock_ro)
+ lock_state = OPAL_RO;
+
+ return sedopal_lock_unlock(fd, lock_state);
}
/*
int sedopal_cmd_unlock(int fd)
{
int rc;
+ int lock_state = OPAL_RW;
+
+ if (sedopal_lock_ro)
+ lock_state = OPAL_RO;
- rc = sedopal_lock_unlock(fd, OPAL_RW);
+ rc = sedopal_lock_unlock(fd, lock_state);
/*
* If the unlock was successful, force a re-read of the