From patchwork Thu Oct 20 12:53:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Juha.Riihimaki@nokia.com X-Patchwork-Id: 120807 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8D995B6F68 for ; Thu, 20 Oct 2011 23:54:02 +1100 (EST) Received: from localhost ([::1]:47227 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGs8C-0008Qb-5U for incoming@patchwork.ozlabs.org; Thu, 20 Oct 2011 08:53:56 -0400 Received: from eggs.gnu.org ([140.186.70.92]:54070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGs7q-00080F-2U for qemu-devel@nongnu.org; Thu, 20 Oct 2011 08:53:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RGs7f-0003jt-C4 for qemu-devel@nongnu.org; Thu, 20 Oct 2011 08:53:33 -0400 Received: from smtp.nokia.com ([147.243.128.24]:59249 helo=mgw-da01.nokia.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGs7f-0003jS-6N for qemu-devel@nongnu.org; Thu, 20 Oct 2011 08:53:23 -0400 Received: from Ziltoidia.research.nokia.com (esdhcp034185.research.nokia.com [172.21.34.185]) by mgw-da01.nokia.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id p9KCrH7X001248 for ; Thu, 20 Oct 2011 15:53:19 +0300 From: juha.riihimaki@nokia.com To: qemu-devel@nongnu.org Date: Thu, 20 Oct 2011 15:53:35 +0300 Message-Id: <1319115215-21224-3-git-send-email-juha.riihimaki@nokia.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1319115215-21224-1-git-send-email-juha.riihimaki@nokia.com> References: <1319115215-21224-1-git-send-email-juha.riihimaki@nokia.com> MIME-Version: 1.0 X-Nokia-AV: Clean X-MIME-Autoconverted: from 8bit to quoted-printable by mgw-da01.nokia.com id p9KCrH7X001248 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 147.243.128.24 Subject: [Qemu-devel] [PATCH v2 2/2] hw/onenand: reject read-only drives X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Juha Riihimäki Signed-off-by: Juha Riihimäki --- hw/onenand.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/hw/onenand.c b/hw/onenand.c index 6f68f70..7898da9 100644 --- a/hw/onenand.c +++ b/hw/onenand.c @@ -26,6 +26,7 @@ #include "memory.h" #include "exec-memory.h" #include "sysbus.h" +#include "qemu-error.h" /* 11 for 2kB-page OneNAND ("2nd generation") and 10 for 1kB-page chips */ #define PAGE_SHIFT 11 @@ -772,6 +773,10 @@ static int onenand_initfn(SysBusDevice *dev) s->image = memset(g_malloc(size + (size >> 5)), 0xff, size + (size >> 5)); } else { + if (bdrv_is_read_only(s->bdrv)) { + error_report("Can't use a read-only drive"); + return -1; + } s->bdrv_cur = s->bdrv; } s->otp = memset(g_malloc((64 + 2) << PAGE_SHIFT),