Skip to contentSkip to conversation

nvme-cli: add helper for sanitize command

PATCH New Minwoo Im 1 participant 1 message Feb 8, 2018 NVMe

lore
Share & tools
lore

Minwoo Im

author
#0 lore raw

PATCH 1/1 nvme-cli: add helper for sanitize command

Add helper function for sanitize command just like other commands with few error returning from wrong options.

Signed-off-by Minwoo Im <minwoo.im.dev at gmail.com>
---
 nvme-ioctl.c | 13 +++++++++++++
 nvme-ioctl.h |  2 ++
 nvme.c       | 53 +++++++++++++++++++++++------------------------------
 3 files changed, 38 insertions(+), 30 deletions(-)
nvme-ioctl.c +13 -0
index 6dd7192..d2a37a7 100644
@@ -773,3 +773,16 @@ int nvme_dir_recv(int fd, __u32 nsid, __u16 dspec, __u8 dtype, __u8 doper,
         return err;
 }
 
+int nvme_sanitize(int fd, __u8 sanact, __u8 ause, __u8 owpass, __u8 oipbp,
+		  __u8 no_dealloc, __u32 ovrpat)
+{
+	struct nvme_admin_cmd cmd = {
+		.opcode		= nvme_admin_sanitize_nvm,
+		.cdw10		= no_dealloc << 9 | oipbp << 8 |
+				  owpass << NVME_SANITIZE_OWPASS_SHIFT |
+				  ause << 3 | sanact,
+		.cdw11		= ovrpat,
+	};
+
+	return nvme_submit_admin_passthru(fd, &cmd);
+}
nvme-ioctl.h +2 -0
index 6569665..e3a5968 100644
@@ -129,5 +129,7 @@ int nvme_dir_recv(int fd, __u32 nsid, __u16 dspec, __u8 dtype, __u8 doper,
 		  __u32 data_len, __u32 dw12, void *data, __u32 *result);
 int nvme_get_properties(int fd, void **pbar);
 int nvme_set_property(int fd, int offset, int value);
+int nvme_sanitize(int fd, __u8 sanact, __u8 ause, __u8 owpass, __u8 oipbp,
+		  __u8 no_dealloc, __u32 ovrpat);
 
 #endif				/* _NVME_LIB_H */
nvme.c +23 -30

84 lines not on this page · raw message

Signature · 1 line
2.7.4