Skip to content
Closed
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
4 changes: 2 additions & 2 deletions libnvme/src/libnvme.ld
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ LIBNVME_3 {
libnvme_subsystem_release_fds;
libnvme_transport_handle_get_fd;
libnvme_transport_handle_get_name;
libnvme_transport_handle_is_blkdev;
libnvme_transport_handle_is_chardev;
libnvme_transport_handle_is_ctrl;
libnvme_transport_handle_is_direct;
libnvme_transport_handle_is_mi;
libnvme_transport_handle_is_ns;
libnvme_transport_handle_set_decide_retry;
libnvme_transport_handle_set_submit_entry;
libnvme_transport_handle_set_submit_exit;
Expand Down
8 changes: 4 additions & 4 deletions libnvme/src/nvme/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,14 @@
return basename(hdl->name);
}

__public bool libnvme_transport_handle_is_blkdev(struct libnvme_transport_handle *hdl)
__public bool libnvme_transport_handle_is_ctrl(struct libnvme_transport_handle *hdl)

Check failure on line 294 in libnvme/src/nvme/lib.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 84 exceeds 80 columns
{
return S_ISBLK(hdl->stat.st_mode);
return S_ISCHR(hdl->stat.st_mode);
}

__public bool libnvme_transport_handle_is_chardev(struct libnvme_transport_handle *hdl)
__public bool libnvme_transport_handle_is_ns(struct libnvme_transport_handle *hdl)

Check failure on line 299 in libnvme/src/nvme/lib.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 82 exceeds 80 columns
{
return S_ISCHR(hdl->stat.st_mode);
return S_ISBLK(hdl->stat.st_mode);
}

__public bool libnvme_transport_handle_is_direct(struct libnvme_transport_handle *hdl)
Expand Down
30 changes: 16 additions & 14 deletions libnvme/src/nvme/lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,29 +109,21 @@ const char *libnvme_transport_handle_get_name(
struct libnvme_transport_handle *hdl);

/**
* libnvme_transport_handle_is_blkdev - Check if transport handle is a
* block device
* libnvme_transport_handle_is_ctrl - Check if transport handle is a
* controller device
* @hdl: Transport handle
*
* Return: Return true if transport handle is a block device, otherwise false.
*/
bool libnvme_transport_handle_is_blkdev(struct libnvme_transport_handle *hdl);

/**
* libnvme_transport_handle_is_chardev - Check if transport handle is a
* char device
* @hdl: Transport handle
*
* Return: Return true if transport handle is a char device, otherwise false.
* Return: Return true if transport handle is a controller device,
* otherwise false.
*/
bool libnvme_transport_handle_is_chardev(struct libnvme_transport_handle *hdl);
bool libnvme_transport_handle_is_ctrl(struct libnvme_transport_handle *hdl);

/**
* libnvme_transport_handle_is_direct - Check if transport handle is using IOCTL
* interface
* @hdl: Transport handle
*
* Return: Return true if transport handle is using IOCTL itnerface,
* Return: Return true if transport handle is using IOCTL interface,
* otherwise false.
*/
bool libnvme_transport_handle_is_direct(struct libnvme_transport_handle *hdl);
Expand All @@ -146,6 +138,16 @@ bool libnvme_transport_handle_is_direct(struct libnvme_transport_handle *hdl);
*/
bool libnvme_transport_handle_is_mi(struct libnvme_transport_handle *hdl);

/**
* libnvme_transport_handle_is_ns - Check if transport handle is a
* namespace device
* @hdl: Transport handle
*
* Return: Return true if transport handle is a namespace device,
* otherwise false.
*/
bool libnvme_transport_handle_is_ns(struct libnvme_transport_handle *hdl);

/**
* libnvme_transport_handle_set_submit_entry() - Install a submit-entry callback
* @hdl: Transport handle to configure
Expand Down
46 changes: 23 additions & 23 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@
.name = "nvme",
.version = nvme_version_string,
.usage = "<command> [<device>] [<args>]",
.desc = "The '<device>' may be either an NVMe character "
"device (ex: /dev/nvme0), an nvme block device "
.desc = "The '<device>' may be either an NVMe controller "
"device (ex: /dev/nvme0), an nvme namespace device "

Check failure on line 178 in nvme.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: quoted string split across lines
"(ex: /dev/nvme0n1), or a mctp address in the form "
"mctp:<net>,<eid>[:ctrl-id]",
.extensions = &builtin,
Expand Down Expand Up @@ -212,7 +212,7 @@
static const char *namespace_desired = "desired namespace";
static const char *namespace_id_optional = "optional namespace attached to controller";
static const char *nssf = "NVMe Security Specific Field";
static const char *only_char_dev = "Only character device is allowed";
static const char *only_ctrl_dev = "Only controller device is allowed";
static const char *prinfo = "PI and check field";
static const char *rae = "Retain an Asynchronous Event";
static const char *raw_directive = "show directive in binary format";
Expand Down Expand Up @@ -422,11 +422,11 @@
struct libnvme_transport_handle *hdl = *phdl;
int err;

if (libnvme_transport_handle_is_chardev(hdl)) {
if (libnvme_transport_handle_is_ctrl(hdl)) {
__cleanup_free char *cdev = NULL;

if (!nsid) {
nvme_show_error("char device not supported without --namespace-id");
nvme_show_error("controller device not supported without --namespace-id");

Check failure on line 429 in nvme.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 98 exceeds 80 columns
return -EINVAL;
}

Expand Down Expand Up @@ -1099,8 +1099,8 @@

if (cfg.csi < 0) {
__u64 cap;
if (libnvme_transport_handle_is_blkdev(hdl)) {
nvme_show_error("Block device isn't allowed without csi");
if (libnvme_transport_handle_is_ns(hdl)) {
nvme_show_error("Namespace device isn't allowed without csi");

Check failure on line 1103 in nvme.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 86 exceeds 80 columns
return -EINVAL;
}
bar = mmap_registers(hdl, false);
Expand Down Expand Up @@ -3013,8 +3013,8 @@
return err;
}

if (libnvme_transport_handle_is_blkdev(hdl)) {
nvme_show_error("%s: a block device opened (dev: %s, nsid: %d)", acmd->name,
if (libnvme_transport_handle_is_ns(hdl)) {
nvme_show_error("%s: a namespace device opened (dev: %s, nsid: %d)", acmd->name,

Check failure on line 3017 in nvme.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 96 exceeds 80 columns
libnvme_transport_handle_get_name(hdl), cfg.nsid);
return -EINVAL;
}
Expand Down Expand Up @@ -5437,8 +5437,8 @@
if (err)
return err;

if (!libnvme_transport_handle_is_chardev(hdl)) {
nvme_show_error(only_char_dev);
if (!libnvme_transport_handle_is_ctrl(hdl)) {
nvme_show_error(only_ctrl_dev);
return -EINVAL;
}

Expand Down Expand Up @@ -5468,8 +5468,8 @@
if (err)
return err;

if (!libnvme_transport_handle_is_chardev(hdl)) {
nvme_show_error(only_char_dev);
if (!libnvme_transport_handle_is_ctrl(hdl)) {
nvme_show_error(only_ctrl_dev);
return -EINVAL;
}

Expand Down Expand Up @@ -5497,8 +5497,8 @@
if (err)
return err;

if (!libnvme_transport_handle_is_chardev(hdl)) {
nvme_show_error(only_char_dev);
if (!libnvme_transport_handle_is_ctrl(hdl)) {
nvme_show_error(only_ctrl_dev);
return -EINVAL;
}

Expand Down Expand Up @@ -5860,8 +5860,8 @@
if (err)
return err;

if (libnvme_transport_handle_is_blkdev(hdl)) {
nvme_show_error(only_char_dev);
if (libnvme_transport_handle_is_ns(hdl)) {
nvme_show_error(only_ctrl_dev);
return -EINVAL;
}

Expand Down Expand Up @@ -6137,8 +6137,8 @@
if (err)
return err;

if (libnvme_transport_handle_is_blkdev(hdl)) {
nvme_show_error(only_char_dev);
if (libnvme_transport_handle_is_ns(hdl)) {
nvme_show_error(only_ctrl_dev);
return -EINVAL;
}

Expand Down Expand Up @@ -6441,8 +6441,8 @@
if (err)
return err;

if (libnvme_transport_handle_is_blkdev(hdl)) {
nvme_show_error(only_char_dev);
if (libnvme_transport_handle_is_ns(hdl)) {
nvme_show_error(only_ctrl_dev);
return -EINVAL;
}

Expand Down Expand Up @@ -6798,7 +6798,7 @@

printf("Success formatting namespace:%x\n", cfg.namespace_id);
if (libnvme_transport_handle_is_direct(hdl) && cfg.lbaf != prev_lbaf) {
if (libnvme_transport_handle_is_chardev(hdl)) {
if (libnvme_transport_handle_is_ctrl(hdl)) {
if (libnvme_rescan_ns(hdl) < 0) {
nvme_show_error("failed to rescan namespaces");
return -errno;
Expand Down Expand Up @@ -6830,7 +6830,7 @@
}
}
if (libnvme_transport_handle_is_direct(hdl) && cfg.reset &&
libnvme_transport_handle_is_chardev(hdl))
libnvme_transport_handle_is_ctrl(hdl))
libnvme_reset_ctrl(hdl);

return err;
Expand Down
6 changes: 3 additions & 3 deletions plugins/scaleflux/sfx-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,7 @@
__u8 reserve1[5];
} __packed;

if (libnvme_transport_handle_is_chardev(hdl))
if (libnvme_transport_handle_is_ctrl(hdl))
snprintf(dev_name, 32, "%sn%u", libnvme_transport_handle_get_name(hdl), namespace_id);
else
strcpy(dev_name, libnvme_transport_handle_get_name(hdl));
Expand Down Expand Up @@ -1507,8 +1507,8 @@
return err;

if (cfg.namespace_id == NVME_NSID_ALL) {
if (libnvme_transport_handle_is_chardev(hdl)) {
fprintf(stderr, "namespace_id or blk device required\n");
if (libnvme_transport_handle_is_ctrl(hdl)) {
fprintf(stderr, "namespace_id or namespace device required\n");

Check failure on line 1511 in plugins/scaleflux/sfx-nvme.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 87 exceeds 80 columns
return -EINVAL;
} else {
cfg.namespace_id = atoi(&libnvme_transport_handle_get_name(hdl)[strlen(libnvme_transport_handle_get_name(hdl)) - 1]);
Expand Down
7 changes: 4 additions & 3 deletions plugins/sed/sed.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

/*
* Open the NVMe device specified on the command line. It must be the
* NVMe block device (e.g. /dev/nvme0n1).
* NVMe namespace device (e.g. /dev/nvme0n1).
*/
static int sed_opal_open_device(struct libnvme_global_ctx **ctx, struct libnvme_transport_handle **hdl, int argc, char **argv,
const char *desc, struct argconfig_commandline_options *opts)
Expand All @@ -74,9 +74,10 @@
if (err)
return err;

if (!libnvme_transport_handle_is_blkdev(*hdl)) {
if (!libnvme_transport_handle_is_ns(*hdl)) {
fprintf(stderr,
"ERROR : The NVMe block device must be specified\n");
"ERROR : The NVMe namespace device (e.g. /dev/nvme0n1) "
"must be specified\n");

Check failure on line 80 in plugins/sed/sed.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: quoted string split across lines
err = -EINVAL;
}

Expand Down
Loading