Skip to content

Commit 5fee3d0

Browse files
ikegami-tigaw
authored andcommitted
nvme: change attach-ns to error out if wrong device given
Also updating the documentation. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 25a4a5d commit 5fee3d0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Documentation/nvme-attach-ns.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ For the NVMe device given, sends the nvme namespace attach command for
1818
the provided namespace identifier, attaching to the provided list of
1919
controller identifiers.
2020

21+
The <device> parameter is mandatory NVMe character device (ex: /dev/nvme0) but
22+
not a namespace block device (ex: /dev/nvme0n1).
23+
2124
OPTIONS
2225
-------
2326
-n <nsid>::
2427
--namespace-id=<nsid>::
25-
The namespace identifier to attach.
28+
The namespace identifier to attach but not attached already.
2629

2730
-c <ctrl-list,>::
2831
-controllers=<ctrl-list,>::

nvme.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2928,6 +2928,12 @@ static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, s
29282928
if (err)
29292929
return err;
29302930

2931+
if (is_blkdev(dev)) {
2932+
nvme_show_error("%s: a block device opened (dev: %s, nsid: %d)", cmd->name,
2933+
dev->name, cfg.namespace_id);
2934+
return -EINVAL;
2935+
}
2936+
29312937
if (!cfg.namespace_id) {
29322938
nvme_show_error("%s: namespace-id parameter required", cmd->name);
29332939
return -EINVAL;

0 commit comments

Comments
 (0)