From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751670AbeA2KTh (ORCPT ); Mon, 29 Jan 2018 05:19:37 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36043 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750913AbeA2KTf (ORCPT ); Mon, 29 Jan 2018 05:19:35 -0500 X-Google-Smtp-Source: AH8x227/h8xqZ6QMVgSOTfYYQEPiJVqOfqCnet+9Ax2+hvU41OoGXGjg5pNMv/cX9yI1Foo9Iq2TFw== From: Romain Izard To: Artem Bityutskiy , Richard Weinberger , David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Cyrille Pitchen Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Romain Izard Subject: [PATCH v1] mtd: ubi: block: Fix error for write access Date: Mon, 29 Jan 2018 11:18:20 +0100 Message-Id: <20180129101820.1692-1-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When opening a device with write access, ubiblock_open returns an error code. Currently, this error code is -EPERM, but this is not the right value. The open function for other block devices returns -EROFS when opening read-only devices with FMODE_WRITE set. When used with dm-verity, the veritysetup userspace tool is expecting EROFS, and refuses to use the ubiblock device. Use -EROFS for ubiblock as well. As a result, veritysetup accepts the ubiblock device as valid. Fixes: 9d54c8a33eec (UBI: R/O block driver on top of UBI volumes) Signed-off-by: Romain Izard --- drivers/mtd/ubi/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c index b210fdb31c98..4533423cf2aa 100644 --- a/drivers/mtd/ubi/block.c +++ b/drivers/mtd/ubi/block.c @@ -242,7 +242,7 @@ static int ubiblock_open(struct block_device *bdev, fmode_t mode) * in any case. */ if (mode & FMODE_WRITE) { - ret = -EPERM; + ret = -EROFS; goto out_unlock; } -- 2.14.1