Previously only the log header output since the log length is changeable.
The changes to output the changeable log length correctly.
Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "nvme-print.h"
+#include "util/logging.h"
static struct print_ops binary_print_ops;
d_raw((unsigned char *)log, sizeof(*log));
}
-static void binary_reachability_associations_log(struct nvme_reachability_associations_log *log)
+static void binary_reachability_associations_log(struct nvme_reachability_associations_log *log,
+ __u64 len)
{
- d_raw((unsigned char *)log, sizeof(*log));
+ d_raw((unsigned char *)log, len);
}
static struct print_ops binary_print_ops = {
#include <errno.h>
#include <time.h>
+#include <ccan/ccan/compiler/compiler.h>
+
#include "nvme-print.h"
#include "util/json.h"
+#include "util/logging.h"
#include "nvme.h"
#include "common.h"
json_print(r);
}
-static void json_reachability_associations_log(struct nvme_reachability_associations_log *log)
+static void json_reachability_associations_log(struct nvme_reachability_associations_log *log,
+ __u64 len UNUSED)
{
struct json_object *r = json_create_object();
__u16 i;
#include "nvme-models.h"
#include "util/suffix.h"
#include "util/types.h"
+#include "util/logging.h"
#include "common.h"
static const uint8_t zero_uuid[16] = { 0 };
}
}
-static void stdout_reachability_associations_log(struct nvme_reachability_associations_log *log)
+static void stdout_reachability_associations_log(struct nvme_reachability_associations_log *log,
+ __u64 len)
{
__u16 i;
__u32 j;
+ print_debug("len: %"PRIu64"\n", (uint64_t)len);
printf("chngc: %"PRIu64"\n", le64_to_cpu(log->chngc));
printf("nrad: %u\n", le16_to_cpu(log->nrad));
}
void nvme_show_reachability_associations_log(struct nvme_reachability_associations_log *log,
- nvme_print_flags_t flags)
+ __u64 len, nvme_print_flags_t flags)
{
- nvme_print(reachability_associations_log, flags, log);
+ nvme_print(reachability_associations_log, flags, log, len);
}
void (*rotational_media_info_log)(struct nvme_rotational_media_info_log *info);
void (*dispersed_ns_psub_log)(struct nvme_dispersed_ns_participating_nss_log *log);
void (*reachability_groups_log)(struct nvme_reachability_groups_log *log);
- void (*reachability_associations_log)(struct nvme_reachability_associations_log *log);
+ void (*reachability_associations_log)(struct nvme_reachability_associations_log *log,
+ __u64 len);
/* libnvme tree print functions */
void (*list_item)(nvme_ns_t n);
void nvme_show_reachability_groups_log(struct nvme_reachability_groups_log *log,
nvme_print_flags_t flags);
void nvme_show_reachability_associations_log(struct nvme_reachability_associations_log *log,
- nvme_print_flags_t flags);
+ __u64 len, nvme_print_flags_t flags);
#endif /* NVME_PRINT_H */
}
static int get_reachability_association_desc(struct nvme_dev *dev, struct nvme_get_log_args *args,
- __u64 offset,
+ __u64 *offset,
struct nvme_reachability_associations_log **logp)
{
int err;
for (i = 0; i < le16_to_cpu(log->nrad); i++) {
len = sizeof(*log->rad);
- err = get_log_offset(dev, args, &offset, len, (void **)&log);
+ err = get_log_offset(dev, args, offset, len, (void **)&log);
if (err)
goto err_free;
len = le32_to_cpu(log->rad[i].nrid) * sizeof(*log->rad[i].rgid);
- err = get_log_offset(dev, args, &offset, len, (void **)&log);
+ err = get_log_offset(dev, args, offset, len, (void **)&log);
if (err)
goto err_free;
}
}
static int get_reachability_associations(struct nvme_dev *dev, bool rao, bool rae,
- struct nvme_reachability_associations_log **logp)
+ struct nvme_reachability_associations_log **logp,
+ __u64 *lenp)
{
int err;
struct nvme_reachability_associations_log *log;
if (err)
goto err_free;
- err = get_reachability_association_desc(dev, &args, log_len, &log);
+ err = get_reachability_association_desc(dev, &args, &log_len, &log);
if (err)
goto err_free;
*logp = log;
+ *lenp = log_len;
return 0;
err_free:
const char *rao = "Return Associations Only";
nvme_print_flags_t flags;
int err;
+ __u64 len = 0;
_cleanup_free_ struct nvme_reachability_associations_log *log = NULL;
return err;
}
- err = get_reachability_associations(dev, cfg.rao, cfg.rae, &log);
+ err = get_reachability_associations(dev, cfg.rao, cfg.rae, &log, &len);
if (!err)
- nvme_show_reachability_associations_log(log, flags);
+ nvme_show_reachability_associations_log(log, len, flags);
else if (err > 0)
nvme_show_status(err);
else