Received: from [140.186.70.92] (port=38856 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OsdH5-0002EI-B9 for qemu-devel@nongnu.org; Mon, 06 Sep 2010 11:06:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OsdH3-0002Y5-M6 for qemu-devel@nongnu.org; Mon, 06 Sep 2010 11:06:23 -0400 Received: from demumfd001.nsn-inter.net ([93.183.12.32]:13706) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OsdH3-0002XH-8K for qemu-devel@nongnu.org; Mon, 06 Sep 2010 11:06:21 -0400 From: Bernhard Kohl Date: Mon, 6 Sep 2010 17:06:02 +0200 Message-Id: <1283785562-31830-1-git-send-email-bernhard.kohl@nsn.com> Subject: [Qemu-devel] [PATCH] raw-posix: improve detection of scsi-generic devices List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, Bernhard Kohl , Bernhard Kohl From: Bernhard Kohl Allow symbolic links which point to /dev/sgX devices. Signed-off-by: Bernhard Kohl --- block/raw-posix.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index 72fb8ce..4544a57 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -48,6 +48,7 @@ #endif #ifdef __linux__ #include +#include #include #include #endif @@ -868,8 +869,13 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags) s->type = FTYPE_FILE; #if defined(__linux__) - if (strstart(filename, "/dev/sg", NULL)) { - bs->sg = 1; + { + char resolved_path[ MAXPATHLEN ], *temp; + + temp = realpath(filename, resolved_path); + if (temp && strstart(temp, "/dev/sg", NULL)) { + bs->sg = 1; + } } #endif -- 1.7.2.2