There are occasions where it would be good to know the difference between a sysfs attribute failing to be accessed because we could not open versus could not read/write.
Signed-off-by: Dan Williams <[email protected]> --- util/sysfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/sysfs.c b/util/sysfs.c index 31d1a898eba2..7905455890dc 100644 --- a/util/sysfs.c +++ b/util/sysfs.c @@ -34,13 +34,13 @@ int __sysfs_read_attr(struct log_ctx *ctx, const char *path, char *buf) if (fd < 0) { log_dbg(ctx, "failed to open %s: %s\n", path, strerror(errno)); - return -1; + return -ENOENT; } n = read(fd, buf, SYSFS_ATTR_SIZE); close(fd); if (n < 0 || n >= SYSFS_ATTR_SIZE) { log_dbg(ctx, "failed to read %s: %s\n", path, strerror(errno)); - return -1; + return -EIO; } buf[n] = 0; if (n && buf[n-1] == '\n') @@ -56,7 +56,7 @@ static int write_attr(struct log_ctx *ctx, const char *path, if (fd < 0) { log_dbg(ctx, "failed to open %s: %s\n", path, strerror(errno)); - return -1; + return -ENOENT; } n = write(fd, buf, len); close(fd); @@ -64,7 +64,7 @@ static int write_attr(struct log_ctx *ctx, const char *path, if (!quiet) log_dbg(ctx, "failed to write %s to %s: %s\n", buf, path, strerror(errno)); - return -1; + return -EIO; } return 0; } _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
