From a79a69d226f8b465da8eb2ff8dd6ffc2847de7a6 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Fri, 15 Dec 2017 11:25:23 +0900 Subject: [PATCH] bdev_aio: Remove use of perror() for open/close failure All SPDK libraries should use the spdk/log.h family of functions for logging. Change-Id: I4c12388433f8c57291cea9f30566438a9d78e3d1 Signed-off-by: Shuhei Matsumoto Reviewed-on: https://review.gerrithub.io/391683 Reviewed-by: Jim Harris Reviewed-by: Daniel Verkamp Tested-by: SPDK Automated Test System --- lib/bdev/aio/bdev_aio.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/bdev/aio/bdev_aio.c b/lib/bdev/aio/bdev_aio.c index fb318e824..0c7ba8277 100644 --- a/lib/bdev/aio/bdev_aio.c +++ b/lib/bdev/aio/bdev_aio.c @@ -42,6 +42,7 @@ #include "spdk/io_channel.h" #include "spdk/json.h" #include "spdk/util.h" +#include "spdk/string.h" #include "spdk_internal/log.h" @@ -65,13 +66,16 @@ static int bdev_aio_open(struct file_disk *disk) { int fd; + char buf[64]; fd = open(disk->filename, O_RDWR | O_DIRECT); if (fd < 0) { /* Try without O_DIRECT for non-disk files */ fd = open(disk->filename, O_RDWR); if (fd < 0) { - perror("open"); + spdk_strerror_r(errno, buf, sizeof(buf)); + SPDK_ERRLOG("open() failed (file:%s), errno %d: %s\n", + disk->filename, errno, buf); disk->fd = -1; return -1; } @@ -86,6 +90,7 @@ static int bdev_aio_close(struct file_disk *disk) { int rc; + char buf[64]; if (disk->fd == -1) { return 0; @@ -93,7 +98,9 @@ bdev_aio_close(struct file_disk *disk) rc = close(disk->fd); if (rc < 0) { - perror("close"); + spdk_strerror_r(errno, buf, sizeof(buf)); + SPDK_ERRLOG("close() failed (fd=%d), errno %d: %s\n", + disk->fd, errno, buf); return -1; }