1
0
Fork 0

Adding upstream version 2.2.1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-16 12:17:56 +01:00
parent 28d4a2895d
commit 8dc527e3df
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
446 changed files with 8369 additions and 4059 deletions

View file

@ -117,15 +117,16 @@ static void show_shannon_smart_log(struct nvme_shannon_smart_log *smart,
static int get_additional_smart_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
{
struct nvme_shannon_smart_log smart_log;
int err, fd;
char *desc = "Get Shannon vendor specific additional smart log (optionally, "\
"for the specified namespace), and show it.";
const char *namespace = "(optional) desired namespace";
const char *raw = "dump output in binary format";
struct nvme_dev *dev;
struct config {
__u32 namespace_id;
bool raw_binary;
};
int err;
struct config cfg = {
.namespace_id = NVME_NSID_ALL,
@ -137,20 +138,21 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
OPT_END()
};
fd = parse_and_open(argc, argv, desc, opts);
if (fd < 0)
return fd;
err = nvme_get_nsid_log(fd, false, 0xca, cfg.namespace_id,
sizeof(smart_log), &smart_log);
err = parse_and_open(&dev, argc, argv, desc, opts);
if (err)
return err;
err = nvme_get_nsid_log(dev_fd(dev), false, 0xca, cfg.namespace_id,
sizeof(smart_log), &smart_log);
if (!err) {
if (!cfg.raw_binary)
show_shannon_smart_log(&smart_log, cfg.namespace_id, devicename);
show_shannon_smart_log(&smart_log, cfg.namespace_id,
dev->name);
else
d_raw((unsigned char *)&smart_log, sizeof(smart_log));
}
else if (err > 0)
nvme_show_status(err);
close(fd);
dev_close(dev);
return err;
}
@ -174,9 +176,10 @@ static int get_additional_feature(int argc, char **argv, struct command *cmd, st
const char *data_len = "buffer len (if) data is returned";
const char *cdw11 = "dword 11 for interrupt vector config";
const char *human_readable = "show infos in readable format";
int err, fd;
__u32 result;
struct nvme_dev *dev;
void *buf = NULL;
__u32 result;
int err;
struct config {
__u32 namespace_id;
@ -207,24 +210,24 @@ static int get_additional_feature(int argc, char **argv, struct command *cmd, st
OPT_END()
};
fd = parse_and_open(argc, argv, desc, opts);
if (fd < 0)
return fd;
err = parse_and_open(&dev, argc, argv, desc, opts);
if (err)
return err;
if (cfg.sel > 7) {
fprintf(stderr, "invalid 'select' param:%d\n", cfg.sel);
close(fd);
dev_close(dev);
return EINVAL;
}
if (!cfg.feature_id) {
fprintf(stderr, "feature-id required param\n");
close(fd);
dev_close(dev);
return EINVAL;
}
if (cfg.data_len) {
if (posix_memalign(&buf, getpagesize(), cfg.data_len))
{
close(fd);
dev_close(dev);
exit(ENOMEM);
}
memset(buf, 0, cfg.data_len);
@ -232,7 +235,7 @@ static int get_additional_feature(int argc, char **argv, struct command *cmd, st
struct nvme_get_features_args args = {
.args_size = sizeof(args),
.fd = fd,
.fd = dev_fd(dev),
.fid = cfg.feature_id,
.nsid = cfg.namespace_id,
.sel = cfg.sel,
@ -286,10 +289,11 @@ static int set_additional_feature(int argc, char **argv, struct command *cmd, st
const char *data = "optional file for feature data (default stdin)";
const char *value = "new value of feature (required)";
const char *save = "specifies that the controller shall save the attribute";
int err, fd;
__u32 result;
void *buf = NULL;
int ffd = STDIN_FILENO;
struct nvme_dev *dev;
void *buf = NULL;
__u32 result;
int err;
struct config {
char *file;
@ -319,20 +323,20 @@ static int set_additional_feature(int argc, char **argv, struct command *cmd, st
OPT_END()
};
fd = parse_and_open(argc, argv, desc, opts);
if (fd < 0)
return fd;
err = parse_and_open(&dev, argc, argv, desc, opts);
if (err)
return err;
if (!cfg.feature_id) {
fprintf(stderr, "feature-id required param\n");
close(fd);
dev_close(dev);
return EINVAL;
}
if (cfg.data_len) {
if (posix_memalign(&buf, getpagesize(), cfg.data_len)){
fprintf(stderr, "can not allocate feature payload\n");
close(fd);
dev_close(dev);
return ENOMEM;
}
memset(buf, 0, cfg.data_len);
@ -357,7 +361,7 @@ static int set_additional_feature(int argc, char **argv, struct command *cmd, st
struct nvme_set_features_args args = {
.args_size = sizeof(args),
.fd = fd,
.fd = dev_fd(dev),
.fid = cfg.feature_id,
.nsid = cfg.namespace_id,
.cdw11 = cfg.value,