From patchwork Mon Sep 6 15:06:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Kohl X-Patchwork-Id: 63928 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 981C6B7100 for ; Tue, 7 Sep 2010 01:07:05 +1000 (EST) Received: from localhost ([127.0.0.1]:49600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OsdHh-0002ER-Ui for incoming@patchwork.ozlabs.org; Mon, 06 Sep 2010 11:07:01 -0400 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 Received: from demuprx016.emea.nsn-intra.net ([10.150.129.55]) by demumfd001.nsn-inter.net (8.12.11.20060308/8.12.11) with ESMTP id o86F6FwT018415 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 6 Sep 2010 17:06:15 +0200 Received: from localhost6.localdomain6 ([10.148.23.89]) by demuprx016.emea.nsn-intra.net (8.12.11.20060308/8.12.11) with ESMTP id o86F6Flm005675; Mon, 6 Sep 2010 17:06:15 +0200 From: Bernhard Kohl To: qemu-devel@nongnu.org Date: Mon, 6 Sep 2010 17:06:02 +0200 Message-Id: <1283785562-31830-1-git-send-email-bernhard.kohl@nsn.com> X-Mailer: git-send-email 1.7.2.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 Cc: kwolf@redhat.com, Bernhard Kohl , Bernhard Kohl Subject: [Qemu-devel] [PATCH] raw-posix: improve detection of scsi-generic devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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