From 05acda4d1660591ea317619699f6aa7c659a90f1 Mon Sep 17 00:00:00 2001 From: Bernhard Kohl Date: Mon, 6 Sep 2010 17:06:02 +0200 Subject: [PATCH] raw-posix: improve detection of scsi-generic devices Allow symbolic links which point to /dev/sgX devices. Signed-off-by: Bernhard Kohl Signed-off-by: Kevin Wolf --- block/raw-posix.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index 0fce449092..813372a6c7 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