From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:55690) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvBTP-00021M-Cc for qemu-devel@nongnu.org; Wed, 08 Feb 2012 12:38:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RvBTK-0000ze-J3 for qemu-devel@nongnu.org; Wed, 08 Feb 2012 12:38:27 -0500 Received: from mail-pz0-f45.google.com ([209.85.210.45]:63221) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvBTK-0000z1-7O for qemu-devel@nongnu.org; Wed, 08 Feb 2012 12:38:22 -0500 Received: by mail-pz0-f45.google.com with SMTP id p14so796238dad.4 for ; Wed, 08 Feb 2012 09:38:21 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 8 Feb 2012 18:37:32 +0100 Message-Id: <1328722656-22856-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1328722656-22856-1-git-send-email-pbonzini@redhat.com> References: <1328722656-22856-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 1/5] raw-posix: always prefer specific devices to hdev List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: amit.shah@redhat.com, armbru@redhat.com There is no need to try matching device names; using ioctls is more effective. So, always return a low priority from the generic hdev_probe_device and let the ioctl tests override it. Signed-off-by: Paolo Bonzini --- block/raw-posix.c | 12 +++--------- 1 files changed, 3 insertions(+), 9 deletions(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index 2ee5d69..2a5b6fa 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -712,13 +712,9 @@ static int hdev_probe_device(const char *filename) { struct stat st; - /* allow a dedicated CD-ROM driver to match with a higher priority */ - if (strstart(filename, "/dev/cdrom", NULL)) - return 50; - if (stat(filename, &st) >= 0 && (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))) { - return 100; + return 50; } return 0; @@ -947,9 +943,6 @@ static int floppy_probe_device(const char *filename) struct floppy_struct fdparam; struct stat st; - if (strstart(filename, "/dev/fd", NULL)) - prio = 50; - fd = open(filename, O_RDONLY | O_NONBLOCK); if (fd < 0) { goto out; @@ -959,7 +952,8 @@ static int floppy_probe_device(const char *filename) goto outc; } - /* Attempt to detect via a floppy specific ioctl */ + /* Attempt to detect via a floppy specific ioctl. If it fails, + * hdev will be just as good. */ ret = ioctl(fd, FDGETPRM, &fdparam); if (ret >= 0) prio = 100; -- 1.7.7.6