@@ -662,7 +662,8 @@ static int sysfs_read_attr(struct ndctl_ctx *ctx, const char *path, char *buf)
return 0;
}
-static int sysfs_write_attr(struct ndctl_ctx *ctx, const char *path, const char *buf)
+static int __sysfs_write_attr(struct ndctl_ctx *ctx, const char *path,
+ const char *buf, int quiet)
{
int fd = open(path, O_WRONLY|O_CLOEXEC);
int n, len = strlen(buf) + 1;
@@ -674,13 +675,26 @@ static int sysfs_write_attr(struct ndctl_ctx *ctx, const char *path, const char
n = write(fd, buf, len);
close(fd);
if (n < len) {
- dbg(ctx, "failed to write %s to %s: %s\n", buf, path,
- strerror(errno));
+ if (!quiet)
+ dbg(ctx, "failed to write %s to %s: %s\n", buf, path,
+ strerror(errno));
return -1;
}
return 0;
}
+static int sysfs_write_attr(struct ndctl_ctx *ctx, const char *path,
+ const char *buf)
+{
+ return __sysfs_write_attr(ctx, path, buf, 0);
+}
+
+static int sysfs_write_attr_quiet(struct ndctl_ctx *ctx, const char *path,
+ const char *buf)
+{
+ return __sysfs_write_attr(ctx, path, buf, 1);
+}
+
static char *__dev_path(char *type, int major, int minor, int parent)
{
char *path, *dev_path;
@@ -2745,7 +2759,7 @@ static int ndctl_bind(struct ndctl_ctx *ctx, struct kmod_module *module,
continue;
}
- rc = sysfs_write_attr(ctx, drv_path, devname);
+ rc = sysfs_write_attr_quiet(ctx, drv_path, devname);
free(drv_path);
if (rc == 0)
break;
Given that we need to try every driver on an nvdimm bus the default error message reporting from sysfs_write_attr() is not very meaningful. Instead we really care about the case where the bind attempt failed completely. Suppress debug messages from sysfs_write_attr() when called by ndctl_bind(). Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- lib/libndctl.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)