Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Documentation/nvme-attach-ns.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ For the NVMe device given, sends the nvme namespace attach command for
the provided namespace identifier, attaching to the provided list of
controller identifiers.

The <device> parameter is mandatory NVMe character device (ex: /dev/nvme0) but
not a namespace block device (ex: /dev/nvme0n1).

OPTIONS
-------
-n <nsid>::
--namespace-id=<nsid>::
The namespace identifier to attach.
The namespace identifier to attach but not attached already.

-c <ctrl-list,>::
-controllers=<ctrl-list,>::
Expand Down
6 changes: 6 additions & 0 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -2928,6 +2928,12 @@ static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, s
if (err)
return err;

if (is_blkdev(dev)) {
nvme_show_error("%s: a block device opened (dev: %s, nsid: %d)", cmd->name,
dev->name, cfg.namespace_id);
return -EINVAL;
}

if (!cfg.namespace_id) {
nvme_show_error("%s: namespace-id parameter required", cmd->name);
return -EINVAL;
Expand Down