From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzp7E-0006gn-2h for qemu-devel@nongnu.org; Thu, 27 Oct 2016 14:09:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzp7A-0006EQ-9k for qemu-devel@nongnu.org; Thu, 27 Oct 2016 14:09:24 -0400 From: Kevin Wolf Date: Thu, 27 Oct 2016 20:08:49 +0200 Message-Id: <1477591747-21962-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1477591747-21962-1-git-send-email-kwolf@redhat.com> References: <1477591747-21962-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 05/23] raw-posix: Don't use bdrv_ioctl() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Instead of letting raw-posix use the bdrv_ioctl() abstraction to issue an ioctl to itself, just call ioctl() directly. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block/raw-posix.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index f481e57..247e47b 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -2069,13 +2069,23 @@ static bool hdev_is_sg(BlockDriverState *bs) #if defined(__linux__) + BDRVRawState *s = bs->opaque; struct stat st; struct sg_scsi_id scsiid; int sg_version; + int ret; + + if (stat(bs->filename, &st) < 0 || !S_ISCHR(st.st_mode)) { + return false; + } - if (stat(bs->filename, &st) >= 0 && S_ISCHR(st.st_mode) && - !bdrv_ioctl(bs, SG_GET_VERSION_NUM, &sg_version) && - !bdrv_ioctl(bs, SG_GET_SCSI_ID, &scsiid)) { + ret = ioctl(s->fd, SG_GET_VERSION_NUM, &sg_version); + if (ret < 0) { + return false; + } + + ret = ioctl(s->fd, SG_GET_SCSI_ID, &scsiid); + if (ret >= 0) { DPRINTF("SG device found: type=%d, version=%d\n", scsiid.scsi_type, sg_version); return true; -- 1.8.3.1